osm 0.1.10 → 0.1.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG.md +32 -0
- data/README.md +4 -0
- data/lib/osm/event.rb +140 -34
- data/lib/osm/section.rb +94 -8
- data/spec/osm/event_spec.rb +102 -28
- data/spec/osm/section_spec.rb +68 -7
- data/version.rb +1 -1
- metadata +17 -22
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,35 @@
|
|
1
|
+
## Version 0.0.11
|
2
|
+
|
3
|
+
* Fix "can't convert Hash into String" occuring when some section's config is a Hash not a JSON encoded Hash
|
4
|
+
* Remove num\_scouts attribute from Section (OSM always sets this to 999)
|
5
|
+
* Add My.SCOUT related attributes to Section:
|
6
|
+
* gocardless (Boolean) - does the section use gocardless
|
7
|
+
* myscout\_events\_expires (Date) - when the subscription to Events in My.SCOUT expires
|
8
|
+
* myscout\_badges\_expires (Date) - when the subscription to Badges in My.SCOUT expires
|
9
|
+
* myscout\_programme\_expires (Date) - when the subscription to Badges in My.SCOUT expires
|
10
|
+
* myscout\_events (Boolean) - whether the section uses the Events part of My.SCOUT
|
11
|
+
* myscout\_badges (Boolean) - whether the section uses the Badges part of My.SCOUT
|
12
|
+
* myscout\_programme (Boolean) - whether the section uses the Programme part of My.SCOUT
|
13
|
+
* myscout\_payments (Boolean) - whether the section uses the Payments part of My.SCOUT
|
14
|
+
* myscout\_emails (Hash of Symbol to Boolean) - which email addresses are linked to MyScout for each Member
|
15
|
+
* myscout\_email\_address\_send (String, blank OK) - which email address to send My.SCOUT emails as
|
16
|
+
* myscout\_email\_address\_copy (String, blank OK) - which email address to send copys of My.SCOUT emails to
|
17
|
+
* myscout\_badges\_partial (Boolean) - Wether parents can see partially completed badges
|
18
|
+
* myscout\_programme\_summary (Boolean) - Wether parents can see the summary of programme items
|
19
|
+
* myscout\_event\_reminder\_count (Integer) - How many event reminders to send to parents who haven't responded
|
20
|
+
* myscout\_event\_reminder\_frequency (Integer) - How many days to leave between event reminder emails
|
21
|
+
* myscout\_payment\_reminder\_count (Integer) - How many payment reminders to send to parents who haven't paid yet
|
22
|
+
* myscout\_payment\_reminder\_frequency (Integer) - How many days to leave between payment reminder emails
|
23
|
+
* Add new OSM attributes to Event:
|
24
|
+
* notepad - the notepad shown in OSM
|
25
|
+
* public\_notepad - the notepad shown on My.SCOUT
|
26
|
+
* confirm\_by\_date - the last day that parents can change their child's attendance details
|
27
|
+
* allow\_changes - wether parents can change their child's attendance details
|
28
|
+
* reminders - wether reminder emails are sent
|
29
|
+
* Osm::Event
|
30
|
+
* Mark fields attribute as depricated
|
31
|
+
* Add columns attribute returning an array of column details
|
32
|
+
|
1
33
|
## Version 0.1.10
|
2
34
|
|
3
35
|
* Fix 'undefined variable' when getting an event's attendance without passing a term.
|
data/README.md
CHANGED
@@ -118,6 +118,9 @@ however it should be noted that when the OSM API adds a feature it can be diffic
|
|
118
118
|
|
119
119
|
## Parts of the OSM API currently NOT supported:
|
120
120
|
|
121
|
+
* Event Fields:
|
122
|
+
* Delete [issue 45]
|
123
|
+
* Rename [issue 46]
|
121
124
|
* Badges:
|
122
125
|
* Which requirements each member has met:
|
123
126
|
* Retreive [issue 21]
|
@@ -137,3 +140,4 @@ however it should be noted that when the OSM API adds a feature it can be diffic
|
|
137
140
|
* SMS:
|
138
141
|
* Retreival of delivery reports
|
139
142
|
* Sending a message
|
143
|
+
* MyScout
|
data/lib/osm/event.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
module Osm
|
2
2
|
|
3
3
|
class Event < Osm::Model
|
4
|
+
class Column; end # Ensure the constant exists for the validators
|
4
5
|
|
5
6
|
# @!attribute [rw] id
|
6
7
|
# @return [Fixnum] the id for the event
|
@@ -21,7 +22,20 @@ module Osm
|
|
21
22
|
# @!attribute [rw] archived
|
22
23
|
# @return [Boolean] if the event has been archived
|
23
24
|
# @!attribute [rw] fields
|
25
|
+
# @deprecated use columns instead
|
24
26
|
# @return [Hash] Keys are the field's id, values are the field names
|
27
|
+
# @!attribute [rw] columns
|
28
|
+
# @return [Array<Osm::Event::Column>] the custom columns for the event
|
29
|
+
# @!attribute [rw] notepad
|
30
|
+
# @return [String] notepad for the event
|
31
|
+
# @!attribute [rw] public_notepad
|
32
|
+
# @return [String] public notepad (shown in My.SCOUT) for the event
|
33
|
+
# @!attribute [rw] confirm_by_date
|
34
|
+
# @return [Date] the date parents can no longer add/change their child's details
|
35
|
+
# @!attribute [rw] allow_changes
|
36
|
+
# @return [Boolean] wether parent's can change their child's details
|
37
|
+
# @!attribute [rw] reminders
|
38
|
+
# @return [Boolean] wether email reminders are sent for the event
|
25
39
|
|
26
40
|
attribute :id, :type => Integer
|
27
41
|
attribute :section_id, :type => Integer
|
@@ -32,18 +46,27 @@ module Osm
|
|
32
46
|
attribute :location, :type => String, :default => ''
|
33
47
|
attribute :notes, :type => String, :default => ''
|
34
48
|
attribute :archived, :type => Boolean, :default => false
|
35
|
-
attribute :
|
49
|
+
attribute :columns, :default => []
|
50
|
+
attribute :notepad, :type => String, :default => ''
|
51
|
+
attribute :public_notepad, :type => String, :default => ''
|
52
|
+
attribute :confirm_by_date, :type => Date
|
53
|
+
attribute :allow_changes, :type => Boolean, :default => false
|
54
|
+
attribute :reminders, :type => Boolean, :default => true
|
36
55
|
|
37
|
-
attr_accessible :id, :section_id, :name, :start, :finish, :cost, :location, :notes, :archived,
|
56
|
+
attr_accessible :id, :section_id, :name, :start, :finish, :cost, :location, :notes, :archived,
|
57
|
+
:fields, :columns, :notepad, :public_notepad,
|
58
|
+
:confirm_by_date, :allow_changes, :reminders
|
38
59
|
|
39
60
|
validates_numericality_of :id, :only_integer=>true, :greater_than=>0, :allow_nil => true
|
40
61
|
validates_numericality_of :section_id, :only_integer=>true, :greater_than=>0
|
41
62
|
validates_presence_of :name
|
42
|
-
validates :
|
63
|
+
validates :columns, :array_of => {:item_type => Osm::Event::Column, :item_valid => true}
|
64
|
+
validates_inclusion_of :allow_changes, :in => [true, false]
|
65
|
+
validates_inclusion_of :reminders, :in => [true, false]
|
43
66
|
|
44
67
|
|
45
68
|
# @!method initialize
|
46
|
-
# Initialize a new
|
69
|
+
# Initialize a new Event
|
47
70
|
# @param [Hash] attributes the hash of attributes (see attributes for descriptions, use Symbol of attribute name as the key)
|
48
71
|
|
49
72
|
|
@@ -66,26 +89,9 @@ module Osm
|
|
66
89
|
|
67
90
|
events = Array.new
|
68
91
|
unless data['items'].nil?
|
69
|
-
data['items'].each do |
|
70
|
-
|
71
|
-
|
72
|
-
fields = {}
|
73
|
-
ActiveSupport::JSON.decode(fields_data['config']).each do |field|
|
74
|
-
fields[field['id']] = field['name']
|
75
|
-
end
|
76
|
-
|
77
|
-
event = Osm::Event.new(
|
78
|
-
:id => event_id,
|
79
|
-
:section_id => Osm::to_i_or_nil(item['sectionid']),
|
80
|
-
:name => item['name'],
|
81
|
-
:start => Osm::make_datetime(item['startdate'], item['starttime']),
|
82
|
-
:finish => Osm::make_datetime(item['enddate'], item['endtime']),
|
83
|
-
:cost => item['cost'],
|
84
|
-
:location => item['location'],
|
85
|
-
:notes => item['notes'],
|
86
|
-
:archived => item['archived'].eql?('1'),
|
87
|
-
:fields => fields,
|
88
|
-
)
|
92
|
+
data['items'].map { |i| i['eventid'].to_i }.each do |event_id|
|
93
|
+
event_data = api.perform_query("events.php?action=getEvent§ionid=#{section_id}&eventid=#{event_id}")
|
94
|
+
event = self.new_event_from_data(event_data)
|
89
95
|
events.push event
|
90
96
|
cache_write(api, ['event', event.id], event)
|
91
97
|
end
|
@@ -113,14 +119,8 @@ module Osm
|
|
113
119
|
return cache_read(api, cache_key)
|
114
120
|
end
|
115
121
|
|
116
|
-
|
117
|
-
return
|
118
|
-
|
119
|
-
events.each do |event|
|
120
|
-
return event if event.id == event_id
|
121
|
-
end
|
122
|
-
|
123
|
-
return nil
|
122
|
+
event_data = api.perform_query("events.php?action=getEvent§ionid=#{section_id}&eventid=#{event_id}")
|
123
|
+
return self.new_event_from_data(event_data)
|
124
124
|
end
|
125
125
|
|
126
126
|
|
@@ -141,6 +141,9 @@ module Osm
|
|
141
141
|
'notes' => event.notes,
|
142
142
|
'starttime' => event.start? ? event.start.strftime(Osm::OSM_TIME_FORMAT) : '',
|
143
143
|
'endtime' => event.finish? ? event.finish.strftime(Osm::OSM_TIME_FORMAT) : '',
|
144
|
+
'confdate' => event.confirm_by_date? ? event.confirm_by_date.strftime(Osm::OSM_DATE_FORMAT) : '',
|
145
|
+
'allowChanges' => event.allow_changes ? 'true' : 'false',
|
146
|
+
'disablereminders' => !event.reminders ? 'true' : 'false',
|
144
147
|
})
|
145
148
|
|
146
149
|
# The cached events for the section will be out of date - remove them
|
@@ -171,6 +174,17 @@ module Osm
|
|
171
174
|
'notes' => notes,
|
172
175
|
'starttime' => start? ? start.strftime(Osm::OSM_TIME_FORMAT) : '',
|
173
176
|
'endtime' => finish? ? finish.strftime(Osm::OSM_TIME_FORMAT) : '',
|
177
|
+
'confdate' => confirm_by_date? ? confirm_by_date.strftime(Osm::OSM_DATE_FORMAT) : '',
|
178
|
+
'allowChanges' => allow_changes ? 'true' : 'false',
|
179
|
+
'disablereminders' => !reminders ? 'true' : 'false',
|
180
|
+
})
|
181
|
+
api.perform_query("events.php?action=saveNotepad§ionid=#{section_id}", {
|
182
|
+
'eventid' => id,
|
183
|
+
'notepad' => notepad,
|
184
|
+
})
|
185
|
+
api.perform_query("events.php?action=saveNotepad§ionid=#{section_id}", {
|
186
|
+
'eventid' => id,
|
187
|
+
'pnnotepad' => public_notepad,
|
174
188
|
})
|
175
189
|
|
176
190
|
# The cached events for the section will be out of date - remove them
|
@@ -236,16 +250,44 @@ module Osm
|
|
236
250
|
end
|
237
251
|
|
238
252
|
|
253
|
+
# Add a column to the event in OSM
|
254
|
+
# @param [Osm::Api] api The api to use to make the request
|
255
|
+
# @param [String] label the label for the field in OSM
|
256
|
+
# @param [String] name the label for the field in My.SCOUT (if this is blank then parents can't edit it)
|
257
|
+
# @return [Boolean] wether the update succedded
|
258
|
+
def add_column(api, name, label='')
|
259
|
+
raise ArgumentIsInvalid, 'name is invalid' if name.blank?
|
260
|
+
raise Forbidden, 'you do not have permission to write to events for this section' unless get_user_permission(api, section_id, :events).include?(:write)
|
261
|
+
|
262
|
+
data = api.perform_query("events.php?action=addColumn§ionid=#{section_id}&eventid=#{id}", {
|
263
|
+
'columnName' => name,
|
264
|
+
'parentLabel' => label
|
265
|
+
})
|
266
|
+
|
267
|
+
# The cached events for the section will be out of date - remove them
|
268
|
+
cache_delete(api, ['events', section_id])
|
269
|
+
cache_delete(api, ['event', id])
|
270
|
+
cache_delete(api, ['event_attendance', id])
|
271
|
+
|
272
|
+
self.columns = self.class.new_event_from_data(data).columns
|
273
|
+
|
274
|
+
return data.is_a?(Hash) && (data['eventid'].to_i == id)
|
275
|
+
end
|
276
|
+
|
239
277
|
# Add a field in OSM
|
278
|
+
# @deprecated use add_column instead
|
240
279
|
# @param [Osm::Api] api The api to use to make the request
|
241
280
|
# @param [String] field_label the label for the field to add
|
242
281
|
# @return [Boolean] wether the update succedded
|
282
|
+
# TODO - Remove this method when upping the version
|
243
283
|
def add_field(api, label)
|
284
|
+
warn "[DEPRECATION OF METHOD] this method is being depreiated, use add_column instead"
|
244
285
|
raise ArgumentIsInvalid, 'label is invalid' if label.blank?
|
245
286
|
raise Forbidden, 'you do not have permission to write to events for this section' unless get_user_permission(api, section_id, :events).include?(:write)
|
246
287
|
|
247
288
|
data = api.perform_query("events.php?action=addColumn§ionid=#{section_id}&eventid=#{id}", {
|
248
|
-
'columnName' => label
|
289
|
+
'columnName' => label,
|
290
|
+
'parentLabel' => ''
|
249
291
|
})
|
250
292
|
|
251
293
|
# The cached events for the section will be out of date - remove them
|
@@ -257,6 +299,70 @@ module Osm
|
|
257
299
|
end
|
258
300
|
|
259
301
|
|
302
|
+
# TODO - Remove this attribute when upping the version
|
303
|
+
def fields
|
304
|
+
warn "[DEPRECATION OF ATTRIBUTE] this attribute is being depreiated, in favor of returning an array of Field objects."
|
305
|
+
return columns.inject({}){ |h,(c)| h[c.id] = c.name; h}
|
306
|
+
end
|
307
|
+
def fields=(value)
|
308
|
+
raise "[DEPRECATION OF ATTRIBUTE] this attribute is being depreiated, in favor of returning an array of Field objects."
|
309
|
+
end
|
310
|
+
|
311
|
+
|
312
|
+
private
|
313
|
+
def self.new_event_from_data(event_data)
|
314
|
+
columns = []
|
315
|
+
ActiveSupport::JSON.decode(event_data['config']).each do |field|
|
316
|
+
columns.push Column.new(:id => field['id'], :name => field['name'], :parent_label => field['pL'])
|
317
|
+
end
|
318
|
+
|
319
|
+
event = Osm::Event.new(
|
320
|
+
:id => Osm::to_i_or_nil(event_data['eventid']),
|
321
|
+
:section_id => Osm::to_i_or_nil(event_data['sectionid']),
|
322
|
+
:name => event_data['name'],
|
323
|
+
:start => Osm::make_datetime(event_data['startdate'], event_data['starttime']),
|
324
|
+
:finish => Osm::make_datetime(event_data['enddate'], event_data['endtime']),
|
325
|
+
:cost => event_data['cost'],
|
326
|
+
:location => event_data['location'],
|
327
|
+
:notes => event_data['notes'],
|
328
|
+
:archived => event_data['archived'].eql?('1'),
|
329
|
+
:columns => columns,
|
330
|
+
:notepad => event_data['notepad'],
|
331
|
+
:public_notepad => event_data['publicnotes'],
|
332
|
+
:confirm_by_date => Osm::parse_date(event_data['confdate']),
|
333
|
+
:allow_changes => event_data['allowchanges'].eql?('1'),
|
334
|
+
:reminders => !event_data['disablereminders'].eql?('1'),
|
335
|
+
)
|
336
|
+
end
|
337
|
+
|
338
|
+
|
339
|
+
class Column
|
340
|
+
include ::ActiveAttr::MassAssignmentSecurity
|
341
|
+
include ::ActiveAttr::Model
|
342
|
+
|
343
|
+
# @!attribute [rw] id
|
344
|
+
# @return [String] OSM id for the column
|
345
|
+
# @!attribute [rw] name
|
346
|
+
# @return [String] name for the column (displayed in OSM)
|
347
|
+
# @!attribute [rw] parent_label
|
348
|
+
# @return [String] label to display in My.SCOUT ("" prevents display in My.SCOUT)
|
349
|
+
|
350
|
+
attribute :id, :type => String
|
351
|
+
attribute :name, :type => String
|
352
|
+
attribute :parent_label, :type => String, :default => ''
|
353
|
+
|
354
|
+
attr_accessible :id, :name, :parent_label
|
355
|
+
|
356
|
+
validates_presence_of :id
|
357
|
+
validates_presence_of :name
|
358
|
+
|
359
|
+
|
360
|
+
# @!method initialize
|
361
|
+
# Initialize a new Column
|
362
|
+
# @param [Hash] attributes the hash of attributes (see attributes for descriptions, use Symbol of attribute name as the key)
|
363
|
+
|
364
|
+
end # class Column
|
365
|
+
|
260
366
|
|
261
367
|
class Attendance
|
262
368
|
include ::ActiveAttr::MassAssignmentSecurity
|
@@ -289,7 +395,7 @@ module Osm
|
|
289
395
|
|
290
396
|
|
291
397
|
# @!method initialize
|
292
|
-
# Initialize a new
|
398
|
+
# Initialize a new Attendance
|
293
399
|
# @param [Hash] attributes the hash of attributes (see attributes for descriptions, use Symbol of attribute name as the key)
|
294
400
|
|
295
401
|
|
data/lib/osm/section.rb
CHANGED
@@ -17,8 +17,6 @@ module Osm
|
|
17
17
|
# @return [Date] when the section's subscription to OSM expires
|
18
18
|
# @!attribute [rw] type
|
19
19
|
# @return [Symbol] the section type (:beavers, :cubs, :scouts, :exporers, :adults, :waiting, :unknown)
|
20
|
-
# @!attribute [rw] num_scouts
|
21
|
-
# @return [Fixnum] how many members the section has
|
22
20
|
# @!attribute [rw] column_names
|
23
21
|
# @return [Hash] custom names to use for the data columns
|
24
22
|
# @!attribute [rw] fields
|
@@ -29,6 +27,40 @@ module Osm
|
|
29
27
|
# @return [Hash] which columns are shown in the OSM mobile app
|
30
28
|
# @!attribute [rw] flexi_records
|
31
29
|
# @return [Array<FlexiRecord>] list of the extra records the section has
|
30
|
+
# @!attribute [rw] gocardless
|
31
|
+
# @return [Boolean] does the section use gocardless
|
32
|
+
# @!attribute [rw] myscout_events_expires
|
33
|
+
# @return [Date] when the subscription to Events in My.SCOUT expires
|
34
|
+
# @!attribute [rw] myscout_badges_expires
|
35
|
+
# @return [Date] when the subscription to Badges in My.SCOUT expires
|
36
|
+
# @!attribute [rw] myscout_programme_expires
|
37
|
+
# @return [Date] when the subscription to Badges in My.SCOUT expires
|
38
|
+
# @!attribute [rw] myscout_events
|
39
|
+
# @return [Boolean] whether the section uses the Events part of My.SCOUT
|
40
|
+
# @!attribute [rw] myscout_badges
|
41
|
+
# @return [Boolean] whether the section uses the Badges part of My.SCOUT
|
42
|
+
# @!attribute [rw] myscout_programme
|
43
|
+
# @return [Boolean] whether the section uses the Programme part of My.SCOUT
|
44
|
+
# @!attribute [rw] myscout_payments
|
45
|
+
# @return [Boolean] whether the section uses the Payments part of My.SCOUT
|
46
|
+
# @!attribute [rw] myscout_emails
|
47
|
+
# @return [Hash of Symbol to Boolean] which email addresses are linked to MyScout for each Member
|
48
|
+
# @!attribute [rw] myscout_email_address_send
|
49
|
+
# @return [String] which email address to send My.SCOUT emails as
|
50
|
+
# @!attribute [rw] myscout_email_address_copy
|
51
|
+
# @return [String] which email address to send copys of My.SCOUT emails to
|
52
|
+
# @!attribute [rw] myscout_badges_partial
|
53
|
+
# @return [Boolean] Wether parents can see partially completed badges
|
54
|
+
# @!attribute [rw] myscout_programme_summary
|
55
|
+
# @return [Boolean] Wether parents can see summary of programme items
|
56
|
+
# @!attribute [rw] myscout_event_reminder_count
|
57
|
+
# @return [Fixnum] How many event reminders to send to parents who haven't responded
|
58
|
+
# @!attribute [rw] myscout_event_reminder_frequency
|
59
|
+
# @return [Fixnum] How many days to leave between event reminder emails
|
60
|
+
# @!attribute [rw] myscout_payment_reminder_count
|
61
|
+
# @return [Fixnum] How many payment reminders to send to parents who haven't paid yet
|
62
|
+
# @!attribute [rw] myscout_payment_reminder_frequency
|
63
|
+
# @return [Fixnum] How many days to leave between payment reminder emails
|
32
64
|
|
33
65
|
attribute :id, :type => Integer
|
34
66
|
attribute :name, :type => String
|
@@ -37,19 +69,46 @@ module Osm
|
|
37
69
|
attribute :subscription_level, :default => :unknown
|
38
70
|
attribute :subscription_expires, :type => Date
|
39
71
|
attribute :type, :default => :unknown
|
40
|
-
attribute :num_scouts, :type => Integer
|
41
72
|
attribute :column_names, :default => {}
|
42
73
|
attribute :fields, :default => {}
|
43
74
|
attribute :intouch_fields, :default => {}
|
44
75
|
attribute :mobile_fields, :default => {}
|
45
76
|
attribute :flexi_records, :default => []
|
46
|
-
|
47
|
-
|
48
|
-
|
77
|
+
attribute :gocardless, :type => Boolean
|
78
|
+
attribute :myscout_events_expires, :type => Date
|
79
|
+
attribute :myscout_badges_expires, :type => Date
|
80
|
+
attribute :myscout_programme_expires, :type => Date
|
81
|
+
attribute :myscout_events, :type => Boolean
|
82
|
+
attribute :myscout_badges, :type => Boolean
|
83
|
+
attribute :myscout_programme, :type => Boolean
|
84
|
+
attribute :myscout_payments, :type => Boolean
|
85
|
+
attribute :myscout_emails, :default => {}# (Hash of Symbol to Boolean)
|
86
|
+
attribute :myscout_email_address_send, :type => String#, blank OK)
|
87
|
+
attribute :myscout_email_address_copy, :type => String#, blank OK)
|
88
|
+
attribute :myscout_badges_partial, :type => Boolean
|
89
|
+
attribute :myscout_programme_summary, :type => Boolean
|
90
|
+
attribute :myscout_event_reminder_count, :type => Integer
|
91
|
+
attribute :myscout_event_reminder_frequency, :type => Integer
|
92
|
+
attribute :myscout_payment_reminder_count, :type => Integer
|
93
|
+
attribute :myscout_payment_reminder_frequency, :type => Integer
|
94
|
+
|
95
|
+
attr_accessible :id, :name, :group_id, :group_name, :subscription_level, :subscription_expires,
|
96
|
+
:type, :column_names, :fields, :intouch_fields, :mobile_fields, :flexi_records,
|
97
|
+
:gocardless, :myscout_events_expires, :myscout_badges_expires,
|
98
|
+
:myscout_programme_expires, :myscout_events, :myscout_badges,
|
99
|
+
:myscout_programme, :myscout_payments, :myscout_emails,
|
100
|
+
:myscout_email_address_send, :myscout_email_address_copy,
|
101
|
+
:myscout_badges_partial, :myscout_programme_summary,
|
102
|
+
:myscout_event_reminder_count, :myscout_event_reminder_frequency,
|
103
|
+
:myscout_payment_reminder_count, :myscout_payment_reminder_frequency
|
49
104
|
|
50
105
|
validates_numericality_of :id, :only_integer=>true, :greater_than=>0, :allow_nil => true
|
51
106
|
validates_numericality_of :group_id, :only_integer=>true, :greater_than=>0, :allow_nil => true
|
52
|
-
validates_numericality_of :
|
107
|
+
validates_numericality_of :myscout_event_reminder_count, :only_integer=>true, :greater_than_or_equal_to=>-1
|
108
|
+
validates_numericality_of :myscout_event_reminder_frequency, :only_integer=>true, :greater_than_or_equal_to=>-1
|
109
|
+
validates_numericality_of :myscout_payment_reminder_count, :only_integer=>true, :greater_than_or_equal_to=>-1
|
110
|
+
validates_numericality_of :myscout_payment_reminder_frequency, :only_integer=>true, :greater_than_or_equal_to=>-1
|
111
|
+
|
53
112
|
validates_presence_of :name
|
54
113
|
validates_presence_of :group_name
|
55
114
|
validates_presence_of :subscription_level
|
@@ -62,11 +121,19 @@ module Osm
|
|
62
121
|
validates_presence_of :flexi_records, :unless => Proc.new { |a| a.flexi_records == [] }
|
63
122
|
|
64
123
|
validates_inclusion_of :subscription_level, :in => [:bronze, :silver, :gold, :unknown], :message => 'is not a valid level'
|
124
|
+
validates_inclusion_of :gocardless, :in => [true, false]
|
125
|
+
validates_inclusion_of :myscout_events, :in => [true, false]
|
126
|
+
validates_inclusion_of :myscout_badges, :in => [true, false]
|
127
|
+
validates_inclusion_of :myscout_programme, :in => [true, false]
|
128
|
+
validates_inclusion_of :myscout_payments, :in => [true, false]
|
129
|
+
validates_inclusion_of :myscout_badges_partial, :in => [true, false]
|
130
|
+
validates_inclusion_of :myscout_programme_summary, :in => [true, false]
|
65
131
|
|
66
132
|
validates :column_names, :hash => {:key_type => Symbol, :value_type => String}
|
67
133
|
validates :fields, :hash => {:key_type => Symbol, :value_in => [true, false]}
|
68
134
|
validates :intouch_fields, :hash => {:key_type => Symbol, :value_in => [true, false]}
|
69
135
|
validates :mobile_fields, :hash => {:key_type => Symbol, :value_in => [true, false]}
|
136
|
+
validates :myscout_emails, :hash => {:key_in => [:email1, :email2, :email3, :email4], :value_in => [true, false]}
|
70
137
|
|
71
138
|
|
72
139
|
# @!method initialize
|
@@ -96,7 +163,9 @@ module Osm
|
|
96
163
|
permissions = Hash.new
|
97
164
|
data.each do |role_data|
|
98
165
|
unless role_data['section'].eql?('discount') # It's not an actual section
|
99
|
-
section_data = ActiveSupport::JSON.decode(role_data['sectionConfig'])
|
166
|
+
section_data = role_data['sectionConfig'].is_a?(String) ? ActiveSupport::JSON.decode(role_data['sectionConfig']) : role_data['sectionConfig']
|
167
|
+
myscout_data = section_data['portal'] || {}
|
168
|
+
section_data['portalExpires'] ||= {}
|
100
169
|
|
101
170
|
# Make sense of flexi records
|
102
171
|
fr_data = []
|
@@ -127,6 +196,23 @@ module Osm
|
|
127
196
|
:flexi_records => flexi_records.sort,
|
128
197
|
:group_id => role_data['groupid'],
|
129
198
|
:group_name => role_data['groupname'],
|
199
|
+
:gocardless => (section_data['gocardless'] || 'false').downcase.eql?('true'),
|
200
|
+
:myscout_events_expires => Osm::parse_date(section_data['portalExpires']['events']),
|
201
|
+
:myscout_badges_expires => Osm::parse_date(section_data['portalExpires']['badges']),
|
202
|
+
:myscout_programme_expires => Osm::parse_date(section_data['portalExpires']['programme']),
|
203
|
+
:myscout_events => myscout_data['events'] == 1,
|
204
|
+
:myscout_badges => myscout_data['badges'] == 1,
|
205
|
+
:myscout_programme => myscout_data['programme'] == 1,
|
206
|
+
:myscout_payments => myscout_data['payments'] == 1,
|
207
|
+
:myscout_emails => (myscout_data['emails'] || {}).inject({}) { |n,(k,v)| n[k.to_sym] = v.eql?('true'); n},
|
208
|
+
:myscout_email_address_send => myscout_data['emailAddress'],
|
209
|
+
:myscout_email_address_copy => myscout_data['emailAddressCopy'],
|
210
|
+
:myscout_badges_partial => myscout_data['badgesPartial'] == 1,
|
211
|
+
:myscout_programme_summary => myscout_data['programmeSummary'] == 1,
|
212
|
+
:myscout_event_reminder_count => myscout_data['eventRemindCount'].to_i,
|
213
|
+
:myscout_event_reminder_frequency => myscout_data['eventRemindFrequency'].to_i,
|
214
|
+
:myscout_payment_reminder_count => myscout_data['paymentRemindCount'].to_i,
|
215
|
+
:myscout_payment_reminder_frequency => myscout_data['paymentRemindFrequency'].to_i,
|
130
216
|
)
|
131
217
|
|
132
218
|
result.push section
|
data/spec/osm/event_spec.rb
CHANGED
@@ -15,7 +15,12 @@ describe "Event" do
|
|
15
15
|
:location => 'Somewhere',
|
16
16
|
:notes => 'None',
|
17
17
|
:archived => '0',
|
18
|
-
:
|
18
|
+
:columns => [],
|
19
|
+
:notepad => 'notepad',
|
20
|
+
:public_notepad => 'public notepad',
|
21
|
+
:confirm_by_date => Date.new(2002, 1, 2),
|
22
|
+
:allow_changes => true,
|
23
|
+
:reminders => false,
|
19
24
|
}
|
20
25
|
event = Osm::Event.new(data)
|
21
26
|
|
@@ -28,7 +33,12 @@ describe "Event" do
|
|
28
33
|
event.location.should == 'Somewhere'
|
29
34
|
event.notes.should == 'None'
|
30
35
|
event.archived.should be_false
|
31
|
-
event.
|
36
|
+
event.columns.should == []
|
37
|
+
event.notepad.should == 'notepad'
|
38
|
+
event.public_notepad.should == 'public notepad'
|
39
|
+
event.confirm_by_date.should == Date.new(2002, 1, 2)
|
40
|
+
event.allow_changes.should == true
|
41
|
+
event.reminders.should == false
|
32
42
|
event.valid?.should be_true
|
33
43
|
end
|
34
44
|
|
@@ -37,8 +47,8 @@ describe "Event" do
|
|
37
47
|
:member_id => 1,
|
38
48
|
:grouping_id => 2,
|
39
49
|
:row => 3,
|
40
|
-
:
|
41
|
-
:event => Osm::Event.new(:id => 1, :section_id => 1, :name => 'Name', :
|
50
|
+
:columns => [],
|
51
|
+
:event => Osm::Event.new(:id => 1, :section_id => 1, :name => 'Name', :columns => [])
|
42
52
|
}
|
43
53
|
|
44
54
|
ea = Osm::Event::Attendance.new(data)
|
@@ -68,16 +78,38 @@ describe "Event" do
|
|
68
78
|
'notes' => 'Notes',
|
69
79
|
'sectionid' => 1,
|
70
80
|
'googlecalendar' => nil,
|
71
|
-
'archived' => '0'
|
81
|
+
'archived' => '0',
|
82
|
+
'confdate' => nil,
|
83
|
+
'allowchanges' => '1',
|
84
|
+
'disablereminders' => '1'
|
72
85
|
}]
|
73
86
|
}
|
74
87
|
|
75
|
-
|
76
|
-
'
|
88
|
+
event_body = {
|
89
|
+
'eventid' => '2',
|
90
|
+
'name' => 'An Event',
|
91
|
+
'startdate' => '2001-01-02',
|
92
|
+
'enddate' => '2001-02-05',
|
93
|
+
'starttime' => '00:00:00',
|
94
|
+
'endtime' => '12:00:00',
|
95
|
+
'cost' => '0.00',
|
96
|
+
'location' => 'Somewhere',
|
97
|
+
'notes' => 'Notes',
|
98
|
+
'notepad' => 'notepad',
|
99
|
+
'publicnotes' => 'public notepad',
|
100
|
+
'config' => '[{"id":"f_1","name":"Name","pL":"Label"}]',
|
101
|
+
'sectionid' => '1',
|
102
|
+
'googlecalendar' => nil,
|
103
|
+
'archived' => '0',
|
104
|
+
'confdate' => '2002-01-02',
|
105
|
+
'allowchanges' => '1',
|
106
|
+
'disablereminders' => '1',
|
107
|
+
'pnnotepad' => '',
|
108
|
+
'structure' => []
|
77
109
|
}
|
78
110
|
|
79
111
|
FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/events.php?action=getEvents§ionid=1&showArchived=true", :body => events_body.to_json)
|
80
|
-
FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/events.php?action=getEvent§ionid=1&eventid=2", :body =>
|
112
|
+
FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/events.php?action=getEvent§ionid=1&eventid=2", :body => event_body.to_json)
|
81
113
|
|
82
114
|
Osm::Model.stub(:get_user_permissions) { {:events => [:read, :write]} }
|
83
115
|
end
|
@@ -89,12 +121,20 @@ describe "Event" do
|
|
89
121
|
event.id.should == 2
|
90
122
|
event.section_id.should == 1
|
91
123
|
event.name.should == 'An Event'
|
92
|
-
event.start.should == Date.new(2001,
|
124
|
+
event.start.should == Date.new(2001, 1, 2)
|
93
125
|
event.finish.should == DateTime.new(2001, 2, 5, 12, 0, 0)
|
94
126
|
event.cost.should == '0.00'
|
95
127
|
event.location.should == 'Somewhere'
|
96
128
|
event.notes.should == 'Notes'
|
97
129
|
event.archived.should be_false
|
130
|
+
event.notepad.should == 'notepad'
|
131
|
+
event.public_notepad.should == 'public notepad'
|
132
|
+
event.confirm_by_date.should == Date.new(2002, 1, 2)
|
133
|
+
event.allow_changes.should == true
|
134
|
+
event.reminders.should == false
|
135
|
+
event.columns[0].id.should == 'f_1'
|
136
|
+
event.columns[0].name.should == 'Name'
|
137
|
+
event.columns[0].parent_label.should == 'Label'
|
98
138
|
event.valid?.should be_true
|
99
139
|
end
|
100
140
|
|
@@ -132,10 +172,15 @@ describe "Event" do
|
|
132
172
|
}
|
133
173
|
|
134
174
|
FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/events.php?action=getEvents§ionid=1&showArchived=true", :body => body.to_json)
|
135
|
-
FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/events.php?action=getEvent§ionid=1&eventid=1", :body => {'config' => '[]'}.to_json)
|
136
|
-
FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/events.php?action=getEvent§ionid=1&eventid=2", :body => {'config' => '[]'}.to_json)
|
137
|
-
|
138
|
-
Osm::Event.get_for_section(@api, 1
|
175
|
+
FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/events.php?action=getEvent§ionid=1&eventid=1", :body => {'config' => '[]', 'archived' => '0', 'eventid' => '1'}.to_json)
|
176
|
+
FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/events.php?action=getEvent§ionid=1&eventid=2", :body => {'config' => '[]', 'archived' => '1', 'eventid' => '2'}.to_json)
|
177
|
+
|
178
|
+
events = Osm::Event.get_for_section(@api, 1)
|
179
|
+
all_events = Osm::Event.get_for_section(@api, 1, {:include_archived => true})
|
180
|
+
|
181
|
+
events.size.should == 1
|
182
|
+
events[0].id == 1
|
183
|
+
all_events.size.should == 2
|
139
184
|
end
|
140
185
|
|
141
186
|
it "Get event" do
|
@@ -159,7 +204,10 @@ describe "Event" do
|
|
159
204
|
'endtime' => '04:05:06',
|
160
205
|
'cost' => '1.23',
|
161
206
|
'location' => 'Somewhere',
|
162
|
-
'notes' => 'none'
|
207
|
+
'notes' => 'none',
|
208
|
+
'confdate' => '2000-01-01',
|
209
|
+
'allowChanges' => 'true',
|
210
|
+
'disablereminders' => 'false',
|
163
211
|
}
|
164
212
|
|
165
213
|
Osm::Event.stub(:get_for_section) { [] }
|
@@ -168,12 +216,17 @@ describe "Event" do
|
|
168
216
|
event = Osm::Event.create(@api, {
|
169
217
|
:section_id => 1,
|
170
218
|
:name => 'Test event',
|
171
|
-
:start => DateTime.new(2000,
|
172
|
-
:finish => DateTime.new(2001,
|
219
|
+
:start => DateTime.new(2000, 1, 2, 3, 4, 5),
|
220
|
+
:finish => DateTime.new(2001, 2, 3, 4, 5, 6),
|
173
221
|
:cost => '1.23',
|
174
222
|
:location => 'Somewhere',
|
175
223
|
:notes => 'none',
|
176
|
-
:
|
224
|
+
:columns => [],
|
225
|
+
:notepad => '',
|
226
|
+
:public_notepad => '',
|
227
|
+
:confirm_by_date => Date.new(2000, 1, 1),
|
228
|
+
:allow_changes => true,
|
229
|
+
:reminders => true,
|
177
230
|
})
|
178
231
|
event.should_not be_nil
|
179
232
|
event.id.should == 2
|
@@ -191,7 +244,12 @@ describe "Event" do
|
|
191
244
|
:cost => '1.23',
|
192
245
|
:location => 'Somewhere',
|
193
246
|
:notes => 'none',
|
194
|
-
:
|
247
|
+
:columns => [],
|
248
|
+
:notepad => '',
|
249
|
+
:public_notepad => '',
|
250
|
+
:confirm_by_date => nil,
|
251
|
+
:allow_changes => true,
|
252
|
+
:reminders => true,
|
195
253
|
})
|
196
254
|
event.should be_nil
|
197
255
|
end
|
@@ -212,10 +270,15 @@ describe "Event" do
|
|
212
270
|
'cost' => '1.23',
|
213
271
|
'location' => 'Somewhere',
|
214
272
|
'notes' => 'none',
|
215
|
-
'eventid' => 2
|
273
|
+
'eventid' => 2,
|
274
|
+
'confdate' => '',
|
275
|
+
'allowChanges' => 'true',
|
276
|
+
'disablereminders' => 'false',
|
216
277
|
}
|
217
278
|
|
218
279
|
HTTParty.should_receive(:post).with(url, {:body => post_data}) { DummyHttpResult.new(:response=>{:code=>'200', :body=>'{"id":2}'}) }
|
280
|
+
HTTParty.should_receive(:post).with('https://www.onlinescoutmanager.co.uk/events.php?action=saveNotepad§ionid=1', {:body=>{"eventid"=>2, "notepad"=>"notepad", "userid"=>"user_id", "secret"=>"secret", "apiid"=>"1", "token"=>"API TOKEN"}}) { DummyHttpResult.new(:response=>{:code=>'200', :body=>'{}'}) }
|
281
|
+
HTTParty.should_receive(:post).with('https://www.onlinescoutmanager.co.uk/events.php?action=saveNotepad§ionid=1', {:body=>{"eventid"=>2, "pnnotepad"=>"public notepad", "userid"=>"user_id", "secret"=>"secret", "apiid"=>"1", "token"=>"API TOKEN"}}) { DummyHttpResult.new(:response=>{:code=>'200', :body=>'{}'}) }
|
219
282
|
|
220
283
|
event = Osm::Event.new(
|
221
284
|
:section_id => 1,
|
@@ -225,13 +288,18 @@ describe "Event" do
|
|
225
288
|
:cost => '1.23',
|
226
289
|
:location => 'Somewhere',
|
227
290
|
:notes => 'none',
|
228
|
-
:id => 2
|
291
|
+
:id => 2,
|
292
|
+
:confirm_by_date => nil,
|
293
|
+
:allow_changes => true,
|
294
|
+
:reminders => true,
|
295
|
+
:notepad => 'notepad',
|
296
|
+
:public_notepad => 'public notepad',
|
229
297
|
)
|
230
298
|
event.update(@api).should be_true
|
231
299
|
end
|
232
300
|
|
233
301
|
it "Update (failed)" do
|
234
|
-
HTTParty.should_receive(:post) { DummyHttpResult.new(:response=>{:code=>'200', :body=>'{}'}) }
|
302
|
+
HTTParty.should_receive(:post).exactly(3).times { DummyHttpResult.new(:response=>{:code=>'200', :body=>'{}'}) }
|
235
303
|
|
236
304
|
event = Osm::Event.new(
|
237
305
|
:section_id => 1,
|
@@ -347,28 +415,34 @@ describe "Event" do
|
|
347
415
|
end
|
348
416
|
|
349
417
|
|
350
|
-
it "Add
|
418
|
+
it "Add column (succeded)" do
|
351
419
|
url = 'https://www.onlinescoutmanager.co.uk/events.php?action=addColumn§ionid=1&eventid=2'
|
352
420
|
post_data = {
|
353
421
|
'apiid' => @CONFIGURATION[:api][:osm][:id],
|
354
422
|
'token' => @CONFIGURATION[:api][:osm][:token],
|
355
423
|
'userid' => 'user_id',
|
356
424
|
'secret' => 'secret',
|
357
|
-
'columnName' => 'Test
|
425
|
+
'columnName' => 'Test name',
|
426
|
+
'parentLabel' => 'Test label',
|
358
427
|
}
|
359
|
-
|
428
|
+
body = {
|
429
|
+
'eventid' => '2',
|
430
|
+
'config' => '[{"id":"f_1","name":"Test name","pL":"Test label"}]'
|
431
|
+
}
|
432
|
+
HTTParty.should_receive(:post).with(url, {:body => post_data}) { DummyHttpResult.new(:response=>{:code=>'200', :body=>body.to_json}) }
|
360
433
|
|
361
434
|
event = Osm::Event.new(:id => 2, :section_id => 1)
|
362
435
|
event.should_not be_nil
|
363
|
-
event.
|
436
|
+
event.add_column(@api, 'Test name', 'Test label').should be_true
|
437
|
+
event.columns.should == [Osm::Event::Column.new(:id=>'f_1', :name=>'Test name', :parent_label=>'Test label')]
|
364
438
|
end
|
365
439
|
|
366
|
-
it "Add
|
367
|
-
HTTParty.should_receive(:post) { DummyHttpResult.new(:response=>{:code=>'200', :body=>'{}'}) }
|
440
|
+
it "Add column (failed)" do
|
441
|
+
HTTParty.should_receive(:post) { DummyHttpResult.new(:response=>{:code=>'200', :body=>'{"config":"[]"}'}) }
|
368
442
|
|
369
443
|
event = Osm::Event.new(:id => 2, :section_id => 1)
|
370
444
|
event.should_not be_nil
|
371
|
-
event.
|
445
|
+
event.add_column(@api, 'Test name', 'Test label').should be_false
|
372
446
|
end
|
373
447
|
|
374
448
|
end
|
data/spec/osm/section_spec.rb
CHANGED
@@ -12,7 +12,6 @@ describe "Section" do
|
|
12
12
|
:subscription_level => :silver,
|
13
13
|
:subscription_expires => (Date.today + 60).strftime('%Y-%m-%d'),
|
14
14
|
:type => :cubs,
|
15
|
-
:num_scouts => 10,
|
16
15
|
:wizard => false,
|
17
16
|
:column_names => {:column_names => 'names'},
|
18
17
|
:fields => {:fields => true},
|
@@ -20,7 +19,24 @@ describe "Section" do
|
|
20
19
|
:mobile_fields => {:mobile_fields => true},
|
21
20
|
:flexi_records => [],
|
22
21
|
:group_id => 3,
|
23
|
-
:group_name => '3rd Somewhere'
|
22
|
+
:group_name => '3rd Somewhere',
|
23
|
+
:gocardless => true,
|
24
|
+
:myscout_events_expires => (Date.today + 61).strftime('%Y-%m-%d'),
|
25
|
+
:myscout_badges_expires => (Date.today + 62).strftime('%Y-%m-%d'),
|
26
|
+
:myscout_programme_expires => (Date.today + 63).strftime('%Y-%m-%d'),
|
27
|
+
:myscout_events => true,
|
28
|
+
:myscout_badges => true,
|
29
|
+
:myscout_programme => true,
|
30
|
+
:myscout_payments => true,
|
31
|
+
:myscout_emails => {:email1 => true, :email2 => false},
|
32
|
+
:myscout_email_address_send => 'send_from@example.com',
|
33
|
+
:myscout_email_address_copy => '',
|
34
|
+
:myscout_badges_partial => true,
|
35
|
+
:myscout_programme_summary => true,
|
36
|
+
:myscout_event_reminder_count => 4,
|
37
|
+
:myscout_event_reminder_frequency => 5,
|
38
|
+
:myscout_payment_reminder_count => 6,
|
39
|
+
:myscout_payment_reminder_frequency => 7
|
24
40
|
}
|
25
41
|
end
|
26
42
|
|
@@ -33,7 +49,6 @@ describe "Section" do
|
|
33
49
|
section.subscription_level.should == :silver
|
34
50
|
section.subscription_expires.should == Date.today + 60
|
35
51
|
section.type.should == :cubs
|
36
|
-
section.num_scouts.should == 10
|
37
52
|
section.column_names.should == {:column_names => 'names'}
|
38
53
|
section.fields.should == {:fields => true}
|
39
54
|
section.intouch_fields.should == {:intouch_fields => true}
|
@@ -41,6 +56,23 @@ describe "Section" do
|
|
41
56
|
section.group_id.should == 3
|
42
57
|
section.group_name.should == '3rd Somewhere'
|
43
58
|
section.flexi_records.should == []
|
59
|
+
section.gocardless.should == true
|
60
|
+
section.myscout_events_expires.should == Date.today + 61
|
61
|
+
section.myscout_badges_expires.should == Date.today + 62
|
62
|
+
section.myscout_programme_expires.should == Date.today + 63
|
63
|
+
section.myscout_events.should == true
|
64
|
+
section.myscout_badges.should == true
|
65
|
+
section.myscout_programme.should == true
|
66
|
+
section.myscout_payments.should == true
|
67
|
+
section.myscout_emails.should == {:email1 => true, :email2 => false}
|
68
|
+
section.myscout_email_address_send.should == 'send_from@example.com'
|
69
|
+
section.myscout_email_address_copy.should == ''
|
70
|
+
section.myscout_badges_partial.should == true
|
71
|
+
section.myscout_programme_summary.should == true
|
72
|
+
section.myscout_event_reminder_count.should == 4
|
73
|
+
section.myscout_event_reminder_frequency.should == 5
|
74
|
+
section.myscout_payment_reminder_count.should == 6
|
75
|
+
section.myscout_payment_reminder_frequency.should == 7
|
44
76
|
section.valid?.should be_true
|
45
77
|
end
|
46
78
|
|
@@ -51,7 +83,6 @@ describe "Section" do
|
|
51
83
|
section.subscription_level.should == :unknown
|
52
84
|
section.subscription_expires.should == nil
|
53
85
|
section.type.should == :unknown
|
54
|
-
section.num_scouts.should == nil
|
55
86
|
section.column_names.should == {}
|
56
87
|
section.fields.should == {}
|
57
88
|
section.intouch_fields.should == {}
|
@@ -64,7 +95,7 @@ describe "Section" do
|
|
64
95
|
|
65
96
|
before :each do
|
66
97
|
body = [
|
67
|
-
{"sectionConfig"=>"{\"subscription_level\":1,\"subscription_expires\":\"2013-01-05\",\"sectionType\":\"beavers\",\"columnNames\":{\"column_names\":\"names\"},\"numscouts\":10,\"hasUsedBadgeRecords\":true,\"hasProgramme\":true,\"extraRecords\":[{\"name\":\"Flexi Record 1\",\"extraid\":\"111\"}],\"wizard\":\"false\",\"fields\":{\"fields\":true},\"intouch\":{\"intouch_fields\":true},\"mobFields\":{\"mobile_fields\":true}}", "groupname"=>"3rd Somewhere", "groupid"=>"3", "groupNormalised"=>"1", "sectionid"=>"1", "sectionname"=>"Section 1", "section"=>"beavers", "isDefault"=>"1", "permissions"=>{"badge"=>10, "member"=>20, "user"=>100, "register"=>100, "contact"=>100, "programme"=>100, "originator"=>1, "events"=>100, "finance"=>100, "flexi"=>100}},
|
98
|
+
{"sectionConfig"=>"{\"subscription_level\":1,\"subscription_expires\":\"2013-01-05\",\"sectionType\":\"beavers\",\"columnNames\":{\"column_names\":\"names\"},\"numscouts\":10,\"hasUsedBadgeRecords\":true,\"hasProgramme\":true,\"extraRecords\":[{\"name\":\"Flexi Record 1\",\"extraid\":\"111\"}],\"wizard\":\"false\",\"fields\":{\"fields\":true},\"intouch\":{\"intouch_fields\":true},\"mobFields\":{\"mobile_fields\":true},\"gocardless\":\"true\",\"portal\":{\"paymentRemindFrequency\":\"7\",\"paymentRemindCount\":\"6\",\"eventRemindFrequency\":\"5\",\"eventRemindCount\":\"4\",\"badgesPartial\":1,\"programmeSummary\":1,\"emailAddress\":\"send_from@example.com\",\"emailAddressCopy\":\"\",\"payments\":1,\"badges\":1,\"emails\":{\"email1\":\"true\",\"email2\":\"false\"},\"events\":1,\"programme\":1},\"portalExpires\":{\"events\":\"2013-01-06\",\"eventsA\":1,\"badges\":\"2013-01-07\",\"badgesA\":1,\"programme\":\"2013-01-08\",\"programmeA\":1}}", "groupname"=>"3rd Somewhere", "groupid"=>"3", "groupNormalised"=>"1", "sectionid"=>"1", "sectionname"=>"Section 1", "section"=>"beavers", "isDefault"=>"1", "permissions"=>{"badge"=>10, "member"=>20, "user"=>100, "register"=>100, "contact"=>100, "programme"=>100, "originator"=>1, "events"=>100, "finance"=>100, "flexi"=>100}},
|
68
99
|
{"sectionConfig"=>"{\"subscription_level\":3,\"subscription_expires\":\"2013-01-05\",\"sectionType\":\"cubs\",\"columnNames\":{\"phone1\":\"Home Phone\",\"phone2\":\"Parent 1 Phone\",\"address\":\"Member's Address\",\"phone3\":\"Parent 2 Phone\",\"address2\":\"Address 2\",\"phone4\":\"Alternate Contact Phone\",\"subs\":\"Gender\",\"email1\":\"Parent 1 Email\",\"medical\":\"Medical / Dietary\",\"email2\":\"Parent 2 Email\",\"ethnicity\":\"Gift Aid\",\"email3\":\"Member's Email\",\"religion\":\"Religion\",\"email4\":\"Email 4\",\"school\":\"School\"},\"numscouts\":10,\"hasUsedBadgeRecords\":true,\"hasProgramme\":true,\"extraRecords\":[],\"wizard\":\"false\",\"fields\":{\"email1\":true,\"email2\":true,\"email3\":true,\"email4\":false,\"address\":true,\"address2\":false,\"phone1\":true,\"phone2\":true,\"phone3\":true,\"phone4\":true,\"school\":false,\"religion\":true,\"ethnicity\":true,\"medical\":true,\"patrol\":true,\"subs\":true,\"saved\":true},\"intouch\":{\"address\":true,\"address2\":false,\"email1\":false,\"email2\":false,\"email3\":false,\"email4\":false,\"phone1\":true,\"phone2\":true,\"phone3\":true,\"phone4\":true,\"medical\":false},\"mobFields\":{\"email1\":false,\"email2\":false,\"email3\":false,\"email4\":false,\"address\":true,\"address2\":false,\"phone1\":true,\"phone2\":true,\"phone3\":true,\"phone4\":true,\"school\":false,\"religion\":false,\"ethnicity\":true,\"medical\":true,\"patrol\":true,\"subs\":false}}", "groupname"=>"1st Somewhere", "groupid"=>"1", "groupNormalised"=>"1", "sectionid"=>"2", "sectionname"=>"Section 2", "section"=>"cubs", "isDefault"=>"0", "permissions"=>{"badge"=>100, "member"=>100, "user"=>100, "register"=>100, "contact"=>100, "programme"=>100, "originator"=>1, "events"=>100, "finance"=>100, "flexi"=>100}}
|
69
100
|
]
|
70
101
|
FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/api.php?action=getUserRoles", :body => body.to_json)
|
@@ -80,7 +111,6 @@ describe "Section" do
|
|
80
111
|
section.subscription_level.should == :bronze
|
81
112
|
section.subscription_expires.should == Date.new(2013, 1, 5)
|
82
113
|
section.type.should == :beavers
|
83
|
-
section.num_scouts.should == 10
|
84
114
|
section.column_names.should == {:column_names => 'names'}
|
85
115
|
section.fields.should == {:fields => true}
|
86
116
|
section.intouch_fields.should == {:intouch_fields => true}
|
@@ -90,12 +120,30 @@ describe "Section" do
|
|
90
120
|
section.flexi_records.size.should == 1
|
91
121
|
section.flexi_records[0].id.should == 111
|
92
122
|
section.flexi_records[0].name.should == 'Flexi Record 1'
|
123
|
+
section.gocardless.should == true
|
124
|
+
section.myscout_events_expires.should == Date.new(2013, 1, 6)
|
125
|
+
section.myscout_badges_expires.should == Date.new(2013, 1, 7)
|
126
|
+
section.myscout_programme_expires.should == Date.new(2013, 1, 8)
|
127
|
+
section.myscout_events.should == true
|
128
|
+
section.myscout_badges.should == true
|
129
|
+
section.myscout_programme.should == true
|
130
|
+
section.myscout_payments.should == true
|
131
|
+
section.myscout_emails.should == {:email1 => true, :email2 => false}
|
132
|
+
section.myscout_email_address_send.should == 'send_from@example.com'
|
133
|
+
section.myscout_email_address_copy.should == ''
|
134
|
+
section.myscout_badges_partial.should == true
|
135
|
+
section.myscout_programme_summary.should == true
|
136
|
+
section.myscout_event_reminder_count.should == 4
|
137
|
+
section.myscout_event_reminder_frequency.should == 5
|
138
|
+
section.myscout_payment_reminder_count.should == 6
|
139
|
+
section.myscout_payment_reminder_frequency.should == 7
|
93
140
|
end
|
94
141
|
|
95
142
|
it "Gets a section" do
|
96
143
|
section = Osm::Section.get(@api, 1)
|
97
144
|
section.should_not be_nil
|
98
145
|
section.id.should == 1
|
146
|
+
section.valid?.should be_true
|
99
147
|
end
|
100
148
|
|
101
149
|
it "Fetches user's permissions" do
|
@@ -295,7 +343,7 @@ describe "Online Scout Manager API Strangeness" do
|
|
295
343
|
section.get_notepad(@api).should == ''
|
296
344
|
end
|
297
345
|
|
298
|
-
it "
|
346
|
+
it "skips a 'discount' section" do
|
299
347
|
body = [
|
300
348
|
{"sectionConfig"=>"{\"subscription_level\":1,\"subscription_expires\":\"2013-01-05\",\"sectionType\":\"beavers\",\"columnNames\":{\"phone1\":\"Home Phone\",\"phone2\":\"Parent 1 Phone\",\"address\":\"Member's Address\",\"phone3\":\"Parent 2 Phone\",\"address2\":\"Address 2\",\"phone4\":\"Alternate Contact Phone\",\"subs\":\"Gender\",\"email1\":\"Parent 1 Email\",\"medical\":\"Medical / Dietary\",\"email2\":\"Parent 2 Email\",\"ethnicity\":\"Gift Aid\",\"email3\":\"Member's Email\",\"religion\":\"Religion\",\"email4\":\"Email 4\",\"school\":\"School\"},\"numscouts\":10,\"hasUsedBadgeRecords\":true,\"hasProgramme\":true,\"extraRecords\":[],\"wizard\":\"false\",\"fields\":{\"email1\":true,\"email2\":true,\"email3\":true,\"email4\":false,\"address\":true,\"address2\":false,\"phone1\":true,\"phone2\":true,\"phone3\":true,\"phone4\":true,\"school\":false,\"religion\":true,\"ethnicity\":true,\"medical\":true,\"patrol\":true,\"subs\":true,\"saved\":true},\"intouch\":{\"address\":true,\"address2\":false,\"email1\":false,\"email2\":false,\"email3\":false,\"email4\":false,\"phone1\":true,\"phone2\":true,\"phone3\":true,\"phone4\":true,\"medical\":false},\"mobFields\":{\"email1\":false,\"email2\":false,\"email3\":false,\"email4\":false,\"address\":true,\"address2\":false,\"phone1\":true,\"phone2\":true,\"phone3\":true,\"phone4\":true,\"school\":false,\"religion\":false,\"ethnicity\":true,\"medical\":true,\"patrol\":true,\"subs\":false}}", "groupname"=>"3rd Somewhere", "groupid"=>"3", "groupNormalised"=>"1", "sectionid"=>"1", "sectionname"=>"Section 1", "section"=>"beavers", "isDefault"=>"1", "permissions"=>{"badge"=>100, "member"=>100, "user"=>100, "register"=>100, "contact"=>100, "programme"=>100, "originator"=>1, "events"=>100, "finance"=>100, "flexi"=>100}},
|
301
349
|
{"sectionConfig"=>"{\"code\":1,\"districts\":[\"Loddon\",\"Kennet\"]}","groupname"=>"Berkshire","groupid"=>"2","groupNormalised"=>"1","sectionid"=>"3","sectionname"=>"County Admin","section"=>"discount","isDefault"=>"0","permissions"=>{"districts"=>["Loddon"]}}
|
@@ -309,4 +357,17 @@ describe "Online Scout Manager API Strangeness" do
|
|
309
357
|
section.id.should == 1
|
310
358
|
end
|
311
359
|
|
360
|
+
it "handles section config being either a Hash or a JSON encoded Hash" do
|
361
|
+
body = [
|
362
|
+
{"sectionConfig"=>"{\"subscription_level\":1,\"subscription_expires\":\"2013-01-05\",\"sectionType\":\"beavers\",\"columnNames\":{\"column_names\":\"names\"},\"numscouts\":10,\"hasUsedBadgeRecords\":true,\"hasProgramme\":true,\"extraRecords\":[{\"name\":\"Flexi Record 1\",\"extraid\":\"111\"}],\"wizard\":\"false\",\"fields\":{\"fields\":true},\"intouch\":{\"intouch_fields\":true},\"mobFields\":{\"mobile_fields\":true}}", "groupname"=>"3rd Somewhere", "groupid"=>"3", "groupNormalised"=>"1", "sectionid"=>"1", "sectionname"=>"Section 1", "section"=>"beavers", "isDefault"=>"1", "permissions"=>{"badge"=>10, "member"=>20, "user"=>100, "register"=>100, "contact"=>100, "programme"=>100, "originator"=>1, "events"=>100, "finance"=>100, "flexi"=>100}},
|
363
|
+
{"sectionConfig"=>{"subscription_level"=>3,"subscription_expires"=>"2013-01-05","sectionType"=>"cubs","columnNames"=>{"phone1"=>"Home Phone","phone2"=>"Parent 1 Phone","address"=>"Member's Address","phone3"=>"Parent 2 Phone","address2"=>"Address 2","phone4"=>"Alternate Contact Phone","subs"=>"Gender","email1"=>"Parent 1 Email","medical"=>"Medical / Dietary","email2"=>"Parent 2 Email","ethnicity"=>"Gift Aid","email3"=>"Member's Email","religion"=>"Religion","email4"=>"Email 4","school"=>"School"},"numscouts"=>10,"hasUsedBadgeRecords"=>true,"hasProgramme"=>true,"extraRecords"=>[],"wizard"=>"false","fields"=>{"email1"=>true,"email2"=>true,"email3"=>true,"email4"=>false,"address"=>true,"address2"=>false,"phone1"=>true,"phone2"=>true,"phone3"=>true,"phone4"=>true,"school"=>false,"religion"=>true,"ethnicity"=>true,"medical"=>true,"patrol"=>true,"subs"=>true,"saved"=>true},"intouch"=>{"address"=>true,"address2"=>false,"email1"=>false,"email2"=>false,"email3"=>false,"email4"=>false,"phone1"=>true,"phone2"=>true,"phone3"=>true,"phone4"=>true,"medical"=>false},"mobFields"=>{"email1"=>false,"email2"=>false,"email3"=>false,"email4"=>false,"address"=>true,"address2"=>false,"phone1"=>true,"phone2"=>true,"phone3"=>true,"phone4"=>true,"school"=>false,"religion"=>false,"ethnicity"=>true,"medical"=>true,"patrol"=>true,"subs"=>false}}, "groupname"=>"1st Somewhere", "groupid"=>"1", "groupNormalised"=>"1", "sectionid"=>"2", "sectionname"=>"Section 2", "section"=>"cubs", "isDefault"=>"0", "permissions"=>{"badge"=>100, "member"=>100, "user"=>100, "register"=>100, "contact"=>100, "programme"=>100, "originator"=>1, "events"=>100, "finance"=>100, "flexi"=>100}}
|
364
|
+
]
|
365
|
+
FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/api.php?action=getUserRoles", :body => body.to_json)
|
366
|
+
|
367
|
+
sections = Osm::Section.get_all(@api)
|
368
|
+
sections.size.should == 2
|
369
|
+
sections[0].should_not be_nil
|
370
|
+
sections[1].should_not be_nil
|
371
|
+
end
|
372
|
+
|
312
373
|
end
|
data/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: osm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.11
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-01-09 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
16
|
-
requirement: &
|
16
|
+
requirement: &79244120 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '3.2'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *79244120
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: httparty
|
27
|
-
requirement: &
|
27
|
+
requirement: &79243800 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0.9'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *79243800
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: active_attr
|
38
|
-
requirement: &
|
38
|
+
requirement: &79243500 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0.6'
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *79243500
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: activemodel
|
49
|
-
requirement: &
|
49
|
+
requirement: &79243020 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ~>
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: '3.2'
|
55
55
|
type: :runtime
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *79243020
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: rake
|
60
|
-
requirement: &
|
60
|
+
requirement: &79242470 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ~>
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: '10.0'
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *79242470
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rspec
|
71
|
-
requirement: &
|
71
|
+
requirement: &79242200 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ~>
|
@@ -76,10 +76,10 @@ dependencies:
|
|
76
76
|
version: '2.11'
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *79242200
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: fakeweb
|
82
|
-
requirement: &
|
82
|
+
requirement: &79241900 !ruby/object:Gem::Requirement
|
83
83
|
none: false
|
84
84
|
requirements:
|
85
85
|
- - ~>
|
@@ -87,7 +87,7 @@ dependencies:
|
|
87
87
|
version: '1.3'
|
88
88
|
type: :development
|
89
89
|
prerelease: false
|
90
|
-
version_requirements: *
|
90
|
+
version_requirements: *79241900
|
91
91
|
description: Use the Online Scout Manager API (https://www.onlinescoutmanager.co.uk)
|
92
92
|
to retrieve and save data.
|
93
93
|
email:
|
@@ -149,18 +149,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
149
149
|
- - ! '>='
|
150
150
|
- !ruby/object:Gem::Version
|
151
151
|
version: '0'
|
152
|
-
segments:
|
153
|
-
- 0
|
154
|
-
hash: 624159517
|
155
152
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
156
153
|
none: false
|
157
154
|
requirements:
|
158
155
|
- - ! '>='
|
159
156
|
- !ruby/object:Gem::Version
|
160
157
|
version: '0'
|
161
|
-
segments:
|
162
|
-
- 0
|
163
|
-
hash: 624159517
|
164
158
|
requirements: []
|
165
159
|
rubyforge_project: osm
|
166
160
|
rubygems_version: 1.8.10
|
@@ -168,3 +162,4 @@ signing_key:
|
|
168
162
|
specification_version: 3
|
169
163
|
summary: Use the Online Scout Manager API
|
170
164
|
test_files: []
|
165
|
+
has_rdoc:
|