diff --git a/app/models/incidents/ability.rb b/app/models/incidents/ability.rb index 6ae2f7be..d9b6e216 100644 --- a/app/models/incidents/ability.rb +++ b/app/models/incidents/ability.rb @@ -15,6 +15,7 @@ def initialize(person) dispatch_console(region_admin) if is_admin or person.has_capability 'dispatch_console' create_incident if person.has_capability 'create_incident' + download if person.has_capability 'download' submit_incident_report if is_admin or person.has_capability 'submit_incident_report' cas_admin if is_admin or person.has_capability 'cas_admin' incident_details if is_admin or person.has_capability 'incident_details' @@ -87,6 +88,10 @@ def incidents_admin(region_admin) can :manage, Incidents::InitialIncidentReport, incident: {region_id: @region_scope} end + def download + can :download, Incidents::Incident, region_id: @region_scope + end + def incident_details can [:read_dat_details, :index], Incidents::Incident end diff --git a/app/models/scheduler/ability.rb b/app/models/scheduler/ability.rb index 1bdd9fac..b01902c2 100644 --- a/app/models/scheduler/ability.rb +++ b/app/models/scheduler/ability.rb @@ -24,6 +24,8 @@ def initialize(person) dat_admin_shift_territories = person.scope_for_capability('shift_territory_dat_admin') shift_territory_dat_admin dat_admin_shift_territories if dat_admin_shift_territories.present? # is dat shift_territory admin + download if person.has_capability 'region_admin' or person.has_capability 'download' + read_only if ENV['READ_ONLY'] end @@ -71,4 +73,9 @@ def shift_territory_dat_admin ids def read_only cannot [:update, :create, :destroy], :all end + + def download + can :download, Scheduler::Shift + can :download, Roster::Person + end end diff --git a/app/views/incidents/incidents_list/_index_table.html.haml b/app/views/incidents/incidents_list/_index_table.html.haml index 137a7d88..4566402b 100644 --- a/app/views/incidents/incidents_list/_index_table.html.haml +++ b/app/views/incidents/incidents_list/_index_table.html.haml @@ -1,7 +1,8 @@ .text-center= paginate collection, :theme => 'twitter-bootstrap-3', remote: true -%h1(style="font-size:150%;text-align:center;margin-top:0px") - = link_to 'Download as CSV', incidents_region_incidents_path(format: :csv, params: request.query_parameters.merge(page: 'all')), download: "incidents.csv" +- if can? :download, Incidents::Incident + %h1(style="font-size:150%;text-align:center;margin-top:0px") + = link_to 'Download as CSV', incidents_region_incidents_path(format: :csv, params: request.query_parameters.merge(page: 'all')), download: "incidents.csv" %table.table.table-condensed %tr diff --git a/app/views/incidents/responses/responders.html.haml b/app/views/incidents/responses/responders.html.haml index 0a962787..345fb47a 100644 --- a/app/views/incidents/responses/responders.html.haml +++ b/app/views/incidents/responses/responders.html.haml @@ -7,7 +7,8 @@ =date_field_tag "date_before", current_scopes[:date_before], class: 'form-control', placeholder: 'Before YYYY-MM-DD' =submit_tag 'Show', class: 'btn btn-primary' -= link_to 'Download as CSV', incidents_region_responders_path(format: :csv, params: request.query_parameters.merge(page: 'all')), download: "people.csv" +- if can? :download, Incidents::Incident + = link_to 'Download as CSV', incidents_region_responders_path(format: :csv, params: request.query_parameters.merge(page: 'all')), download: "people.csv" .legend %span.text-success %i.fa.fa-check-square diff --git a/app/views/scheduler/people/_index_table.html.haml b/app/views/scheduler/people/_index_table.html.haml index 430c0179..47ff32b0 100644 --- a/app/views/scheduler/people/_index_table.html.haml +++ b/app/views/scheduler/people/_index_table.html.haml @@ -1,6 +1,7 @@ .text-center= paginate collection, :theme => 'twitter-bootstrap-3', remote: true -%h1(style="font-size:150%;text-align:center;margin-top:0px") - = link_to 'Download as CSV', scheduler_people_path(format: :csv, params: request.query_parameters.merge(page: 'all')), download: "people.csv" +- if can? :download, Roster::Person + %h1(style="font-size:150%;text-align:center;margin-top:0px") + = link_to 'Download as CSV', scheduler_people_path(format: :csv, params: request.query_parameters.merge(page: 'all')), download: "people.csv" %table.table.table-striped.table-condensed %thead diff --git a/app/views/scheduler/shift_report/_index_table.html.haml b/app/views/scheduler/shift_report/_index_table.html.haml index 619abcd5..bc58878b 100644 --- a/app/views/scheduler/shift_report/_index_table.html.haml +++ b/app/views/scheduler/shift_report/_index_table.html.haml @@ -1,6 +1,7 @@ .text-center= paginate collection, :theme => 'twitter-bootstrap-3', remote: true -%h1(style="font-size:150%;text-align:center;margin-top:0px") - = link_to 'Download as CSV', scheduler_shift_report_index_path(format: :csv, params: request.query_parameters.merge(page: 'all')), download: "shifts.csv" +- if can? :download, Scheduler::Shift + %h1(style="font-size:150%;text-align:center;margin-top:0px") + = link_to 'Download as CSV', scheduler_shift_report_index_path(format: :csv, params: request.query_parameters.merge(page: 'all')), download: "shifts.csv" %table.table.table-striped.table-condensed %thead