osm 1.2.13 → 1.2.14

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- N2ExNWUzMjEwM2JjMjI1ZTMwN2I5MjAzNjY2YjY4MTUxNDg3ZGNlNg==
4
+ ZGU3ZmNhNzhmMTBlNDY4ZmJjMTU2YmUwNmRiN2NlODgxNGYyZWZjYg==
5
5
  data.tar.gz: !binary |-
6
- NWE5Y2U1MWRmMjY0Y2RiYTU1YzUxNmNmZjUyYzlkZjYxZGUzMzhmMw==
6
+ NTY0OGM2NDkzOWVlMWJhOTU5MWNiZjJkMGIyZjUwMjRmY2I1ZGNlMg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- N2I2YjcwYWRhNWY1YTI0NGRlNzRhZTJkZjkwZTk4ZWUwYjIzMmNmNjUyNDQ1
10
- YTIzYTQ0MWJhYTZmZWUzNjViNjgwY2Y5YWUxN2FiMWVkN2EwODk1ZDI3YzY2
11
- MjEyYWViZTJiOWExMzVkYTRiZjg4ZWY2ZThkNmIxNmIwNTBiYTA=
9
+ OTY5Njg0MmZhYjkwZDBlYjNiZWIwMWE5OGRkNDYyMmM0M2ZiNDU2MDQ2MTY4
10
+ ZTczNDI4ZjdhZDVlMGVhY2E3ZGI0MGZhYjBlOWRmNjU3YzliMjJlNGU1MWEy
11
+ Yzg3MDg3ZDkzYzBhNmI2M2Y1MzU1YWYxOWZlNzVhOTFlOWM0MWM=
12
12
  data.tar.gz: !binary |-
13
- YWYzNGFhYTM3Y2E1NDVmM2IxMWFkYjkwZTY1NGE3ZTJmY2E0NTA0OWZiNTIx
14
- NDUwMWY3MmI0NDUxYTQxMTZiZTA2NWRlM2EzY2QxMDQ5NTRiMWFhMzliMDZl
15
- ZGY1NDgyYTE2OGIwNzhlNWQzYmEyODlhNWVkZWViNDdlM2I5YzI=
13
+ Nzc4ZjljYTQ1YzVhNDM3MTlhYTUwZDY1YWRmOWQ2MjFmOTllNTZmZmI0NTZi
14
+ ZjZkMjVhNWQ0YWViNDAzN2RjNDkxYWI2N2M5NTQyOGNiZDllZTNlMjEzMjhl
15
+ MzY4ZGRmNDFkYjdhNGIwN2Q3Zjk5ZjgyOTI1OGNiMjhkMjA4ZjU=
@@ -1,3 +1,7 @@
1
+ ## Version 1.2.14
2
+
3
+ * Fix fetching sections when user doesn't have access to any
4
+
1
5
  ## Version 1.2.13
2
6
 
3
7
  * Fix event.get\_attendance ignoring term in building the cache key
@@ -192,74 +192,75 @@ module Osm
192
192
  ids = Array.new
193
193
  permissions = Hash.new
194
194
  data.each do |role_data|
