diff --git a/app/models/group/federation.rb b/app/models/group/federation.rb index 79e8c373..5574d722 100644 --- a/app/models/group/federation.rb +++ b/app/models/group/federation.rb @@ -86,6 +86,7 @@ class DispatchAddress < Jubla::Role::DispatchAddress class ItSupport < Jubla::Role::Member self.permissions = [:impersonation] + include Group::UniqueNextcloudGroup end roles GroupAdmin, Alumnus, External, DispatchAddress, ItSupport diff --git a/app/models/group/flock.rb b/app/models/group/flock.rb index f2c50325..d0d812fc 100644 --- a/app/models/group/flock.rb +++ b/app/models/group/flock.rb @@ -116,17 +116,21 @@ def population_approveable? current_census && !MemberCounter.new(current_census.year, self).exists? end + # Scharleitung class Leader < Jubla::Role::Leader self.permissions = [:layer_and_below_full, :contact_data, :approve_applications] end + # Lagerleitung class CampLeader < ::Role self.permissions = [:layer_and_below_full, :contact_data] + include Group::UniqueNextcloudGroup end # Präses class President < ::Role self.permissions = [:layer_and_below_read, :contact_data] + include Group::UniqueNextcloudGroup self.used_attributes += [:employment_percent, :honorary] end @@ -134,6 +138,7 @@ class President < ::Role # Leiter class Guide < ::Role self.permissions = [:layer_and_below_read] + include Group::UniqueNextcloudGroup end # Kassier @@ -144,6 +149,7 @@ class Treasurer < Jubla::Role::Treasurer # Coach class Coach < ::Role self.permissions = [:layer_and_below_read] + include Group::UniqueNextcloudGroup self.kind = nil self.visible_from_above = false end @@ -151,6 +157,7 @@ class Coach < ::Role # Betreuer class Advisor < ::Role self.permissions = [:layer_and_below_read] + include Group::UniqueNextcloudGroup self.kind = nil self.visible_from_above = false end diff --git a/app/models/group/state_board.rb b/app/models/group/state_board.rb index 225d0129..9f6f763e 100644 --- a/app/models/group/state_board.rb +++ b/app/models/group/state_board.rb @@ -58,6 +58,7 @@ class President < Member # Stellenbegleitung class Supervisor < ::Role self.permissions = [:layer_and_below_read] + include Group::UniqueNextcloudGroup end class GroupAdmin < Jubla::Role::GroupAdmin diff --git a/app/models/group/unique_nextcloud_group.rb b/app/models/group/unique_nextcloud_group.rb new file mode 100644 index 00000000..ec0d6f90 --- /dev/null +++ b/app/models/group/unique_nextcloud_group.rb @@ -0,0 +1,21 @@ +# encoding: utf-8 + +# Copyright (c) 2012-2023, Jungwacht Blauring Schweiz. This file is part of +# hitobito and licensed under the Affero General Public License version 3 +# or later. See the COPYING file at the top-level directory or at +# https://github.com/hitobito/hitobito. + +module Group::UniqueNextcloudGroup + extend ActiveSupport::Concern + + included do + self.nextcloud_group = :calculate_nextcloud_group + end + + def calculate_nextcloud_group + { + "gid" => "#{group_id.to_s}_#{self.type}", + "displayName" => "#{group.name} - #{self.class.model_name.human(count:2)}" + } + end +end diff --git a/app/models/jubla/role.rb b/app/models/jubla/role.rb index 041403c4..a4162a80 100644 --- a/app/models/jubla/role.rb +++ b/app/models/jubla/role.rb @@ -51,6 +51,7 @@ def roles_in_layer(person_id, layer_group_id) # Adressverwaltung class GroupAdmin < ::Role self.permissions = [:group_full] + include Group::UniqueNextcloudGroup end # Versandadresse. Intended to be used with mailing lists @@ -73,20 +74,24 @@ class Alumnus < ::Role # Common superclass for all J+S Coach roles class Coach < ::Role self.permissions = [:contact_data, :group_read] + include Group::UniqueNextcloudGroup end # Common superclass for all leader roles # Primarly used for common naming class Leader < ::Role + include Group::UniqueNextcloudGroup end # Common superclass for all member roles # Primarly used for common naming class Member < ::Role + include Group::UniqueNextcloudGroup end # Common superclass for all treasurer roles class Treasurer < ::Role + include Group::UniqueNextcloudGroup end def alumnus_group_member?