summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Wintermeyer <stefan.wintermeyer@amooma.de>2013-01-24 14:09:31 +0100
committerStefan Wintermeyer <stefan.wintermeyer@amooma.de>2013-01-24 14:09:31 +0100
commite024c99b6ffeb725cf73ebf8b7b55957f36772f5 (patch)
tree36ce89c477055f33245a62f8455a4af5eb27a8de
parentea3df5a7eb079982a8fcda3df572a0d1433b7f52 (diff)
A new user becomes a member of default UserGroups.
-rw-r--r--app/models/user.rb10
-rw-r--r--app/views/user_groups/_index_core.html.haml4
-rw-r--r--config/locales/views/users/de.yml2
-rw-r--r--db/migrate/20130124125238_add_default_user_groups_for_new_users.rb9
-rw-r--r--db/schema.rb2
5 files changed, 21 insertions, 6 deletions
diff --git a/app/models/user.rb b/app/models/user.rb
index b902b99..9e8cbc0 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -95,6 +95,8 @@ class User < ActiveRecord::Base
before_destroy :destroy_or_logout_phones
+ after_save :become_a_member_of_default_user_groups
+
def destroy
clean_whitelist_entries
super
@@ -207,4 +209,12 @@ class User < ActiveRecord::Base
end
end
+ # Normaly a new user should become a member of default user groups.
+ #
+ def become_a_member_of_default_user_groups
+ UserGroup.where(:id => GsParameter.get('DEFAULT_USER_GROUPS_IDS')).each do |user_group|
+ user_group.user_group_memberships.create(:user_id => self.id)
+ end
+ end
+
end
diff --git a/app/views/user_groups/_index_core.html.haml b/app/views/user_groups/_index_core.html.haml
index c481a18..aa1497e 100644
--- a/app/views/user_groups/_index_core.html.haml
+++ b/app/views/user_groups/_index_core.html.haml
@@ -29,9 +29,5 @@
- else
%td
=render 'users/listing', :users => user_group.users
- - if user_group.users.any?
- %br
- - if (user_group.tenant.user_ids - user_group.user_ids).any?
- = render :partial => 'shared/create_link', :locals => {:parent => user_group, :child_class => UserGroupMembership}
=render :partial => 'shared/index_view_edit_destroy_part', :locals => {:parent => user_group.tenant, :child => user_group}
diff --git a/config/locales/views/users/de.yml b/config/locales/views/users/de.yml
index 40b64c1..7cdaf68 100644
--- a/config/locales/views/users/de.yml
+++ b/config/locales/views/users/de.yml
@@ -24,7 +24,7 @@ de:
destroy: 'Löschen'
edit: 'Bearbeiten'
show: 'Anzeigen'
- create: 'Neue anlegen'
+ create: 'Neu anlegen'
create_for: 'Neuen User für %{resource} anlegen'
show:
page_title: 'User anzeigen'
diff --git a/db/migrate/20130124125238_add_default_user_groups_for_new_users.rb b/db/migrate/20130124125238_add_default_user_groups_for_new_users.rb
new file mode 100644
index 0000000..d2700d6
--- /dev/null
+++ b/db/migrate/20130124125238_add_default_user_groups_for_new_users.rb
@@ -0,0 +1,9 @@
+class AddDefaultUserGroupsForNewUsers < ActiveRecord::Migration
+ def up
+ GsParameter.create(:name => 'DEFAULT_USER_GROUPS_IDS', :section => 'New user defaults', :value => "---\n- 3\n", :class_type => 'YAML', :description => 'Default user group ids for a new user.')
+ end
+
+ def down
+ GsParameter.where(:name => 'DEFAULT_USER_GROUPS_IDS').destroy_all
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 6365e6d..8258394 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20130124123128) do
+ActiveRecord::Schema.define(:version => 20130124125238) do
create_table "access_authorizations", :force => true do |t|
t.string "access_authorizationable_type"