blob: bcd92de5ad75eb91dba3e8d25739060c50d9825e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
#
# The default Dashboard implementation can be customized in an initializer :
#
# Rails.application.config.to_prepare do
# Dashboard.default_class = Custom::Dashboard
# end
#
class Dashboard
include ActiveModel::Conversion
@@default_class = self
mattr_accessor :default_class
def self.model_name
ActiveModel::Name.new Dashboard, Dashboard, "Dashboard"
end
attr_reader :context
def initialize(context)
@context = context
end
def self.create(context)
default_class.new context
end
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
|