Class: PuavoRest::School
- Inherits:
-
LdapModel
show all
- Includes:
- LocalStore
- Defined in:
- resources/schools.rb
Constant Summary
Constant Summary
Constants inherited
from LdapModel
LdapModel::ESCAPES, LdapModel::ESCAPE_RE, LdapModel::KRB_LOCK, LdapModel::PROF
Instance Attribute Summary
Attributes inherited from LdapModel
#ldap_attr_store, #serialize_attrs
Class Method Summary
(collapse)
Instance Method Summary
(collapse)
Methods included from LocalStore
close_connection, included, #local_store, #local_store_del, #local_store_expire, #local_store_get, #local_store_set
Methods inherited from LdapModel
#[], #[]=, _class_store, #add, #add_validation_error, after, all, #as_json, #assert_validation, before, by_attr, by_attr!, by_dn, by_dn!, by_dn_array, by_id, by_id!, by_ldap_attr, by_ldap_attr!, callable_from_instance, #changed?, class_store, clear_setup, computed_attr, connection, #create!, create_connection, create_filter_lambda, #dirty?, dn_bind, #empty?, escape, filter, from_ldap_hash, #get_own, #get_raw, inherited, #initialize, is_dn, is_not_found?, ldap_attrs, ldap_map, #ldap_merge!, ldap_op, #ldap_set, #link, #merge, #new?, #object_model, organisation, organisation?, pretty_attrs_to_ldap, raw_by_dn, raw_filter, sasl_bind, #save!, search, search_filters, #set, settings, settings=, setup, skip_serialize, #to_hash, #to_json, #to_ldap_hash, #transform, #update!, #validate, #validate!, #validate_unique, #write_raw
Constructor Details
This class inherits a constructor from LdapModel
Class Method Details
+ (Object) base_filter
41
42
43
|
# File 'resources/schools.rb', line 41
def self.base_filter
"(objectClass=puavoSchool)"
end
|
+ (Object) ldap_base
37
38
39
|
# File 'resources/schools.rb', line 37
def self.ldap_base
"ou=Groups,#{ organisation["base"] }"
end
|
Instance Method Details
- (Object) allow_guest
83
84
85
86
87
88
89
|
# File 'resources/schools.rb', line 83
def allow_guest
if get_own(:allow_guest).nil?
organisation.allow_guest
else
get_own(:allow_guest)
end
end
|
- (Object) automatic_image_updates
91
92
93
94
95
96
97
|
# File 'resources/schools.rb', line 91
def automatic_image_updates
if get_own(:automatic_image_updates).nil?
organisation.automatic_image_updates
else
get_own(:automatic_image_updates)
end
end
|
- (Object) autopoweroff_attr_with_organisation_fallback(attr)
204
205
206
207
208
|
# File 'resources/schools.rb', line 204
def autopoweroff_attr_with_organisation_fallback(attr)
[ nil, 'default' ].include?( get_own(:autopoweroff_mode) ) \
? organisation.send(attr) \
: get_own(attr)
end
|
- (Object) cache_feeds
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
|
# File 'resources/schools.rb', line 139
def cache_feeds
ical_feed_urls.each do |url|
begin
res = HTTParty.get(url)
rescue Exception => err
$rest_flog.error "Failed to fetch ical",
:url => url,
:source => self.to_hash,
:error => err.message
next
end
local_store.set("feed:#{ url }", res)
local_store.expire("feed:#{ url }", 60 * 60 * 12)
end
end
|
- (Object) devices
67
68
69
|
# File 'resources/schools.rb', line 67
def devices
Device.by_attr(:school_dn, dn, :multi)
end
|
- (Object) ical_feed_urls
131
132
133
134
135
136
137
|
# File 'resources/schools.rb', line 131
def ical_feed_urls
Array(external_feed_sources).select do |feed|
feed["type"] == "ical"
end.map do |feed|
feed["value"]
end
end
|
- (Object) image_series_source_url
107
108
109
110
111
112
113
|
# File 'resources/schools.rb', line 107
def image_series_source_url
if get_own(:image_series_source_url).nil?
organisation.image_series_source_url
else
get_own(:image_series_source_url)
end
end
|
- (Object) keyboard_layout
188
189
190
191
192
193
194
|
# File 'resources/schools.rb', line 188
def keyboard_layout
if get_own(:keyboard_layout).nil?
organisation.keyboard_layout
else
get_own(:keyboard_layout)
end
end
|
- (Object) keyboard_variant
196
197
198
199
200
201
202
|
# File 'resources/schools.rb', line 196
def keyboard_variant
if get_own(:keyboard_variant).nil?
organisation.keyboard_variant
else
get_own(:keyboard_variant)
end
end
|
- (Object) locale
123
124
125
126
127
128
129
|
# File 'resources/schools.rb', line 123
def locale
if get_own(:locale).nil?
organisation.locale
else
get_own(:locale)
end
end
|
- (Object) ltsp_servers
71
72
73
|
# File 'resources/schools.rb', line 71
def ltsp_servers
LtspServer.by_attr(:school_dns, dn, :multi)
end
|
- (Object) messages
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
|
# File 'resources/schools.rb', line 157
def messages
ical_feed_urls.map do |url|
if data = local_store.get("feed:#{ url }")
begin
ICALParser.parse(data).current_events
rescue Exception => err
$rest_flog.error "Failed to parse ical",
:data => data.to_s.slice(0, 100),
:error => err.message
end
end
end.compact.flatten.map do |msg|
msg["to"] = {
"object_model" => object_model,
"name" => name,
"dn" => dn.to_s
}
msg
end
end
|
- (Object) mountpoints=(value)
58
59
60
|
# File 'resources/schools.rb', line 58
def mountpoints=(value)
write_raw(:puavoMountpoint, value.map{|m| m.to_json})
end
|
- (Object) organisation
Cached organisation query
63
64
65
|
# File 'resources/schools.rb', line 63
def organisation
@organisation ||= Organisation.by_dn(self.class.organisation["base"])
end
|
- (Object) personal_device
99
100
101
102
103
104
105
|
# File 'resources/schools.rb', line 99
def personal_device
if get_own(:personal_device).nil?
organisation.personal_device
else
get_own(:personal_device)
end
end
|
- (Object) preferred_image
75
76
77
78
79
80
81
|
# File 'resources/schools.rb', line 75
def preferred_image
if get_own(:preferred_image)
return get_own(:preferred_image).strip
end
return organisation.preferred_image
end
|
- (Object) preferred_language
115
116
117
118
119
120
121
|
# File 'resources/schools.rb', line 115
def preferred_language
if get_own(:preferred_language).nil?
organisation.preferred_language
else
get_own(:preferred_language)
end
end
|
- (Object) printer_queues
50
51
52
|
# File 'resources/schools.rb', line 50
def printer_queues
@printer_queues ||= PrinterQueue.by_dn_array(printer_queue_dns)
end
|
- (Object) puavo_id
46
47
48
|
# File 'resources/schools.rb', line 46
def puavo_id
id
end
|
- (Object) timezone
180
181
182
183
184
185
186
|
# File 'resources/schools.rb', line 180
def timezone
if get_own(:timezone).nil?
organisation.timezone
else
get_own(:timezone)
end
end
|
- (Object) wireless_printer_queues
54
55
56
|
# File 'resources/schools.rb', line 54
def wireless_printer_queues
@wireless_printer_queues ||= PrinterQueue.by_dn_array(wireless_printer_queue_dns)
end
|