diff options
| author | Alban Peignier | 2018-03-05 17:41:30 +0100 |
|---|---|---|
| committer | Alban Peignier | 2018-03-05 21:50:13 +0100 |
| commit | 1733f285e673131f869c60330e25808bb56fc8d7 (patch) | |
| tree | c63e90f91de5a27a0031e80eed8bdef79253d711 /app | |
| parent | 5d655eb93710e2d541e0314837567f0cf7ba88ee (diff) | |
| download | chouette-core-1733f285e673131f869c60330e25808bb56fc8d7.tar.bz2 | |
Use Workbench#calendars in dashboard. Refs #6064
Diffstat (limited to 'app')
| -rw-r--r-- | app/models/dashboard.rb | 11 | ||||
| -rw-r--r-- | app/models/workbench.rb | 4 | ||||
| -rw-r--r-- | app/views/dashboards/_dashboard.html.slim | 6 |
3 files changed, 7 insertions, 14 deletions
diff --git a/app/models/dashboard.rb b/app/models/dashboard.rb index bcd92de5a..e0857dca3 100644 --- a/app/models/dashboard.rb +++ b/app/models/dashboard.rb @@ -28,15 +28,4 @@ class Dashboard 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/models/workbench.rb b/app/models/workbench.rb index eb53af7aa..b6f90c7dc 100644 --- a/app/models/workbench.rb +++ b/app/models/workbench.rb @@ -42,6 +42,10 @@ class Workbench < ActiveRecord::Base end end + def calendars + workgroup.calendars.where('(organisation_id = ? OR shared = ?)', organisation.id, true) + end + def self.default self.last if self.count == 1 where(name: DEFAULT_WORKBENCH_NAME).last diff --git a/app/views/dashboards/_dashboard.html.slim b/app/views/dashboards/_dashboard.html.slim index 8d0e723a6..f93b85cad 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.calendars.size), workgroup_calendars_path(workbench.workgroup) + = link_to I18n.t("activerecord.models.calendar", count: workbench.calendars.size), workgroup_calendars_path(workbench.workgroup) div = link_to '', workgroup_calendars_path(workbench.workgroup), class: ' fa fa-chevron-right pull-right' - - if @dashboard.calendars.present? + - if workbench.calendars.present? .list-group - - @dashboard.calendars.order("updated_at desc").limit(5).each do |calendar| + - workbench.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 |
