Commit f142891e9d09d1001a2de0356f30466654273d3a
1 parent
f285ecc3
Exists in
master
and in
29 other branches
ActionItem5: interface to manage roles functional
git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@483 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing
6 changed files
with
19 additions
and
7 deletions
Show diff stats
app/controllers/role_controller.rb
@@ -8,7 +8,7 @@ class RoleController < ApplicationController | @@ -8,7 +8,7 @@ class RoleController < ApplicationController | ||
8 | end | 8 | end |
9 | 9 | ||
10 | def new | 10 | def new |
11 | - @role = Role.new(:name => 'bla', :permissions => []) | 11 | + @role = Role.new(:name => '', :permissions => []) |
12 | end | 12 | end |
13 | 13 | ||
14 | def create | 14 | def create |
app/models/role.rb
@@ -11,9 +11,8 @@ class Role < ActiveRecord::Base | @@ -11,9 +11,8 @@ class Role < ActiveRecord::Base | ||
11 | } | 11 | } |
12 | 12 | ||
13 | def self.permission_name(p) | 13 | def self.permission_name(p) |
14 | -# msgid = ... | ||
15 | -# gettext(msgid) | ||
16 | - raise "Moises need to write me" | 14 | + msgid = PERMISSIONS.values.inject({}){|s,v| s.merge(v)}[p] |
15 | + gettext(msgid) | ||
17 | end | 16 | end |
18 | 17 | ||
19 | has_many :role_assignments | 18 | has_many :role_assignments |
app/views/role/_form.rhtml
1 | <%= error_messages_for :role %> | 1 | <%= error_messages_for :role %> |
2 | 2 | ||
3 | -<% labelled_form_for :role, @role do |f| %> | 3 | +<% labelled_form_for :role, @role, :url => (mode == :edit) ? {:action => 'update', :id => role} : {:action => 'create'} do |f| %> |
4 | 4 | ||
5 | <%= f.text_field :name %> | 5 | <%= f.text_field :name %> |
6 | 6 | ||
7 | <%= _('Permissions: ') %> <br> | 7 | <%= _('Permissions: ') %> <br> |
8 | <% Role::PERMISSIONS[:profile].keys.each do |p| %> | 8 | <% Role::PERMISSIONS[:profile].keys.each do |p| %> |
9 | - <%= labelled_form_field("bla", (check_box_tag "role[permissions][#{p}]", @role.has_permission?(p))) %> | 9 | + <%= labelled_form_field(Role.permission_name(p), (check_box_tag "role[permissions][]", p, @role.has_permission?(p))) %> |
10 | <% end %> | 10 | <% end %> |
11 | + | ||
12 | + <%= submit_tag (mode == :edit) ? _('Save changes') : _('Create role')%> | ||
11 | <% end %> | 13 | <% end %> |
app/views/role/index.rhtml
@@ -4,7 +4,7 @@ | @@ -4,7 +4,7 @@ | ||
4 | <li> | 4 | <li> |
5 | <%= link_to role.name, :action => 'show', :id => role %> | 5 | <%= link_to role.name, :action => 'show', :id => role %> |
6 | <%= link_to _('Edit'), :action => 'edit', :id => role %> | 6 | <%= link_to _('Edit'), :action => 'edit', :id => role %> |
7 | - <%= link_to _('Destroy'), :action => 'destoy', :id => role %> | 7 | + <%= link_to _('Destroy'), :action => 'destroy', :id => role %> |
8 | </li> | 8 | </li> |
9 | <% end %> | 9 | <% end %> |
10 | </ul> | 10 | </ul> |