Class: Term
Constant Summary
collapse
- GENERAL =
%w(legal privacy student)
- ROLE_SPECIFIC =
%w(headmaster janitor teacher moderator)
- FORUM_RELATED =
%w(forum)
Class Method Summary
collapse
Instance Method Summary
collapse
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_pg_retry, with_temporary_token
Methods included from WithPgLock
#with_pg_lock
Class Method Details
.current_role_terms_for(user) ⇒ Object
32
33
34
35
|
# File 'app/models/term.rb', line 32
def self.current_role_terms_for(user)
return [] unless user.present?
(user.any_granted_roles & ROLE_SPECIFIC).to_a
end
|
28
29
30
|
# File 'app/models/term.rb', line 28
def self.forum_related_terms(locale = I18n.locale)
terms_for(FORUM_RELATED, locale)
end
|
.general_terms(locale = I18n.locale) ⇒ Object
24
25
26
|
# File 'app/models/term.rb', line 24
def self.general_terms(locale = I18n.locale)
terms_for(GENERAL, locale)
end
|
.profile_terms_for(user, locale = I18n.locale) ⇒ Object
16
17
18
|
# File 'app/models/term.rb', line 16
def self.profile_terms_for(user, locale = I18n.locale)
general_terms(locale) + role_specific_terms_for(user, locale)
end
|
.role_specific_terms_for(user, locale = I18n.locale) ⇒ Object
20
21
22
|
# File 'app/models/term.rb', line 20
def self.role_specific_terms_for(user, locale = I18n.locale)
terms_for(current_role_terms_for(user), locale)
end
|
.terms_for(scope, locale) ⇒ Object
12
13
14
|
# File 'app/models/term.rb', line 12
def self.terms_for(scope, locale)
where(scope: scope, locale: locale)
end
|
Instance Method Details
#accepted_by?(user) ⇒ Boolean
37
38
39
|
# File 'app/models/term.rb', line 37
def accepted_by?(user)
user.term_accepted_at_for(scope).try { |it| it > updated_at }.present?
end
|