195
- unless role_data['section'].eql?('discount') # It's not an actual section
196
- section_data = role_data['sectionConfig'].is_a?(String) ? ActiveSupport::JSON.decode(role_data['sectionConfig']) : role_data['sectionConfig']
197
- myscout_data = section_data['portal'] || {}
198
- section_data['portalExpires'] ||= {}
199
- section_id = Osm::to_i_or_nil(role_data['sectionid'])
200
-
201
- # Make sense of flexi records
202
- fr_data = []
203
- flexi_records = []
204
- fr_data = section_data['extraRecords'] if section_data['extraRecords'].is_a?(Array)
205
- fr_data = section_data['extraRecords'].values if section_data['extraRecords'].is_a?(Hash)
206
- fr_data.each do |record_data|
207
- # Expect item to be: {:name=>String, :extraid=>Fixnum}
208
- # Sometimes get item as: [String, {"name"=>String, "extraid"=>Fixnum}]
209
- record_data = record_data[1] if record_data.is_a?(Array)
210
- flexi_records.push Osm::FlexiRecord.new(
211
- :id => Osm::to_i_or_nil(record_data['extraid']),
212
- :name => record_data['name'],
213
- :section_id => section_id,
214
- )
215
- end
216
-
217
- section = new(
218
- :id => section_id,
219
- :name => role_data['sectionname'],
220
- :subscription_level => Osm::to_i_or_nil(section_data['subscription_level']),
221
- :subscription_expires => Osm::parse_date(section_data['subscription_expires']),
222
- :type => !section_data['sectionType'].nil? ? section_data['sectionType'].to_sym : (!section_data['section'].nil? ? section_data['section'].to_sym : :unknown),
223
- :num_scouts => section_data['numscouts'],
224
- :column_names => section_data['columnNames'].is_a?(Hash) ? Osm::symbolize_hash(section_data['columnNames']) : {},
225
- :fields => section_data['fields'].is_a?(Hash) ? Osm::symbolize_hash(section_data['fields']) : {},
226
- :intouch_fields => section_data['intouch'].is_a?(Hash) ? Osm::symbolize_hash(section_data['intouch']) : {},
227
- :mobile_fields => section_data['mobFields'].is_a?(Hash) ? Osm::symbolize_hash(section_data['mobFields']) : {},
228
- :flexi_records => flexi_records.sort,
229
- :group_id => role_data['groupid'],
230
- :group_name => role_data['groupname'],
231
- :gocardless => (section_data['gocardless'] || 'false').downcase.eql?('true'),
232
- :myscout_events_expires => Osm::parse_date(section_data['portalExpires']['events']),
233
- :myscout_badges_expires => Osm::parse_date(section_data['portalExpires']['badges']),
234
- :myscout_programme_expires => Osm::parse_date(section_data['portalExpires']['programme']),
235
- :myscout_details_expires => Osm::parse_date(section_data['portalExpires']['details']),
236
- :myscout_events => myscout_data['events'] == 1,
237
- :myscout_badges => myscout_data['badges'] == 1,
238
- :myscout_programme => myscout_data['programme'] == 1,
239
- :myscout_payments => myscout_data['payments'] == 1,
240
- :myscout_details => myscout_data['details'] == 1,
241
- :myscout_emails => (myscout_data['emails'] || {}).inject({}) { |n,(k,v)| n[k.to_sym] = v.eql?('true'); n},
242
- :myscout_email_address_from => myscout_data['emailAddress'] ? myscout_data['emailAddress'] : '',
243
- :myscout_email_address_copy => myscout_data['emailAddressCopy'] ? myscout_data['emailAddressCopy'] : '',
244
- :myscout_badges_partial => myscout_data['badgesPartial'] == 1,
245
- :myscout_programme_summary => myscout_data['programmeSummary'] == 1,
246
- :myscout_programme_times => myscout_data['programmeTimes'] == 1,
247
- :myscout_programme_show => myscout_data['programmeShow'].to_i,
248
- :myscout_event_reminder_count => myscout_data['eventRemindCount'].to_i,
249
- :myscout_event_reminder_frequency => myscout_data['eventRemindFrequency'].to_i,
250
- :myscout_payment_reminder_count => myscout_data['paymentRemindCount'].to_i,
251
- :myscout_payment_reminder_frequency => myscout_data['paymentRemindFrequency'].to_i,
252
- :myscout_details_email_changes_to => myscout_data['contactNotificationEmail'],
253
- :sms_sent_test => section_data['hasSentTestSMS'],
254
- :sms_messages_sent => section_data['sms_sent'],
255
- :sms_messages_remaining => section_data['sms_remaining'],
195
+ next if role_data['section'].eql?('discount') # It's not an actual section
196
+ next if role_data['sectionConfig'].nil? # No config for the section = user hasn't got access
197
+
198
+ section_data = role_data['sectionConfig'].is_a?(String) ? ActiveSupport::JSON.decode(role_data['sectionConfig']) : role_data['sectionConfig']
199
+ myscout_data = section_data['portal'] || {}
200
+ section_data['portalExpires'] ||= {}
201
+ section_id = Osm::to_i_or_nil(role_data['sectionid'])
202
+
203
+ # Make sense of flexi records
204
+ fr_data = []
205
+ flexi_records = []
206
+ fr_data = section_data['extraRecords'] if section_data['extraRecords'].is_a?(Array)
207
+ fr_data = section_data['extraRecords'].values if section_data['extraRecords'].is_a?(Hash)
208
+ fr_data.each do |record_data|
209
+ # Expect item to be: {:name=>String, :extraid=>Fixnum}
210
+ # Sometimes get item as: [String, {"name"=>String, "extraid"=>Fixnum}]
211
+ record_data = record_data[1] if record_data.is_a?(Array)
212
+ flexi_records.push Osm::FlexiRecord.new(
213
+ :id => Osm::to_i_or_nil(record_data['extraid']),
214
+ :name => record_data['name'],
215
+ :section_id => section_id,
256
216
  )
257
-
258
- result.push section
259
- ids.push section.id
260
- cache_write(api, ['section', section.id], section)
261
- permissions.merge!(section.id => Osm.make_permissions_hash(role_data['permissions']))
262
217
  end
218
+
219
+ section = new(
220
+ :id => section_id,
221
+ :name => role_data['sectionname'],
222
+ :subscription_level => Osm::to_i_or_nil(section_data['subscription_level']),
223
+ :subscription_expires => Osm::parse_date(section_data['subscription_expires']),
224
+ :type => !section_data['sectionType'].nil? ? section_data['sectionType'].to_sym : (!section_data['section'].nil? ? section_data['section'].to_sym : :unknown),
225
+ :num_scouts => section_data['numscouts'],
226
+ :column_names => section_data['columnNames'].is_a?(Hash) ? Osm::symbolize_hash(section_data['columnNames']) : {},
227
+ :fields => section_data['fields'].is_a?(Hash) ? Osm::symbolize_hash(section_data['fields']) : {},
228
+ :intouch_fields => section_data['intouch'].is_a?(Hash) ? Osm::symbolize_hash(section_data['intouch']) : {},
229
+ :mobile_fields => section_data['mobFields'].is_a?(Hash) ? Osm::symbolize_hash(section_data['mobFields']) : {},
230
+ :flexi_records => flexi_records.sort,
231
+ :group_id => role_data['groupid'],
232
+ :group_name => role_data['groupname'],
233
+ :gocardless => (section_data['gocardless'] || 'false').downcase.eql?('true'),
234
+ :myscout_events_expires => Osm::parse_date(section_data['portalExpires']['events']),
235
+ :myscout_badges_expires => Osm::parse_date(section_data['portalExpires']['badges']),
236
+ :myscout_programme_expires => Osm::parse_date(section_data['portalExpires']['programme']),
237
+ :myscout_details_expires => Osm::parse_date(section_data['portalExpires']['details']),
238
+ :myscout_events => myscout_data['events'] == 1,
239
+ :myscout_badges => myscout_data['badges'] == 1,
240
+ :myscout_programme => myscout_data['programme'] == 1,
241
+ :myscout_payments => myscout_data['payments'] == 1,
242
+ :myscout_details => myscout_data['details'] == 1,
243
+ :myscout_emails => (myscout_data['emails'] || {}).inject({}) { |n,(k,v)| n[k.to_sym] = v.eql?('true'); n},
244
+ :myscout_email_address_from => myscout_data['emailAddress'] ? myscout_data['emailAddress'] : '',
245
+ :myscout_email_address_copy => myscout_data['emailAddressCopy'] ? myscout_data['emailAddressCopy'] : '',
246
+ :myscout_badges_partial => myscout_data['badgesPartial'] == 1,
247
+ :myscout_programme_summary => myscout_data['programmeSummary'] == 1,
248
+ :myscout_programme_times => myscout_data['programmeTimes'] == 1,
249
+ :myscout_programme_show => myscout_data['programmeShow'].to_i,
250
+ :myscout_event_reminder_count => myscout_data['eventRemindCount'].to_i,
251
+ :myscout_event_reminder_frequency => myscout_data['eventRemindFrequency'].to_i,
252
+ :myscout_payment_reminder_count => myscout_data['paymentRemindCount'].to_i,
253
+ :myscout_payment_reminder_frequency => myscout_data['paymentRemindFrequency'].to_i,
254
+ :myscout_details_email_changes_to => myscout_data['contactNotificationEmail'],
255
+ :sms_sent_test => section_data['hasSentTestSMS'],
256
+ :sms_messages_sent => section_data['sms_sent'],
257
+ :sms_messages_remaining => section_data['sms_remaining'],
258
+ )
259
+
260
+ result.push section
261
+ ids.push section.id
262
+ cache_write(api, ['section', section.id], section)
263
+ permissions.merge!(section.id => Osm.make_permissions_hash(role_data['permissions']))
263
264
  end
264
265
 
265
266
  permissions.each do |s_id, perms|
@@ -385,4 +385,11 @@ describe "Online Scout Manager API Strangeness" do
385
385
  sections[1].should_not be_nil
386
386
  end
387
387
 
388
+ it "Handles user having access to no sections" do
389
+ FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/api.php?action=getUserRoles", :body => '[{"isDefault":"1"}]', :content_type => 'application/json')
390
+
391
+ sections = Osm::Section.get_all(@api)
392
+ sections.should == []
393
+ end
394
+
388
395
  end
data/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Osm
2
- VERSION = "1.2.13"
2
+ VERSION = "1.2.14"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: osm
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.13
4
+ version: 1.2.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Gauld
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-04 00:00:00.000000000 Z
11
+ date: 2014-08-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport