Recreated user forms, updated abilities, linked cards and users
This commit is contained in:
51
app/views/users/_form.html.erb
Normal file
51
app/views/users/_form.html.erb
Normal file
@@ -0,0 +1,51 @@
|
||||
<%= form_for(@user) do |f| %>
|
||||
<% if @user.errors.any? %>
|
||||
<div id="error_explanation">
|
||||
<h2><%= pluralize(@user.errors.count, "error") %> prohibited this user from being saved:</h2>
|
||||
|
||||
<ul>
|
||||
<% @user.errors.full_messages.each do |msg| %>
|
||||
<li><%= msg %></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<div class="field">
|
||||
<%= f.label :name %><br />
|
||||
<%= f.text_field :name %>
|
||||
</div>
|
||||
<div class="field">
|
||||
<%= f.label :email %><br />
|
||||
<%= f.email_field :email %>
|
||||
</div>
|
||||
<% if @user.id.blank? || !params[:password].nil? %>
|
||||
<div class="field">
|
||||
<%= f.label :password %><br />
|
||||
<%= f.password_field :password, :autocomplete => "off" %>
|
||||
</div>
|
||||
<div class="field">
|
||||
<%= f.label :password_confirmation %><br />
|
||||
<%= f.password_field :password_confirmation %>
|
||||
</div>
|
||||
<% else %>
|
||||
<div class="field">
|
||||
<a href="?password=edit">Change Password</a>
|
||||
</div>
|
||||
<% end %>
|
||||
<div class="field">
|
||||
<%= f.label :admin, "Admin?" %><br />
|
||||
<%= f.check_box :admin %>
|
||||
</div>
|
||||
<div class="field">
|
||||
<h3>Cards</h3>
|
||||
<ul>
|
||||
<% @user.cards.each do |c| %>
|
||||
<li><%= link_to "#{c.card_number} #{c.name}", card_url(c) %></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="actions">
|
||||
<%= f.submit %>
|
||||
</div>
|
||||
<% end %>
|
||||
6
app/views/users/edit.html.erb
Normal file
6
app/views/users/edit.html.erb
Normal file
@@ -0,0 +1,6 @@
|
||||
<h1>Editing user</h1>
|
||||
|
||||
<%= render 'form' %>
|
||||
|
||||
<%= link_to 'Show', @user %> |
|
||||
<%= link_to 'Back', users_path %>
|
||||
34
app/views/users/index.html.erb
Normal file
34
app/views/users/index.html.erb
Normal file
@@ -0,0 +1,34 @@
|
||||
<h1>Listing users</h1>
|
||||
|
||||
<% if can? :create, User %>
|
||||
<%= link_to 'New User', new_user_path %>
|
||||
<% end %>
|
||||
<table>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Email</th>
|
||||
<th>Cards</th>
|
||||
<th>Admin?</th>
|
||||
<th></th>
|
||||
<th></th>
|
||||
</tr>
|
||||
|
||||
<% if !@users.blank? %>
|
||||
<% @users.each do |user| %>
|
||||
<tr>
|
||||
<td><%= user.name %></td>
|
||||
<td><%= user.email %></td>
|
||||
<td>
|
||||
<% user.cards.each do |c| %>
|
||||
<%= link_to c.card_number, card_url(c) %><%= "," unless c == user.cards.last %>
|
||||
<% end %>
|
||||
</td>
|
||||
<td><%= if user.admin? then "Admin" end %></td>
|
||||
<td><%= link_to 'Edit', edit_user_path(user) if can? :update, user %></td>
|
||||
<td><%= link_to 'Destroy', user, :confirm => 'Are you sure? WARNING: THIS DOES NOT REMOVE THE USER FROM THE DOOR SYSTEM! DISABLE THEM FIRST.', :method => :delete if can? :destroy, user %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</table>
|
||||
|
||||
<br />
|
||||
5
app/views/users/new.html.erb
Normal file
5
app/views/users/new.html.erb
Normal file
@@ -0,0 +1,5 @@
|
||||
<h1>New user</h1>
|
||||
|
||||
<%= render 'form' %>
|
||||
|
||||
<%= link_to 'Back', users_path %>
|
||||
18
app/views/users/show.html.erb
Normal file
18
app/views/users/show.html.erb
Normal file
@@ -0,0 +1,18 @@
|
||||
|
||||
<p>
|
||||
<b>Name:</b>
|
||||
<%= @user.name %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<b>Email:</b>
|
||||
<%= @user.email %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<b>Admin?</b>
|
||||
<%= @user.admin %>
|
||||
</p>
|
||||
|
||||
<%= link_to 'Edit', edit_user_path(@user) %> |
|
||||
<%= link_to 'Back', users_path %>
|
||||
Reference in New Issue
Block a user