Class: ExamRegistration
Defined Under Namespace
Classes: AuthorizationCriterion
Instance Method Summary
collapse
#friendly, #navigable_name, #navigation_end?, #next_for, #siblings, #structural_parent
#enabled?, #enabled_range
active_between, aggregate_of, all_except, defaults, #delete, #destroy!, enum_prefixed_translations_for, numbered, organic_on, resource_fields, #save, #save_and_notify!, #save_and_notify_changes!, serialize_symbolized_hash_array, teaser_on, #update_and_notify!, update_or_create!, whitelist_attributes, with_temporary_token
Instance Method Details
#authorization_criterion ⇒ Object
19
20
21
|
# File 'app/models/exam_registration.rb', line 19
def authorization_criterion
@authorization_criterion ||= ExamRegistration::AuthorizationCriterion.parse(authorization_criterion_type, authorization_criterion_value)
end
|
#authorization_request_for(user) ⇒ Object
50
51
52
53
|
# File 'app/models/exam_registration.rb', line 50
def authorization_request_for(user)
authorization_requests.find_by(user: user) ||
ExamAuthorizationRequest.new(exam_registration: self, organization: organization)
end
|
#ensure_valid_authorization_criterion! ⇒ Object
23
24
25
|
# File 'app/models/exam_registration.rb', line 23
def ensure_valid_authorization_criterion!
authorization_criterion.ensure_valid!
end
|
#notify_unnotified_registrees! ⇒ Object
27
28
29
|
# File 'app/models/exam_registration.rb', line 27
def notify_unnotified_registrees!
unnotified_registrees.each { |registree| notify_registree! registree }
end
|
#process_requests! ⇒ Object
43
44
45
46
47
48
|
# File 'app/models/exam_registration.rb', line 43
def process_requests!
authorization_requests.each do |it|
process_request! it
it.try_authorize!
end
end
|
#register!(user) ⇒ Object
55
56
57
|
# File 'app/models/exam_registration.rb', line 55
def register!(user)
registrees << user unless registered?(user)
end
|
#register_users!(users) ⇒ Object
35
36
37
|
# File 'app/models/exam_registration.rb', line 35
def register_users!(users)
users.each { |user| register! user }
end
|
#registered?(user) ⇒ Boolean
59
60
61
|
# File 'app/models/exam_registration.rb', line 59
def registered?(user)
registrees.include? user
end
|
#unnotified_registrees ⇒ Object
39
40
41
|
# File 'app/models/exam_registration.rb', line 39
def unnotified_registrees
registrees.where.not(id: Notification.notified_users_ids_for(self, self.organization))
end
|
#unnotified_registrees? ⇒ Boolean
31
32
33
|
# File 'app/models/exam_registration.rb', line 31
def unnotified_registrees?
unnotified_registrees.exists?
end
|