diff --git a/db/seeds.rb b/db/seeds.rb new file mode 100644 index 0000000000..dc8d7a5707 --- /dev/null +++ b/db/seeds.rb @@ -0,0 +1 @@ +OpenProject::Meeting::DefaultData.load! unless Rails.env.test? diff --git a/lib/open_project/meeting/default_data.rb b/lib/open_project/meeting/default_data.rb new file mode 100644 index 0000000000..286d2a26d4 --- /dev/null +++ b/lib/open_project/meeting/default_data.rb @@ -0,0 +1,42 @@ +module OpenProject + module Meeting + module DefaultData + module_function + + def load! + add_permissions! member_role, member_permissions || raise('Member role not found') + add_permissions! reader_role, reader_permissions || raise('Reader role not found') + end + + def add_permissions!(role, permissions) + role.add_permission! *permissions + end + + def member_role + Role.find_by name: I18n.t(:default_role_member) + end + + def member_permissions + [ + :create_meetings, + :edit_meetings, + :delete_meetings, + :view_meetings, + :create_meeting_agendas, + :close_meeting_agendas, + :send_meeting_agendas_notification, + :create_meeting_minutes, + :send_meeting_minutes_notification + ] + end + + def reader_role + Role.find_by name: I18n.t(:default_role_reader) + end + + def reader_permissions + [:view_meetings] + end + end + end +end