Moved users into new admin-namespace and made the controller restful. Also moved some logic from the controller into the user-model (dry it up..).
This commit is contained in:
parent
47398c6a70
commit
461dfa8531
19 changed files with 242 additions and 94 deletions
|
|
@ -1,5 +0,0 @@
|
|||
<% form_tag(:action => 'createUser') do %>
|
||||
<%= render :partial => 'users/form' %>
|
||||
<p style="clear:both;">
|
||||
<%= submit_tag "Speichern" %> | <%= link_to_function('Abbrechen', 'Element.hide("newUser")')%></p>
|
||||
<% end %>
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
<h1>Benutzer bearbeiten</h1>
|
||||
<div id="newUser" style="width:65em">
|
||||
<div class="box_title"><h2>Benutzer_in bearbeiten</h2></div>
|
||||
<div class="column_content" id="userForm">
|
||||
<% form_tag(:action => 'updateUser', :id => @user) do %>
|
||||
<%= render :partial => 'users/form' %>
|
||||
<br style="clear:both" />
|
||||
<p>
|
||||
<%= submit_tag 'Speichern' %> | <%= link_to 'Abbrechen', :action => 'listUsers' %></p>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
<h1>Neuer Benutzer</h1>
|
||||
<div id="newUser">
|
||||
<div class="box_title"><h2>Neue_r Benutzer_in</h2></div>
|
||||
<div class="column_content" id="userForm">
|
||||
<% form_tag(:action => 'createUser') do %>
|
||||
<%= render :partial => 'users/form' %>
|
||||
<p style="clear:both;">
|
||||
<%= submit_tag "Speichern" %> | <%= link_to('Abbrechen', :action => 'listUsers')%></p>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
<p><%= link_to 'Benutzer_innenübersicht', :action => 'listUsers' %></p>
|
||||
|
||||
|
|
@ -25,15 +25,14 @@
|
|||
- roles << 'Artikel' if user.role_article_meta?
|
||||
- roles << 'Bestellung' if user.role_orders?
|
||||
%tr{:class => cycle('even','odd', :name => 'users')}
|
||||
%td= link_to user.nick, :action => 'showUser', :id => user
|
||||
%td= link_to user.nick, [:admin, user]
|
||||
%td=h user.first_name
|
||||
%td=h user.last_name
|
||||
%td=h user.email
|
||||
%td=h roles.join(', ')
|
||||
%td=h format_date_time(user.last_login)
|
||||
%td=h format_time(user.last_login)
|
||||
%td
|
||||
= link_to(image_tag('b_edit.png', :size => "16x16", :border => "0", :alt => 'Benutzer_in bearbeiten', :title => 'Benutzer_in bearbeiten'), :action => 'editUser', :id => user)
|
||||
= link_to(image_tag('b_edit.png', :size => "16x16", :border => "0", :alt => 'Benutzer_in bearbeiten', :title => 'Benutzer_in bearbeiten'), edit_admin_user_path(user))
|
||||
= link_to(image_tag('b_drop.png', :size => "16x16", :border => "0", :alt => 'Benutzer_in löschen', :title => 'Benutzer_in löschen'), |
|
||||
{:action => 'destroyUser', :id => user}, |
|
||||
:confirm => 'Willst du ' + user.first_name + ' wirklich löschen?', |
|
||||
:method => "post") |
|
||||
[:admin, user], |
|
||||
:confirm => 'Willst du ' + user.first_name + ' wirklich löschen?', :method => :delete) |
|
||||
12
app/views/admin/users/edit.html.erb
Normal file
12
app/views/admin/users/edit.html.erb
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
<h1>Benutzerin bearbeiten</h1>
|
||||
<div id="newUser" style="width:65em">
|
||||
<div class="box_title"><h2>Benutzerin bearbeiten</h2></div>
|
||||
<div class="column_content" id="userForm">
|
||||
<% form_for([:admin, @user]) do |@form| %>
|
||||
<%= render :partial => 'shared/user_form' %>
|
||||
<br style="clear:both" />
|
||||
<p>
|
||||
<%= submit_tag 'Speichern' %> | <%= link_to 'Abbrechen', admin_users_path %></p>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
%p
|
||||
%i
|
||||
Hier kannst du Benutzer_innen
|
||||
= link_to_remote 'neu Anlegen', :url => {:action => 'newUser'}
|
||||
= link_to 'neu Anlegen', new_admin_user_path
|
||||
, bearbeiten und natürlich auch löschen.
|
||||
#newUser{:style => "display:none;"}
|
||||
.box_title
|
||||
|
|
@ -20,9 +20,9 @@
|
|||
= observe_field 'query', :frequency => 2, |
|
||||
:before => "Element.show('loader')", |
|
||||
:success => "Element.hide('loader')", |
|
||||
:url => {:action => 'listUsers'}, |
|
||||
:with => 'query' |
|
||||
:url => admin_users_path, |
|
||||
:with => 'query', |
|
||||
:method => :get |
|
||||
#table
|
||||
= render :partial => "listUsers"
|
||||
- if @current_user.role_admin?
|
||||
%p= link_to 'Neue Benutzer_in', :action => 'newUser'
|
||||
= render :partial => "users"
|
||||
%p= link_to 'Neue Benutzerin', new_admin_user_path
|
||||
13
app/views/admin/users/new.html.haml
Normal file
13
app/views/admin/users/new.html.haml
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
- title "Neue Benutzerin"
|
||||
|
||||
#newUser
|
||||
.box_title
|
||||
%h2 Neue Benutzerin
|
||||
.column_content#userForm
|
||||
- form_for([:admin, @user]) do |@form|
|
||||
= render :partial => 'shared/user_form'
|
||||
%p{:style => "clear:both" }
|
||||
= submit_tag "Speichern"
|
||||
|
|
||||
= link_to('Abbrechen', admin_users_path )
|
||||
%p= link_to 'Benutzerinnenübersicht', admin_users_path
|
||||
|
|
@ -1,12 +1,14 @@
|
|||
<h1><%=h @user.nick %></h1>
|
||||
<div class="left_column" style="width:100%">
|
||||
<div class="box_title"><h2>Übersicht</h2></div>
|
||||
<div class="box_title">
|
||||
<h2>Übersicht</h2>
|
||||
</div>
|
||||
<div class="column_content">
|
||||
<%= render :partial => 'users/show'%>
|
||||
<p style="clear:both">
|
||||
<%= link_to 'Bearbeiten', :action => 'editUser', :id => @user %>
|
||||
| <%= link_to 'Löschen', { :action => 'destroyUser', :id => @user }, :confirm => 'Willst du ' + @user.first_name + ' wirklich rausschmeißen?', :method => "post" %>
|
||||
| <%= link_to 'Nachricht senden', :controller => 'messages', :action => 'user', :id => @user %>
|
||||
<%= link_to 'Bearbeiten', edit_admin_user_path(@user) %>
|
||||
| <%= link_to 'Löschen', [:admin, @user], :confirm => "Willst du #{@user.first_name} wirklich rausschmeißen?", :method => :delete %>
|
||||
| <%= link_to 'Nachricht senden', :controller => 'messages', :action => 'user', :id => @user %>
|
||||
</p>
|
||||
</div>
|
||||
<div class="box_title"><h2>Gruppenabos</h2></div>
|
||||
|
|
@ -26,7 +26,8 @@
|
|||
{ :name => "Suppliers", :url => suppliers_path, :access? => (u.role_suppliers?) }
|
||||
]
|
||||
},
|
||||
{ :name => "Finance", :url => "/finance", :active => ["finance", "invoices", "transactions", "balancing"],
|
||||
{ :name => "Finance", :url => "/finance",
|
||||
:active => ["finance", "finance/invoices", "finance/transactions", "finance/balancing"],
|
||||
:access? => (u.role_finance?),
|
||||
:subnav => [
|
||||
{ :name => "Manage accounts", :url => "/finance/transactions" },
|
||||
|
|
@ -34,10 +35,11 @@
|
|||
{ :name => "Invoices", :url => finance_invoices_path }
|
||||
]
|
||||
},
|
||||
{ :name => "Administration", :url => "/admin", :active => ["admin"],
|
||||
{ :name => "Administration", :url => "/admin",
|
||||
:active => ["admin", "admin/users"],
|
||||
:access? => (u.role_admin?),
|
||||
:subnav => [
|
||||
{ :name => "Users", :url => "/admin/listUsers" },
|
||||
{ :name => "Users", :url => "/admin/users" },
|
||||
{ :name => "Groups", :url => "/admin/listGroups" }
|
||||
]
|
||||
}
|
||||
|
|
|
|||
50
app/views/shared/_user_form.rhtml
Normal file
50
app/views/shared/_user_form.rhtml
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
<%= @form.error_messages %>
|
||||
|
||||
<table style="float:left;width:52%;">
|
||||
<tr>
|
||||
<td><%= @form.label :nick %></td>
|
||||
<td><%= @form.text_field :nick %></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><%= @form.label :first_name %></td>
|
||||
<td><%= @form.text_field :first_name %></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><%= @form.label :last_name %></td>
|
||||
<td><%= @form.text_field :last_name %></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><%= @form.label :email %></td>
|
||||
<td><%= @form.text_field :email %></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><%= @form.label :phone %></td>
|
||||
<td><%= @form.text_field :phone %></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><%= @form.label :address %></td>
|
||||
<td><%= @form.text_field :address %></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td/>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><%= @form.label :password, "Password" %></td>
|
||||
<td><%= @form.password_field :password %></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><%= @form.label :password_confirmation, "Password confirmation" %></td>
|
||||
<td><%= @form.password_field :password_confirmation %></td>
|
||||
</tr>
|
||||
</table>
|
||||
<table style="float:right;width:45%;">
|
||||
<tr>
|
||||
<td colspan="2"><b>Einstellungen:</b></td>
|
||||
</tr>
|
||||
<% for setting in User::setting_keys.keys -%>
|
||||
<tr>
|
||||
<td><label for="user[setting_attributes][<%= setting %>]"><%=h User::setting_keys[setting]%></label></td>
|
||||
<td><%= check_box_tag "user[setting_attributes][#{setting}]", '1', @user.settings[setting] == '1' || @user.settings_default(setting) %></td>
|
||||
</tr>
|
||||
<% end -%>
|
||||
</table>
|
||||
|
|
@ -29,12 +29,12 @@
|
|||
<td/>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><label for="user[password]">Neues Passwort</label></td>
|
||||
<td><%= password_field_tag "user[password]" %></td>
|
||||
<td><label for="user_password_entry">Neues Passwort</label></td>
|
||||
<td><%= password_field_tag "user", "password_entry" %></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><label for="user[password_confirmation]">Passwort wiederholen</label></td>
|
||||
<td><%= password_field_tag "user[password_confirmation]" %></td>
|
||||
<td><label for="user_password_entry_confirmation">Passwort wiederholen</label></td>
|
||||
<td><%= password_field_tag "user", "password_entry_confirmation" %></td>
|
||||
</tr>
|
||||
</table>
|
||||
<table style="float:right;width:45%;">
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue