Class: Organization
- Inherits:
-
ApplicationRecord
show all
- Includes:
- Mumukit::Platform::Organization::Helpers
- Defined in:
- app/models/organization.rb
Class Method Summary
collapse
Instance Method Summary
collapse
aggregate_of, all_except, defaults, name_model_as, numbered, #save, #save_and_notify!, #save_and_notify_changes!, #update_and_notify!, update_or_create!
Class Method Details
98
99
100
|
# File 'app/models/organization.rb', line 98
def base
find_by name: 'base'
end
|
94
95
96
|
# File 'app/models/organization.rb', line 94
def central
find_by name: 'central'
end
|
Instance Method Details
#accessible_exams_for(user) ⇒ Object
71
72
73
|
# File 'app/models/organization.rb', line 71
def accessible_exams_for(user)
exams.select { |exam| exam.accessible_for?(user) }
end
|
#drop_usage_indices! ⇒ Object
63
64
65
|
# File 'app/models/organization.rb', line 63
def drop_usage_indices!
usages.destroy_all
end
|
#explain_error(code, advice) ⇒ Object
79
80
81
|
# File 'app/models/organization.rb', line 79
def explain_error(code, advice)
errors_explanations.try { |it| it[code.to_s] } || I18n.t(advice)
end
|
#has_login_method?(login_method) ⇒ Boolean
75
76
77
|
# File 'app/models/organization.rb', line 75
def has_login_method?(login_method)
self.login_methods.include? login_method.to_s
end
|
#in_path?(item) ⇒ Boolean
38
39
40
|
# File 'app/models/organization.rb', line 38
def in_path?(item)
usages.exists?(item: item) || usages.exists?(parent_item: item)
end
|
#index_usage_of!(item, parent) ⇒ Object
67
68
69
|
# File 'app/models/organization.rb', line 67
def index_usage_of!(item, parent)
Usage.create! organization: self, item: item, parent_item: parent
end
|
#notify_assignments_by!(submitter) ⇒ Object
46
47
48
|
# File 'app/models/organization.rb', line 46
def notify_assignments_by!(submitter)
notify_assignments! assignments.where(submitter_id: submitter.id)
end
|
#notify_recent_assignments!(date) ⇒ Object
42
43
44
|
# File 'app/models/organization.rb', line 42
def notify_recent_assignments!(date)
notify_assignments! assignments.where('assignments.updated_at > ?', date)
end
|
#reindex_usages! ⇒ Object
54
55
56
57
58
59
60
61
|
# File 'app/models/organization.rb', line 54
def reindex_usages!
transaction do
drop_usage_indices!
book.index_usage! self
exams.each { |exam| exam.index_usage! self }
end
reload
end
|
#silent? ⇒ Boolean
50
51
52
|
# File 'app/models/organization.rb', line 50
def silent?
test?
end
|