-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make public displays feature accessible to users (#4186)
- Loading branch information
Showing
21 changed files
with
562 additions
and
196 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
89 changes: 89 additions & 0 deletions
89
app/controllers/school_groups/digital_signage_controller.rb
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,89 @@ | ||
module SchoolGroups | ||
class DigitalSignageController < ApplicationController | ||
load_and_authorize_resource :school_group | ||
|
||
def index | ||
end | ||
|
||
def charts | ||
send_data charts_csv, filename: csv_filename_for(:charts) | ||
end | ||
|
||
def equivalences | ||
send_data equivalences_csv, filename: csv_filename_for(:equivalences) | ||
end | ||
|
||
private | ||
|
||
def csv_filename_for(link_type) | ||
title = I18n.t("pupils.digital_signage.index.school_group.links.#{link_type}") | ||
"#{@school_group.name}-#{title}-#{Time.zone.now.strftime('%Y-%m-%d')}".parameterize + '.csv' | ||
end | ||
|
||
def equivalences_csv | ||
CSV.generate do |csv| | ||
csv << [ | ||
t('common.school'), | ||
t('advice_pages.index.priorities.table.columns.fuel_type'), | ||
t('pupils.digital_signage.table.columns.link') | ||
] | ||
schools.each do |school| | ||
if school.has_electricity? | ||
csv << [ | ||
school.name, | ||
t('common.electricity'), | ||
pupils_school_digital_signage_equivalences_url(school, :electricity) | ||
] | ||
end | ||
if school.has_gas? | ||
csv << [ | ||
school.name, | ||
t('common.gas'), | ||
pupils_school_digital_signage_equivalences_url(school, :gas) | ||
] | ||
end | ||
end | ||
end | ||
end | ||
|
||
def charts_csv | ||
CSV.generate do |csv| | ||
csv << [ | ||
t('common.school'), | ||
t('advice_pages.index.priorities.table.columns.fuel_type'), | ||
t('pupils.digital_signage.table.columns.chart_type'), | ||
t('pupils.digital_signage.table.columns.description'), | ||
t('pupils.digital_signage.table.columns.link') | ||
] | ||
schools.each do |school| | ||
if school.has_electricity? | ||
Pupils::DigitalSignageController::CHART_TYPES.each do |chart_type| | ||
csv << [ | ||
school.name, | ||
t('common.electricity'), | ||
t("pupils.digital_signage.index.charts.#{chart_type}.title"), | ||
t("pupils.digital_signage.index.charts.#{chart_type}.description"), | ||
pupils_school_digital_signage_charts_url(school, :electricity, chart_type) | ||
] | ||
end | ||
end | ||
if school.has_gas? | ||
Pupils::DigitalSignageController::CHART_TYPES.each do |chart_type| | ||
csv << [ | ||
school.name, | ||
t('common.gas'), | ||
t("pupils.digital_signage.index.charts.#{chart_type}.title"), | ||
t("pupils.digital_signage.index.charts.#{chart_type}.description"), | ||
pupils_school_digital_signage_charts_url(school, :gas, chart_type) | ||
] | ||
end | ||
end | ||
end | ||
end | ||
end | ||
|
||
def schools | ||
@school_group.schools.active.data_enabled.where(data_sharing: :public).order(:name) | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
module Schools | ||
class DigitalSignageController < ApplicationController | ||
load_and_authorize_resource :school | ||
|
||
def index | ||
end | ||
end | ||
end |
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
This file was deleted.
Oops, something went wrong.
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,59 @@ | ||
<%= content_for :page_title, t('pupils.digital_signage.index.title') %> | ||
|
||
<div class="row"> | ||
<div class="col-12"> | ||
<h1><%= t('pupils.digital_signage.index.title') %></h1> | ||
</div> | ||
</div> | ||
|
||
<div class="row"> | ||
<div class="col-12"> | ||
<%= render PromptComponent.new status: :neutral, icon: 'info-circle' do |c| %> | ||
<% c.with_link { link_to t('pupils.digital_signage.index.prompt.link_text'), 'mailto:[email protected]' } %> | ||
<% c.with_title { t('pupils.digital_signage.index.prompt.title') } %> | ||
<p> | ||
<%= t('pupils.digital_signage.index.prompt.text') %> | ||
</p> | ||
<% end %> | ||
</div> | ||
</div> | ||
|
||
<div class="row"> | ||
<div class="col-12"> | ||
<%= t('pupils.digital_signage.index.intro_html') %> | ||
</div> | ||
</div> | ||
|
||
<div class="row"> | ||
<div class="col-12"> | ||
<h2><%= t('pupils.digital_signage.index.school_group.data_sharing.title') %></h2> | ||
<%= t('pupils.digital_signage.index.public_data_html') %> | ||
</div> | ||
</div> | ||
|
||
<div class="row"> | ||
<div class="col-12"> | ||
<h2><%= t('pupils.digital_signage.index.school_group.downloads.title') %></h2> | ||
<%= t('pupils.digital_signage.index.school_group.downloads.intro_html') %> | ||
</div> | ||
</div> | ||
|
||
<div class="row"> | ||
<div class="col-12" id='equivalences-downloads'> | ||
<h2><%= t('pupils.digital_signage.index.equivalences.title') %></h2> | ||
<p><%= t('pupils.digital_signage.index.equivalences.intro_html') %></p> | ||
<p><%= link_to t('common.labels.download'), | ||
equivalences_school_group_digital_signage_index_path(@school_group, format: :csv), | ||
class: 'btn btn-sm btn-default' %></p> | ||
</div> | ||
</div> | ||
|
||
<div class="row"> | ||
<div class="col-12" id='charts-downloads'> | ||
<h2><%= t('pupils.digital_signage.index.charts.title') %></h2> | ||
<p><%= t('pupils.digital_signage.index.charts.intro_html') %></p> | ||
<p><%= link_to t('common.labels.download'), | ||
charts_school_group_digital_signage_index_path(@school_group, format: :csv), | ||
class: 'btn btn-sm btn-default' %></p> | ||
</div> | ||
</div> |
Oops, something went wrong.