Module: GroupMixins::Officers

Extended by:
ActiveSupport::Concern
Included in:
Group
Defined in:
app/models/group_mixins/officers.rb

Overview

This module contains the extensions of the Group model that concern officers groups.

Note that the majority of the officers functionality is handled by the Structureable model, since officers groups can be also assigned to Pages etc. and not only to Groups.

See:

* app/models/structureable_mixins/roles.rb
* app/models/structureable_mixins/has_special_groups.rb

Instance Method Summary collapse

Instance Method Details

#has_no_subgroups_other_than_the_officers_parent?Boolean

This method determines if the group has no subgroups other than the officers special group. This is used to determine whether the group is a status group.

Returns:

  • (Boolean)


21
22
23
24
25
26
27
28
29
# File 'app/models/group_mixins/officers.rb', line 21

def has_no_subgroups_other_than_the_officers_parent?
  #
  # TODO: Refactor this!
  #
  (self.child_groups - self.child_groups.where(name: ["Amtsträger", "officers"])).count == 0
  
  # (self.child_groups.count == 0) or
  #   ((self.child_groups.count == 1) and (self.child_groups.first.has_flag?(:officers_parent)))
end

#is_officers_group?Boolean

This method determines if the group is an officers group.

Returns:

  • (Boolean)


33
34
35
# File 'app/models/group_mixins/officers.rb', line 33

def is_officers_group?
  self.ancestor_groups.find_all_by_flag(:officers_parent).count > 0
end

#is_special_group?Boolean

This returns whether the group is special. This means that the group is special, e.g. an officers group

Returns:

  • (Boolean)


40
41
42
43
44
45
# File 'app/models/group_mixins/officers.rb', line 40

def is_special_group?
  self.has_flag?( :officers_parent ) or
  self.ancestor_groups.select do |ancestor|
    ancestor.has_flag?(:officers_parent)
  end.any?
end