osm 1.2.22 → 1.2.23
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.travis.yml +1 -0
- data/CHANGELOG.md +8 -0
- data/lib/osm.rb +1 -0
- data/lib/osm/activity.rb +2 -7
- data/lib/osm/api.rb +49 -16
- data/lib/osm/badge.rb +4 -10
- data/lib/osm/budget.rb +2 -8
- data/lib/osm/event.rb +7 -32
- data/lib/osm/flexi_record.rb +2 -0
- data/lib/osm/giftaid.rb +4 -15
- data/lib/osm/grouping.rb +1 -7
- data/lib/osm/invoice.rb +4 -15
- data/lib/osm/meeting.rb +3 -9
- data/lib/osm/model.rb +6 -3
- data/lib/osm/register.rb +2 -16
- data/lib/osm/section.rb +1 -3
- data/lib/osm/term.rb +1 -8
- data/spec/osm/api_spec.rb +25 -0
- data/version.rb +1 -1
- metadata +42 -68
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 5a1c77bba99130c55b0574c0a890c685e99611c2
|
4
|
+
data.tar.gz: 5b81b4165fbd1244ae170f310e5968aa5ffa76ad
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 996af429a7bc3cebae38f122bffc7b3201e16f61d55a54c4320f83ac1501023bb94ff87d23da474bdf92883828741fdf91b832dc82c01c89aed995eb9bf69631
|
7
|
+
data.tar.gz: 087c903f06680b4216c16809dad00b3303b689814c6dc631a25d796154eaf48e39ea9c2a98f3e9cba364e3e1e81cad08e2517a6a94710b62488386c9975b0034
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
## Version 1.2.23
|
2
|
+
|
3
|
+
* Geting list of user roles for getting sections and permissions now done using the get_user_roles method of api instances
|
4
|
+
* When user has no roles in OSM:
|
5
|
+
* get_user_roles will return an empty Array
|
6
|
+
* get_user_roles! (new method) will raise an Osm::NoActiveRoles exception
|
7
|
+
* Fix 'undefined local method or variable fetch_from_osm' when retrieving badges
|
8
|
+
|
1
9
|
## Version 1.2.22
|
2
10
|
|
3
11
|
* Fix marking badge as due when not passing a level
|
data/lib/osm.rb
CHANGED
@@ -12,6 +12,7 @@ module Osm
|
|
12
12
|
class Error < Exception; end
|
13
13
|
class ConnectionError < Error; end
|
14
14
|
class Forbidden < Osm::Error; end
|
15
|
+
class NoActiveRoles < Osm::Error; end
|
15
16
|
class ArgumentIsInvalid < ArgumentError; end
|
16
17
|
class ObjectIsInvalid < Error; end
|
17
18
|
class Osm::Error::NoCurrentTerm < Osm::Error
|
data/lib/osm/activity.rb
CHANGED
@@ -5,6 +5,8 @@ module Osm
|
|
5
5
|
class File; end # Ensure the constant exists for the validators
|
6
6
|
class Version; end # Ensure the constant exists for the validators
|
7
7
|
|
8
|
+
SORT_BY = [:id, :version]
|
9
|
+
|
8
10
|
# @!attribute [rw] id
|
9
11
|
# @return [Fixnum] the id for the activity
|
10
12
|
# @!attribute [rw] version
|
@@ -274,13 +276,6 @@ module Osm
|
|
274
276
|
end
|
275
277
|
end
|
276
278
|
|
277
|
-
# Compare Activity based on id then version
|
278
|
-
def <=>(another)
|
279
|
-
result = self.id <=> another.try(:id)
|
280
|
-
result = self.version <=> another.try(:version) if result == 0
|
281
|
-
return result
|
282
|
-
end
|
283
|
-
|
284
279
|
|
285
280
|
private
|
286
281
|
class File
|
data/lib/osm/api.rb
CHANGED
@@ -169,6 +169,44 @@ module Osm
|
|
169
169
|
}))
|
170
170
|
end
|
171
171
|
|
172
|
+
# Get API user's roles in OSM
|
173
|
+
# @!macro options_get
|
174
|
+
# @return [Array<Hash>] data returned by OSM
|
175
|
+
def get_user_roles(*args)
|
176
|
+
begin
|
177
|
+
get_user_roles!(*args)
|
178
|
+
rescue Osm::NoActiveRoles
|
179
|
+
return []
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
183
|
+
|
184
|
+
# Get API user's roles in OSM
|
185
|
+
# @!macro options_get
|
186
|
+
# @return [Array<Hash>] data returned by OSM
|
187
|
+
# @raises Osm::NoActiveRoles
|
188
|
+
def get_user_roles!(options={})
|
189
|
+
cache_key = ['user_roles', @user_id]
|
190
|
+
|
191
|
+
if !options[:no_cache] && Osm::Model.cache_exist?(self, cache_key)
|
192
|
+
return Osm::Model.cache_read(self, cache_key)
|
193
|
+
end
|
194
|
+
|
195
|
+
begin
|
196
|
+
data = perform_query('api.php?action=getUserRoles')
|
197
|
+
Osm::Model.cache_write(self, cache_key, data)
|
198
|
+
return data
|
199
|
+
|
200
|
+
rescue Osm::Error => e
|
201
|
+
if e.message.eql?('false')
|
202
|
+
fail Osm::NoActiveRoles, "You do not have any active roles in OSM."
|
203
|
+
else
|
204
|
+
raise e
|
205
|
+
end
|
206
|
+
end
|
207
|
+
|
208
|
+
end
|
209
|
+
|
172
210
|
# Get API user's permissions
|
173
211
|
# @!macro options_get
|
174
212
|
# @return nil if an error occured or the user does not have access to that section
|
@@ -180,10 +218,8 @@ module Osm
|
|
180
218
|
return Osm::Model.cache_read(self, cache_key)
|
181
219
|
end
|
182
220
|
|
183
|
-
data = perform_query('api.php?action=getUserRoles')
|
184
|
-
|
185
221
|
all_permissions = Hash.new
|
186
|
-
|
222
|
+
get_user_roles(options).each do |item|
|
187
223
|
unless item['section'].eql?('discount') # It's not an actual section
|
188
224
|
all_permissions.merge!(Osm::to_i_or_nil(item['sectionid']) => Osm.make_permissions_hash(item['permissions']))
|
189
225
|
end
|
@@ -242,25 +278,22 @@ module Osm
|
|
242
278
|
return nil if result.response.body.empty?
|
243
279
|
case result.response.content_type
|
244
280
|
when 'application/json', 'text/html'
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
281
|
+
begin
|
282
|
+
decoded = ActiveSupport::JSON.decode(result.response.body)
|
283
|
+
if osm_error = get_osm_error(decoded)
|
284
|
+
fail Osm::Error, osm_error if osm_error
|
285
|
+
end
|
286
|
+
return decoded
|
287
|
+
rescue ActiveModel::VERSION::MAJOR.eql?(4) ? JSON::ParserError : MultiJson::ParseError
|
288
|
+
fail Osm::Error, result.response.body
|
289
|
+
end
|
250
290
|
when 'image/jpeg'
|
251
291
|
return result.response.body
|
252
292
|
else
|
253
|
-
|
293
|
+
fail Osm::Error, "Unhandled content-type: #{result.response.content_type}"
|
254
294
|
end
|
255
295
|
end
|
256
296
|
|
257
|
-
# Check if text looks like it's JSON
|
258
|
-
# @param [String] text What to look at
|
259
|
-
# @return [Boolean]
|
260
|
-
def self.looks_like_json?(text)
|
261
|
-
(['[', '{'].include?(text[0]))
|
262
|
-
end
|
263
|
-
|
264
297
|
# Get the error returned by OSM
|
265
298
|
# @param data what OSM gave us
|
266
299
|
# @return false if no error message was found
|
data/lib/osm/badge.rb
CHANGED
@@ -324,14 +324,14 @@ module Osm
|
|
324
324
|
@module_completion_data = get_module_completion_data(api, options) if fetched_this_time
|
325
325
|
|
326
326
|
if @module_completion_data[badge.id].nil? && !fetched_this_time
|
327
|
-
@module_completion_data =
|
327
|
+
@module_completion_data = get_module_completion_data(api, options)
|
328
328
|
fetched_this_time = true
|
329
329
|
end
|
330
330
|
data = @module_completion_data[badge.id]
|
331
331
|
raise ArgumentError, "That badge does't exist (bad ID)." if data.nil?
|
332
332
|
|
333
333
|
if data[badge.version].nil? && !fetched_this_time
|
334
|
-
@module_completion_data =
|
334
|
+
@module_completion_data = get_module_completion_data(api, options)
|
335
335
|
data = @module_completion_data[badge.id]
|
336
336
|
fetched_this_time = true
|
337
337
|
end
|
@@ -511,6 +511,8 @@ module Osm
|
|
511
511
|
|
512
512
|
|
513
513
|
class Data < Osm::Model
|
514
|
+
SORT_BY = [:badge, :section_id, :member_id]
|
515
|
+
|
514
516
|
# @!attribute [rw] member_id
|
515
517
|
# @return [Fixnum] ID of the member this data relates to
|
516
518
|
# @!attribute [rw] first_name
|
@@ -843,14 +845,6 @@ module Osm
|
|
843
845
|
return requirements_updated && due_updated && awarded_updated
|
844
846
|
end
|
845
847
|
|
846
|
-
# Compare Badge::Data based on badge, section_id then member_id
|
847
|
-
def <=>(another)
|
848
|
-
result = self.badge <=> another.try(:badge)
|
849
|
-
result = self.section_id <=> another.try(:section_id) if result == 0
|
850
|
-
result = self.member_id <=> another.try(:member_id) if result == 0
|
851
|
-
return result
|
852
|
-
end
|
853
|
-
|
854
848
|
def inspect
|
855
849
|
Osm.inspect_instance(self, {:replace_with => {'badge' => :name}})
|
856
850
|
end
|
data/lib/osm/budget.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
module Osm
|
2
2
|
|
3
3
|
class Budget < Osm::Model
|
4
|
+
SORT_BY = [:section_id, :name]
|
5
|
+
|
4
6
|
# @!attribute [rw] id
|
5
7
|
# @return [Fixnum] The OSM ID for the budget
|
6
8
|
# @!attribute [rw] section_id
|
@@ -125,14 +127,6 @@ module Osm
|
|
125
127
|
return false
|
126
128
|
end
|
127
129
|
|
128
|
-
|
129
|
-
# Compare Budget based on section_id then name
|
130
|
-
def <=>(another)
|
131
|
-
result = self.section_id <=> another.try(:section_id)
|
132
|
-
result = self.name <=> another.try(:name) if result == 0
|
133
|
-
return result
|
134
|
-
end
|
135
|
-
|
136
130
|
end # Class Budget
|
137
131
|
|
138
132
|
end
|
data/lib/osm/event.rb
CHANGED
@@ -6,6 +6,7 @@ module Osm
|
|
6
6
|
|
7
7
|
LIST_ATTRIBUTES = [:id, :section_id, :name, :start, :finish, :cost, :location, :notes, :archived, :public_notepad, :confirm_by_date, :allow_changes, :reminders, :attendance_limit, :attendance_limit_includes_leaders, :attendance_reminder, :allow_booking]
|
8
8
|
EXTRA_ATTRIBUTES = [:notepad, :columns, :badges]
|
9
|
+
SORT_BY = [:start, :name, :id]
|
9
10
|
|
10
11
|
# @!attribute [rw] id
|
11
12
|
# @return [Fixnum] the id for the event
|
@@ -501,15 +502,6 @@ module Osm
|
|
501
502
|
cost.eql?('0.00')
|
502
503
|
end
|
503
504
|
|
504
|
-
# Compare Event based on start, name then id
|
505
|
-
def <=>(another)
|
506
|
-
return 0 if self.id == another.try(:id)
|
507
|
-
result = self.start <=> another.try(:start)
|
508
|
-
result = self.name <=> another.try(:name) if result == 0
|
509
|
-
result = self.id <=> another.try(:id) if result == 0
|
510
|
-
return result
|
511
|
-
end
|
512
|
-
|
513
505
|
|
514
506
|
private
|
515
507
|
def attendees(api)
|
@@ -581,6 +573,8 @@ module Osm
|
|
581
573
|
include ActiveModel::MassAssignmentSecurity if ActiveModel::VERSION::MAJOR < 4
|
582
574
|
include ActiveAttr::Model
|
583
575
|
|
576
|
+
SORT_BY = [:badge_section, :badge_type, :badge_name, :requirement_label]
|
577
|
+
|
584
578
|
# @!attribute [rw] badge_type
|
585
579
|
# @return [Symbol] the type of badge
|
586
580
|
# @!attribute [rw] badge_section
|
@@ -622,19 +616,12 @@ module Osm
|
|
622
616
|
# Initialize a new Meeting::Activity
|
623
617
|
# @param [Hash] attributes The hash of attributes (see attributes for descriptions, use Symbol of attribute name as the key)
|
624
618
|
|
625
|
-
# Compare BadgeLink based on section, type, badge_name, requirement_label, data
|
626
|
-
def <=>(another)
|
627
|
-
[:badge_section, :badge_type, :badge_name, :requirement_label].each do |attribute|
|
628
|
-
result = self.try(:data) <=> another.try(:data)
|
629
|
-
return result unless result == 0
|
630
|
-
end
|
631
|
-
return self.try(:data) <=> another.try(:data)
|
632
|
-
end
|
633
|
-
|
634
619
|
end # Class Event::BadgeLink
|
635
620
|
|
636
621
|
|
637
622
|
class Column < Osm::Model
|
623
|
+
SORT_BY = [:event, :id]
|
624
|
+
|
638
625
|
# @!attribute [rw] id
|
639
626
|
# @return [String] OSM id for the column
|
640
627
|
# @!attribute [rw] name
|
@@ -717,13 +704,6 @@ module Osm
|
|
717
704
|
return true
|
718
705
|
end
|
719
706
|
|
720
|
-
# Compare Column based on event then id
|
721
|
-
def <=>(another)
|
722
|
-
result = self.event <=> another.try(:event)
|
723
|
-
result = self.id <=> another.try(:id) if result == 0
|
724
|
-
return result
|
725
|
-
end
|
726
|
-
|
727
707
|
def inspect
|
728
708
|
Osm.inspect_instance(self, options={:replace_with => {'event' => :id}})
|
729
709
|
end
|
@@ -732,6 +712,8 @@ module Osm
|
|
732
712
|
|
733
713
|
|
734
714
|
class Attendance < Osm::Model
|
715
|
+
SORT_BY = [:event, :row]
|
716
|
+
|
735
717
|
# @!attribute [rw] member_id
|
736
718
|
# @return [Fixnum] OSM id for the member
|
737
719
|
# @!attribute [rw] grouping__id
|
@@ -943,13 +925,6 @@ module Osm
|
|
943
925
|
end
|
944
926
|
end
|
945
927
|
|
946
|
-
# Compare Attendance based on event then row
|
947
|
-
def <=>(another)
|
948
|
-
result = self.event <=> another.try(:event)
|
949
|
-
result = self.row <=> another.try(:row) if result == 0
|
950
|
-
return result
|
951
|
-
end
|
952
|
-
|
953
928
|
def inspect
|
954
929
|
Osm.inspect_instance(self, options={:replace_with => {'event' => :id}})
|
955
930
|
end
|
data/lib/osm/flexi_record.rb
CHANGED
data/lib/osm/giftaid.rb
CHANGED
@@ -134,6 +134,8 @@ module Osm
|
|
134
134
|
end
|
135
135
|
|
136
136
|
class Donation < Osm::Model
|
137
|
+
SORT_BY = [:donation_date]
|
138
|
+
|
137
139
|
# @!attribute [rw] donation_date
|
138
140
|
# @return [Date] When the payment was made
|
139
141
|
|
@@ -151,15 +153,12 @@ module Osm
|
|
151
153
|
# @param [Hash] attributes The hash of attributes (see attributes for descriptions, use Symbol of attribute name as the key)
|
152
154
|
|
153
155
|
|
154
|
-
# Compare Payment based on donation_date then note
|
155
|
-
def <=>(another)
|
156
|
-
return self.donation_date <=> another.try(:donation_date)
|
157
|
-
end
|
158
|
-
|
159
156
|
end # Class GiftAid::Donation
|
160
157
|
|
161
158
|
|
162
159
|
class Data < Osm::Model
|
160
|
+
SORT_BY = [:section_id, :grouping_id, :last_name, :first_name]
|
161
|
+
|
163
162
|
# @!attribute [rw] member_id
|
164
163
|
# @return [Fixnum] The OSM ID for the member
|
165
164
|
# @!attribute [rw] grouping_id
|
@@ -279,16 +278,6 @@ module Osm
|
|
279
278
|
return updated
|
280
279
|
end
|
281
280
|
|
282
|
-
|
283
|
-
# Compare Data based on section_id, grouping_id, last_name then first_name
|
284
|
-
def <=>(another)
|
285
|
-
result = self.section_id <=> another.try(:section_id)
|
286
|
-
result = self.grouping_id <=> another.try(:grouping_id) if result == 0
|
287
|
-
result = self.last_name <=> another.try(:last_name) if result == 0
|
288
|
-
result = self.first_name <=> another.try(:last_name) if result == 0
|
289
|
-
return result
|
290
|
-
end
|
291
|
-
|
292
281
|
end # Class GiftAid::Data
|
293
282
|
|
294
283
|
end # Class GiftAid
|
data/lib/osm/grouping.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
module Osm
|
2
2
|
|
3
3
|
class Grouping < Osm::Model
|
4
|
+
SORT_BY = [:section_id, :name]
|
4
5
|
|
5
6
|
# @!attribute [rw] id
|
6
7
|
# @return [Fixnum] the id for grouping
|
@@ -106,13 +107,6 @@ module Osm
|
|
106
107
|
return result
|
107
108
|
end
|
108
109
|
|
109
|
-
# Compare Grouping based on section_id then name
|
110
|
-
def <=>(another)
|
111
|
-
result = self.section_id <=> another.try(:section_id)
|
112
|
-
result = self.name <=> another.try(:name) if result == 0
|
113
|
-
return result
|
114
|
-
end
|
115
|
-
|
116
110
|
end # Class Grouping
|
117
111
|
|
118
112
|
end # Module
|
data/lib/osm/invoice.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
module Osm
|
2
2
|
|
3
3
|
class Invoice < Osm::Model
|
4
|
+
SORT_BY = [:section_id, :name, :date]
|
5
|
+
|
4
6
|
# @!attribute [rw] id
|
5
7
|
# @return [Fixnum] The OSM ID for the invoice
|
6
8
|
# @!attribute [rw] section_id
|
@@ -239,14 +241,6 @@ module Osm
|
|
239
241
|
return items
|
240
242
|
end
|
241
243
|
|
242
|
-
# Compare Invoice based on section_id, name then date
|
243
|
-
def <=>(another)
|
244
|
-
result = self.section_id <=> another.try(:section_id)
|
245
|
-
result = self.name <=> another.try(:name) if result == 0
|
246
|
-
result = self.date <=> another.try(:date) if result == 0
|
247
|
-
return result
|
248
|
-
end
|
249
|
-
|
250
244
|
|
251
245
|
private
|
252
246
|
def self.new_invoice_from_data(invoice_data)
|
@@ -266,6 +260,8 @@ module Osm
|
|
266
260
|
|
267
261
|
|
268
262
|
class Item < Osm::Model
|
263
|
+
SORT_BY = [:invoice, :date]
|
264
|
+
|
269
265
|
# @!attribute [rw] id
|
270
266
|
# @return [Fixnum] The OSM ID for the invoice item
|
271
267
|
# @!attribute [rw] invoice
|
@@ -415,13 +411,6 @@ module Osm
|
|
415
411
|
return 0.0
|
416
412
|
end
|
417
413
|
|
418
|
-
# Compare Invoice Item based on invoice then date
|
419
|
-
def <=>(another)
|
420
|
-
result = self.invoice <=> another.try(:invoice)
|
421
|
-
result = self.date <=> another.try(:date) if result == 0
|
422
|
-
return result
|
423
|
-
end
|
424
|
-
|
425
414
|
end # class Invoice::Item
|
426
415
|
|
427
416
|
end # class Invoice
|
data/lib/osm/meeting.rb
CHANGED
@@ -360,6 +360,7 @@ module Osm
|
|
360
360
|
# Initialize a new Meeting::Activity
|
361
361
|
# @param [Hash] attributes The hash of attributes (see attributes for descriptions, use Symbol of attribute name as the key)
|
362
362
|
|
363
|
+
|
363
364
|
# Compare Activity based on title then activity_id
|
364
365
|
def <=>(another)
|
365
366
|
result = self.title <=> another.try(:title)
|
@@ -374,6 +375,8 @@ module Osm
|
|
374
375
|
include ActiveModel::MassAssignmentSecurity if ActiveModel::VERSION::MAJOR < 4
|
375
376
|
include ActiveAttr::Model
|
376
377
|
|
378
|
+
SORT_BY = [:badge_section, :badge_type, :badge_name, :requirement_label]
|
379
|
+
|
377
380
|
# @!attribute [rw] badge_type
|
378
381
|
# @return [Symbol] the type of badge
|
379
382
|
# @!attribute [rw] badge_section
|
@@ -415,15 +418,6 @@ module Osm
|
|
415
418
|
# Initialize a new Meeting::Activity
|
416
419
|
# @param [Hash] attributes The hash of attributes (see attributes for descriptions, use Symbol of attribute name as the key)
|
417
420
|
|
418
|
-
# Compare BadgeLink based on section, type, badge_name, requirement_label, data
|
419
|
-
def <=>(another)
|
420
|
-
[:badge_section, :badge_type, :badge_name, :requirement_label].each do |attribute|
|
421
|
-
result = self.try(:data) <=> another.try(:data)
|
422
|
-
return result unless result == 0
|
423
|
-
end
|
424
|
-
return self.try(:data) <=> another.try(:data)
|
425
|
-
end
|
426
|
-
|
427
421
|
end # Class Meeting::BadgeLink
|
428
422
|
|
429
423
|
end # Class Meeting
|
data/lib/osm/model.rb
CHANGED
@@ -11,6 +11,8 @@ module Osm
|
|
11
11
|
include ActiveModel::MassAssignmentSecurity if ActiveModel::VERSION::MAJOR < 4
|
12
12
|
include ActiveAttr::Model
|
13
13
|
|
14
|
+
SORT_BY = [:id]
|
15
|
+
|
14
16
|
@@cache = nil # Class to use for caching
|
15
17
|
@@cache_prepend = 'OSMAPI' # Prepended to the key
|
16
18
|
@@cache_ttl = 600 # 10 minutes
|
@@ -43,12 +45,13 @@ module Osm
|
|
43
45
|
id.to_i
|
44
46
|
end
|
45
47
|
|
46
|
-
#
|
48
|
+
# Compare functions
|
47
49
|
def <=>(another)
|
48
|
-
|
50
|
+
us_values = self.class::SORT_BY.map{ |i| self.try(i) }
|
51
|
+
them_values = self.class::SORT_BY.map{ |i| another.try(i) }
|
52
|
+
us_values <=> them_values
|
49
53
|
end
|
50
54
|
|
51
|
-
# Add other compare functions
|
52
55
|
def <(another)
|
53
56
|
send('<=>', another) < 0
|
54
57
|
end
|
data/lib/osm/register.rb
CHANGED
@@ -158,16 +158,12 @@ module Osm
|
|
158
158
|
# Initialize a new RegisterField
|
159
159
|
# @param [Hash] attributes The hash of attributes (see attributes for descriptions, use Symbol of attribute name as the key)
|
160
160
|
|
161
|
-
|
162
|
-
# Compare Field based on id then version
|
163
|
-
def <=>(another)
|
164
|
-
return self.id <=> another.try(:id)
|
165
|
-
end
|
166
|
-
|
167
161
|
end # Class Register::Field
|
168
162
|
|
169
163
|
|
170
164
|
class Attendance < Osm::Model
|
165
|
+
SORT_BY = [:section_id, :grouping_id, :last_name, :first_name]
|
166
|
+
|
171
167
|
# @!attribute [rw] member_id
|
172
168
|
# @return [Fixnum] The OSM ID for the member
|
173
169
|
# @!attribute [rw] grouping_id
|
@@ -224,16 +220,6 @@ module Osm
|
|
224
220
|
attendance[date] != :yes
|
225
221
|
end
|
226
222
|
|
227
|
-
|
228
|
-
# Compare Attendance based on section_id, grouping_id, last_name then first_name
|
229
|
-
def <=>(another)
|
230
|
-
result = self.section_id <=> another.try(:section_id)
|
231
|
-
result = self.grouping_id <=> another.try(:grouping_id) if result == 0
|
232
|
-
result = self.last_name <=> another.try(:last_name) if result == 0
|
233
|
-
result = self.first_name <=> another.try(:last_name) if result == 0
|
234
|
-
return result
|
235
|
-
end
|
236
|
-
|
237
223
|
end # Class Register::Attendance
|
238
224
|
|
239
225
|
end # Class Register
|
data/lib/osm/section.rb
CHANGED
@@ -153,12 +153,10 @@ module Osm
|
|
153
153
|
return get_from_ids(api, ids, 'section', options, :get_all)
|
154
154
|
end
|
155
155
|
|
156
|
-
data = api.perform_query('api.php?action=getUserRoles')
|
157
|
-
|
158
156
|
result = Array.new
|
159
157
|
ids = Array.new
|
160
158
|
permissions = Hash.new
|
161
|
-
|
159
|
+
api.get_user_roles(options).each do |role_data|
|
162
160
|
next if role_data['section'].eql?('discount') # It's not an actual section
|
163
161
|
next if role_data['sectionConfig'].nil? # No config for the section = user hasn't got access
|
164
162
|
|
data/lib/osm/term.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
module Osm
|
2
2
|
|
3
3
|
class Term < Osm::Model
|
4
|
+
SORT_BY = [:section_id, :start, :id]
|
4
5
|
|
5
6
|
# @!attribute [rw] id
|
6
7
|
# @return [Fixnum] the id for the term
|
@@ -232,14 +233,6 @@ module Osm
|
|
232
233
|
return (start <= date) && (finish >= date)
|
233
234
|
end
|
234
235
|
|
235
|
-
# Compare Term based on section_id, start then id
|
236
|
-
def <=>(another_term)
|
237
|
-
result = self.section_id <=> another_term.section_id
|
238
|
-
result = self.start <=> another_term.start if result == 0
|
239
|
-
result = self.id <=> another_term.id if result == 0
|
240
|
-
return result
|
241
|
-
end
|
242
|
-
|
243
236
|
end # Class Term
|
244
237
|
|
245
238
|
end # Module
|
data/spec/osm/api_spec.rb
CHANGED
@@ -72,6 +72,31 @@ describe "API" do
|
|
72
72
|
end
|
73
73
|
|
74
74
|
|
75
|
+
describe "Get user roles" do
|
76
|
+
|
77
|
+
before :each do
|
78
|
+
@api = Osm::Api.new(3, 4)
|
79
|
+
end
|
80
|
+
|
81
|
+
it "Returns what OSM gives on success" do
|
82
|
+
@api.stub(:perform_query).with('api.php?action=getUserRoles'){ ['a', 'b'] }
|
83
|
+
@api.get_user_roles.should == ['a', 'b']
|
84
|
+
end
|
85
|
+
|
86
|
+
it "User has no roles in OSM" do
|
87
|
+
@api.stub(:perform_query).with('api.php?action=getUserRoles'){ raise Osm::Error, 'false' }
|
88
|
+
expect{ @api.get_user_roles! }.to raise_error(Osm::NoActiveRoles)
|
89
|
+
@api.get_user_roles.should == []
|
90
|
+
end
|
91
|
+
|
92
|
+
it "Reraises any other Osm::Error" do
|
93
|
+
@api.stub(:perform_query).with('api.php?action=getUserRoles'){ raise Osm::Error, 'Test' }
|
94
|
+
expect{ @api.get_user_roles }.to raise_error(Osm::Error, 'Test')
|
95
|
+
end
|
96
|
+
|
97
|
+
end
|
98
|
+
|
99
|
+
|
75
100
|
describe "User Permissions" do
|
76
101
|
|
77
102
|
it "Get from API" do
|
data/version.rb
CHANGED
metadata
CHANGED
@@ -1,230 +1,205 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: osm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
5
|
-
prerelease:
|
4
|
+
version: 1.2.23
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Robert Gauld
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date: 2016-
|
11
|
+
date: 2016-04-20 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: activesupport
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - ">="
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: '3.2'
|
22
|
-
- - <
|
20
|
+
- - "<"
|
23
21
|
- !ruby/object:Gem::Version
|
24
22
|
version: '5'
|
25
23
|
type: :runtime
|
26
24
|
prerelease: false
|
27
25
|
version_requirements: !ruby/object:Gem::Requirement
|
28
|
-
none: false
|
29
26
|
requirements:
|
30
|
-
- -
|
27
|
+
- - ">="
|
31
28
|
- !ruby/object:Gem::Version
|
32
29
|
version: '3.2'
|
33
|
-
- - <
|
30
|
+
- - "<"
|
34
31
|
- !ruby/object:Gem::Version
|
35
32
|
version: '5'
|
36
33
|
- !ruby/object:Gem::Dependency
|
37
34
|
name: httparty
|
38
35
|
requirement: !ruby/object:Gem::Requirement
|
39
|
-
none: false
|
40
36
|
requirements:
|
41
|
-
- - ~>
|
37
|
+
- - "~>"
|
42
38
|
- !ruby/object:Gem::Version
|
43
39
|
version: '0.9'
|
44
40
|
type: :runtime
|
45
41
|
prerelease: false
|
46
42
|
version_requirements: !ruby/object:Gem::Requirement
|
47
|
-
none: false
|
48
43
|
requirements:
|
49
|
-
- - ~>
|
44
|
+
- - "~>"
|
50
45
|
- !ruby/object:Gem::Version
|
51
46
|
version: '0.9'
|
52
47
|
- !ruby/object:Gem::Dependency
|
53
48
|
name: active_attr
|
54
49
|
requirement: !ruby/object:Gem::Requirement
|
55
|
-
none: false
|
56
50
|
requirements:
|
57
|
-
- - ~>
|
51
|
+
- - "~>"
|
58
52
|
- !ruby/object:Gem::Version
|
59
53
|
version: '0.8'
|
60
54
|
type: :runtime
|
61
55
|
prerelease: false
|
62
56
|
version_requirements: !ruby/object:Gem::Requirement
|
63
|
-
none: false
|
64
57
|
requirements:
|
65
|
-
- - ~>
|
58
|
+
- - "~>"
|
66
59
|
- !ruby/object:Gem::Version
|
67
60
|
version: '0.8'
|
68
61
|
- !ruby/object:Gem::Dependency
|
69
62
|
name: activemodel
|
70
63
|
requirement: !ruby/object:Gem::Requirement
|
71
|
-
none: false
|
72
64
|
requirements:
|
73
|
-
- -
|
65
|
+
- - ">="
|
74
66
|
- !ruby/object:Gem::Version
|
75
67
|
version: '3.2'
|
76
|
-
- - <
|
68
|
+
- - "<"
|
77
69
|
- !ruby/object:Gem::Version
|
78
70
|
version: '5'
|
79
71
|
type: :runtime
|
80
72
|
prerelease: false
|
81
73
|
version_requirements: !ruby/object:Gem::Requirement
|
82
|
-
none: false
|
83
74
|
requirements:
|
84
|
-
- -
|
75
|
+
- - ">="
|
85
76
|
- !ruby/object:Gem::Version
|
86
77
|
version: '3.2'
|
87
|
-
- - <
|
78
|
+
- - "<"
|
88
79
|
- !ruby/object:Gem::Version
|
89
80
|
version: '5'
|
90
81
|
- !ruby/object:Gem::Dependency
|
91
82
|
name: dirty_hashy
|
92
83
|
requirement: !ruby/object:Gem::Requirement
|
93
|
-
none: false
|
94
84
|
requirements:
|
95
|
-
- - ~>
|
85
|
+
- - "~>"
|
96
86
|
- !ruby/object:Gem::Version
|
97
87
|
version: 0.2.1
|
98
88
|
type: :runtime
|
99
89
|
prerelease: false
|
100
90
|
version_requirements: !ruby/object:Gem::Requirement
|
101
|
-
none: false
|
102
91
|
requirements:
|
103
|
-
- - ~>
|
92
|
+
- - "~>"
|
104
93
|
- !ruby/object:Gem::Version
|
105
94
|
version: 0.2.1
|
106
95
|
- !ruby/object:Gem::Dependency
|
107
96
|
name: rake
|
108
97
|
requirement: !ruby/object:Gem::Requirement
|
109
|
-
none: false
|
110
98
|
requirements:
|
111
|
-
- - ~>
|
99
|
+
- - "~>"
|
112
100
|
- !ruby/object:Gem::Version
|
113
101
|
version: '10.0'
|
114
102
|
type: :development
|
115
103
|
prerelease: false
|
116
104
|
version_requirements: !ruby/object:Gem::Requirement
|
117
|
-
none: false
|
118
105
|
requirements:
|
119
|
-
- - ~>
|
106
|
+
- - "~>"
|
120
107
|
- !ruby/object:Gem::Version
|
121
108
|
version: '10.0'
|
122
109
|
- !ruby/object:Gem::Dependency
|
123
110
|
name: rspec
|
124
111
|
requirement: !ruby/object:Gem::Requirement
|
125
|
-
none: false
|
126
112
|
requirements:
|
127
|
-
- -
|
113
|
+
- - ">="
|
128
114
|
- !ruby/object:Gem::Version
|
129
115
|
version: 2.14.1
|
130
|
-
- - <
|
116
|
+
- - "<"
|
131
117
|
- !ruby/object:Gem::Version
|
132
118
|
version: '4'
|
133
119
|
type: :development
|
134
120
|
prerelease: false
|
135
121
|
version_requirements: !ruby/object:Gem::Requirement
|
136
|
-
none: false
|
137
122
|
requirements:
|
138
|
-
- -
|
123
|
+
- - ">="
|
139
124
|
- !ruby/object:Gem::Version
|
140
125
|
version: 2.14.1
|
141
|
-
- - <
|
126
|
+
- - "<"
|
142
127
|
- !ruby/object:Gem::Version
|
143
128
|
version: '4'
|
144
129
|
- !ruby/object:Gem::Dependency
|
145
130
|
name: fakeweb
|
146
131
|
requirement: !ruby/object:Gem::Requirement
|
147
|
-
none: false
|
148
132
|
requirements:
|
149
|
-
- - ~>
|
133
|
+
- - "~>"
|
150
134
|
- !ruby/object:Gem::Version
|
151
135
|
version: '1.3'
|
152
136
|
type: :development
|
153
137
|
prerelease: false
|
154
138
|
version_requirements: !ruby/object:Gem::Requirement
|
155
|
-
none: false
|
156
139
|
requirements:
|
157
|
-
- - ~>
|
140
|
+
- - "~>"
|
158
141
|
- !ruby/object:Gem::Version
|
159
142
|
version: '1.3'
|
160
143
|
- !ruby/object:Gem::Dependency
|
161
144
|
name: guard-rspec
|
162
145
|
requirement: !ruby/object:Gem::Requirement
|
163
|
-
none: false
|
164
146
|
requirements:
|
165
|
-
- - ~>
|
147
|
+
- - "~>"
|
166
148
|
- !ruby/object:Gem::Version
|
167
149
|
version: '4.2'
|
168
|
-
- -
|
150
|
+
- - ">="
|
169
151
|
- !ruby/object:Gem::Version
|
170
152
|
version: 4.2.5
|
171
153
|
type: :development
|
172
154
|
prerelease: false
|
173
155
|
version_requirements: !ruby/object:Gem::Requirement
|
174
|
-
none: false
|
175
156
|
requirements:
|
176
|
-
- - ~>
|
157
|
+
- - "~>"
|
177
158
|
- !ruby/object:Gem::Version
|
178
159
|
version: '4.2'
|
179
|
-
- -
|
160
|
+
- - ">="
|
180
161
|
- !ruby/object:Gem::Version
|
181
162
|
version: 4.2.5
|
182
163
|
- !ruby/object:Gem::Dependency
|
183
164
|
name: rb-inotify
|
184
165
|
requirement: !ruby/object:Gem::Requirement
|
185
|
-
none: false
|
186
166
|
requirements:
|
187
|
-
- - ~>
|
167
|
+
- - "~>"
|
188
168
|
- !ruby/object:Gem::Version
|
189
169
|
version: '0.9'
|
190
170
|
type: :development
|
191
171
|
prerelease: false
|
192
172
|
version_requirements: !ruby/object:Gem::Requirement
|
193
|
-
none: false
|
194
173
|
requirements:
|
195
|
-
- - ~>
|
174
|
+
- - "~>"
|
196
175
|
- !ruby/object:Gem::Version
|
197
176
|
version: '0.9'
|
198
177
|
- !ruby/object:Gem::Dependency
|
199
178
|
name: coveralls
|
200
179
|
requirement: !ruby/object:Gem::Requirement
|
201
|
-
none: false
|
202
180
|
requirements:
|
203
|
-
- - ~>
|
181
|
+
- - "~>"
|
204
182
|
- !ruby/object:Gem::Version
|
205
183
|
version: '0.7'
|
206
184
|
type: :development
|
207
185
|
prerelease: false
|
208
186
|
version_requirements: !ruby/object:Gem::Requirement
|
209
|
-
none: false
|
210
187
|
requirements:
|
211
|
-
- - ~>
|
188
|
+
- - "~>"
|
212
189
|
- !ruby/object:Gem::Version
|
213
190
|
version: '0.7'
|
214
191
|
- !ruby/object:Gem::Dependency
|
215
192
|
name: simplecov
|
216
193
|
requirement: !ruby/object:Gem::Requirement
|
217
|
-
none: false
|
218
194
|
requirements:
|
219
|
-
- - ~>
|
195
|
+
- - "~>"
|
220
196
|
- !ruby/object:Gem::Version
|
221
197
|
version: '0.7'
|
222
198
|
type: :development
|
223
199
|
prerelease: false
|
224
200
|
version_requirements: !ruby/object:Gem::Requirement
|
225
|
-
none: false
|
226
201
|
requirements:
|
227
|
-
- - ~>
|
202
|
+
- - "~>"
|
228
203
|
- !ruby/object:Gem::Version
|
229
204
|
version: '0.7'
|
230
205
|
description: Use the Online Scout Manager API (https://www.onlinescoutmanager.co.uk)
|
@@ -235,9 +210,9 @@ executables: []
|
|
235
210
|
extensions: []
|
236
211
|
extra_rdoc_files: []
|
237
212
|
files:
|
238
|
-
- .gitignore
|
239
|
-
- .rspec
|
240
|
-
- .travis.yml
|
213
|
+
- ".gitignore"
|
214
|
+
- ".rspec"
|
215
|
+
- ".travis.yml"
|
241
216
|
- CHANGELOG.md
|
242
217
|
- Gemfile
|
243
218
|
- Guardfile
|
@@ -295,26 +270,25 @@ files:
|
|
295
270
|
homepage: https://github.com/robertgauld/osm
|
296
271
|
licenses:
|
297
272
|
- BSD 3 clause
|
273
|
+
metadata: {}
|
298
274
|
post_install_message:
|
299
275
|
rdoc_options: []
|
300
276
|
require_paths:
|
301
277
|
- lib
|
302
278
|
required_ruby_version: !ruby/object:Gem::Requirement
|
303
|
-
none: false
|
304
279
|
requirements:
|
305
|
-
- -
|
280
|
+
- - ">="
|
306
281
|
- !ruby/object:Gem::Version
|
307
282
|
version: '0'
|
308
283
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
309
|
-
none: false
|
310
284
|
requirements:
|
311
|
-
- -
|
285
|
+
- - ">="
|
312
286
|
- !ruby/object:Gem::Version
|
313
287
|
version: '0'
|
314
288
|
requirements: []
|
315
289
|
rubyforge_project: osm
|
316
|
-
rubygems_version:
|
290
|
+
rubygems_version: 2.5.1
|
317
291
|
signing_key:
|
318
|
-
specification_version:
|
292
|
+
specification_version: 4
|
319
293
|
summary: Use the Online Scout Manager API
|
320
294
|
test_files: []
|