Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nextcloud groups #66

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/models/group/federation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ class DispatchAddress < Jubla::Role::DispatchAddress

class ItSupport < Jubla::Role::Member
self.permissions = [:impersonation]
include Group::UniqueNextcloudGroup
kronn marked this conversation as resolved.
Show resolved Hide resolved
end

roles GroupAdmin, Alumnus, External, DispatchAddress, ItSupport
Expand Down
7 changes: 7 additions & 0 deletions app/models/group/flock.rb
Original file line number Diff line number Diff line change
Expand Up @@ -116,24 +116,29 @@ 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

# Leiter
class Guide < ::Role
self.permissions = [:layer_and_below_read]
include Group::UniqueNextcloudGroup
end

# Kassier
Expand All @@ -144,13 +149,15 @@ 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

# Betreuer
class Advisor < ::Role
self.permissions = [:layer_and_below_read]
include Group::UniqueNextcloudGroup
self.kind = nil
self.visible_from_above = false
end
Expand Down
1 change: 1 addition & 0 deletions app/models/group/state_board.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
21 changes: 21 additions & 0 deletions app/models/group/unique_nextcloud_group.rb
Original file line number Diff line number Diff line change
@@ -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}",
kronn marked this conversation as resolved.
Show resolved Hide resolved
"displayName" => "#{group.name} - #{self.class.model_name.human(count:2)}"
}
end
end
5 changes: 5 additions & 0 deletions app/models/jubla/role.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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?
Expand Down