-
Notifications
You must be signed in to change notification settings - Fork 78
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 #645 from alphagov/add-easter-message
Add a moderation delay message for Easter
- Loading branch information
Showing
17 changed files
with
314 additions
and
34 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
class Admin::HolidaysController < Admin::AdminController | ||
before_action :require_sysadmin | ||
before_action :fetch_holiday | ||
|
||
def edit | ||
respond_to do |format| | ||
format.html | ||
end | ||
end | ||
|
||
def update | ||
if @holiday.update(holiday_params) | ||
redirect_to edit_admin_site_url, notice: :site_updated | ||
else | ||
respond_to do |format| | ||
format.html { render :edit } | ||
end | ||
end | ||
end | ||
|
||
private | ||
|
||
def fetch_holiday | ||
@holiday = Holiday.instance | ||
end | ||
|
||
def holiday_params | ||
params.require(:holiday).permit(*holiday_attributes) | ||
end | ||
|
||
def holiday_attributes | ||
%i[christmas_start christmas_end easter_start easter_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
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,48 @@ | ||
class Holiday < ActiveRecord::Base | ||
class << self | ||
def before_remove_const | ||
Thread.current[:__holiday__] = nil | ||
end | ||
|
||
def instance | ||
Thread.current[:__holiday__] ||= first_or_create(defaults) | ||
end | ||
|
||
def christmas?(today = Date.current) | ||
instance.christmas?(today) | ||
end | ||
|
||
def easter?(today = Date.current) | ||
instance.easter?(today) | ||
end | ||
|
||
private | ||
|
||
def defaults | ||
{ | ||
christmas_start: '2017-12-22', | ||
christmas_end: '2018-01-04', | ||
easter_start: '2018-03-30', | ||
easter_end: '2018-04-09' | ||
} | ||
end | ||
end | ||
|
||
def christmas?(today = Date.current) | ||
christmas.cover?(today) | ||
end | ||
|
||
def easter?(today = Date.current) | ||
easter.cover?(today) | ||
end | ||
|
||
private | ||
|
||
def christmas | ||
christmas_start..christmas_end | ||
end | ||
|
||
def easter | ||
easter_start..easter_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
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,28 @@ | ||
<h1>Edit Site</h1> | ||
|
||
<div class="grid-row"> | ||
<div class="grid-column"> | ||
<%= render "admin/shared/site_tabs" %> | ||
</div> | ||
|
||
<div class="column-two-thirds extra-gutter"> | ||
<%= form_for @holiday, url: admin_holidays_url do |form| %> | ||
<div class="form-group"> | ||
<label class="form-label" for="holiday_christmas_start">Christmas period</label> | ||
<%= form.date_select :christmas_start, {}, tabindex: increment, class: 'form-control form-control-auto' %> | ||
– | ||
<%= form.date_select :christmas_end, {}, tabindex: increment, class: 'form-control form-control-auto' %> | ||
</div> | ||
|
||
<div class="form-group"> | ||
<label class="form-label" for="holiday_easter_start">Easter period</label> | ||
<%= form.date_select :easter_start, {}, tabindex: increment, class: 'form-control form-control-auto' %> | ||
– | ||
<%= form.date_select :easter_end, {}, tabindex: increment, class: 'form-control form-control-auto' %> | ||
</div> | ||
|
||
<%= form.submit 'Save', class: 'button' %> | ||
<%= link_to 'Cancel', admin_root_path, class: 'button-secondary' %> | ||
<% end %> | ||
</div> | ||
</div> |
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,33 @@ | ||
<p class="tabs"> | ||
<% if params[:tab] == "petitions" %> | ||
<%= link_to "Description", edit_admin_site_path %> | | ||
Petitions | | ||
<%= link_to "Moderation", edit_admin_site_path(tab: 'moderation') %> | | ||
<%= link_to "Access", edit_admin_site_path(tab: 'access') %> | | ||
<%= link_to "Holidays", edit_admin_holidays_path %> | ||
<% elsif params[:tab] == "moderation" %> | ||
<%= link_to "Description", edit_admin_site_path %> | | ||
<%= link_to "Petitions", edit_admin_site_path(tab: 'petitions') %> | | ||
Moderation | | ||
<%= link_to "Access", edit_admin_site_path(tab: 'access') %> | | ||
<%= link_to "Holidays", edit_admin_holidays_path %> | ||
<% elsif params[:tab] == "access" %> | ||
<%= link_to "Description", edit_admin_site_path %> | | ||
<%= link_to "Petitions", edit_admin_site_path(tab: 'petitions') %> | | ||
<%= link_to "Moderation", edit_admin_site_path(tab: 'moderation') %> | | ||
Access | | ||
<%= link_to "Holidays", edit_admin_holidays_path %> | ||
<% elsif controller_name == "holidays" %> | ||
<%= link_to "Description", edit_admin_site_path %> | | ||
<%= link_to "Petitions", edit_admin_site_path(tab: 'petitions') %> | | ||
<%= link_to "Moderation", edit_admin_site_path(tab: 'moderation') %> | | ||
<%= link_to "Access", edit_admin_site_path(tab: 'access') %> | | ||
Holidays | ||
<% else %> | ||
Description | | ||
<%= link_to "Petitions", edit_admin_site_path(tab: 'petitions') %> | | ||
<%= link_to "Moderation", edit_admin_site_path(tab: 'moderation') %> | | ||
<%= link_to "Access", edit_admin_site_path(tab: 'access') %> | | ||
<%= link_to "Holidays", edit_admin_holidays_path %> | ||
<% end %> | ||
</p> |
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,11 @@ | ||
class CreateHolidays < ActiveRecord::Migration | ||
def change | ||
create_table :holidays do |t| | ||
t.date :christmas_start | ||
t.date :christmas_end | ||
t.date :easter_start | ||
t.date :easter_end | ||
t.timestamps null: false | ||
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
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.