-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1570 from GSA/dev-with-httpoison-1445
Replace HTTPoison Card #1445
- Loading branch information
Showing
13 changed files
with
252 additions
and
152 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
defmodule Web.Api.BannerController do | ||
use Web, :controller | ||
import Plug.Conn | ||
|
||
alias ChallengeGov.SiteContent | ||
def init(default), do: default | ||
|
||
def call(conn, _params) do | ||
{:ok, banner} = SiteContent.get("site_wide_banner") | ||
|
||
case banner_is_active?(banner) do | ||
true -> | ||
text(conn, banner.content) | ||
|
||
false -> | ||
text(conn, "") | ||
end | ||
end | ||
|
||
defp banner_is_active?(banner) do | ||
now = DateTime.utc_now() | ||
|
||
if is_nil(banner.start_date) or is_nil(banner.end_date) do | ||
false | ||
else | ||
!is_nil(banner.content) and | ||
DateTime.compare(now, banner.start_date) === :gt and | ||
DateTime.compare(now, banner.end_date) === :lt | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.