diff options
| author | Zog | 2018-03-01 10:26:06 +0100 |
|---|---|---|
| committer | Zog | 2018-03-01 10:26:06 +0100 |
| commit | f62b28cad97b6c7c7e281f368e599acd54d4e559 (patch) | |
| tree | 6a6dcdbc24926afddb9245c4502eabfa4e951f68 | |
| parent | 4acb5a53da2995aacc7b6ce2c802ad16fa563bf8 (diff) | |
| download | chouette-core-f62b28cad97b6c7c7e281f368e599acd54d4e559.tar.bz2 | |
Refs #6064; Use same logic to load calendars in dashboard and in controller6064-inconsistency-in-dashboard
| -rw-r--r-- | app/models/dashboard.rb | 12 | ||||
| -rw-r--r-- | app/views/dashboards/_dashboard.html.slim | 6 | ||||
| -rw-r--r-- | lib/stif/dashboard.rb | 2 |
3 files changed, 16 insertions, 4 deletions
diff --git a/app/models/dashboard.rb b/app/models/dashboard.rb index 46c621266..bcd92de5a 100644 --- a/app/models/dashboard.rb +++ b/app/models/dashboard.rb @@ -27,4 +27,16 @@ class Dashboard def current_organisation context.send(:current_organisation) end + + def workbench + @workbench ||= current_organisation.workbenches.default + end + + def workgroup + workbench.workgroup + end + + def calendars + workgroup.calendars.where('(organisation_id = ? OR shared = ?)', current_organisation.id, true) + end end diff --git a/app/views/dashboards/_dashboard.html.slim b/app/views/dashboards/_dashboard.html.slim index 7f78934a6..8d0e723a6 100644 --- a/app/views/dashboards/_dashboard.html.slim +++ b/app/views/dashboards/_dashboard.html.slim @@ -22,12 +22,12 @@ .panel.panel-default .panel-heading h3.panel-title.with_actions - = link_to I18n.t("activerecord.models.calendar", count: @dashboard.current_organisation.calendars.size), workgroup_calendars_path(workbench.workgroup) + = link_to I18n.t("activerecord.models.calendar", count: @dashboard.calendars.size), workgroup_calendars_path(workbench.workgroup) div = link_to '', workgroup_calendars_path(workbench.workgroup), class: ' fa fa-chevron-right pull-right' - - if @dashboard.current_organisation.calendars.present? + - if @dashboard.calendars.present? .list-group - - @dashboard.current_organisation.calendars.order("updated_at desc").limit(5).each do |calendar| + - @dashboard.calendars.order("updated_at desc").limit(5).each do |calendar| = link_to calendar.name, workgroup_calendars_path(workbench.workgroup, calendar), class: 'list-group-item' - else .panel-body diff --git a/lib/stif/dashboard.rb b/lib/stif/dashboard.rb index 46c635091..2f5792547 100644 --- a/lib/stif/dashboard.rb +++ b/lib/stif/dashboard.rb @@ -1,7 +1,7 @@ module Stif class Dashboard < ::Dashboard def workbench - @workbench ||= current_organisation.workbenches.find_by(name: "Gestion de l'offre") + @workbench ||= current_organisation.workbenches.default end def workgroup |
