Moved card stuff from users model to new card model
This commit is contained in:
37
app/views/cards/_form.html.erb
Normal file
37
app/views/cards/_form.html.erb
Normal file
@@ -0,0 +1,37 @@
|
||||
<%= form_for(@card) do |f| %>
|
||||
<% if @card.errors.any? %>
|
||||
<div id="error_explanation">
|
||||
<h2><%= pluralize(@card.errors.count, "error") %> prohibited this card from being saved:</h2>
|
||||
|
||||
<ul>
|
||||
<% @card.errors.full_messages.each do |msg| %>
|
||||
<li><%= msg %></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<div class="field">
|
||||
<%= f.label :user %><br />
|
||||
<%= collection_select(:card, :user_id, User.all.sort_by(&:name), :id, :name) %>
|
||||
</div>
|
||||
<div class="field">
|
||||
<%= f.label :name, "Card Note" %><br />
|
||||
<%= f.text_field :name %>
|
||||
</div>
|
||||
<div class="field">
|
||||
<%= f.label :id, "Card DB ID" %><br />
|
||||
<%= f.number_field :id, :in => 10...201 %>
|
||||
</div>
|
||||
<div class="field">
|
||||
<%= f.label :card_number, "Card Number" %><br />
|
||||
<%= f.text_field :card_number %>
|
||||
</div>
|
||||
<div class="field">
|
||||
<%= f.label :card_permissions %><br />
|
||||
<%= f.select :card_permissions, [["Enabled",1],["Disabled",255]] %>
|
||||
</div>
|
||||
<div class="actions">
|
||||
<%= f.submit %>
|
||||
</div>
|
||||
<% end %>
|
||||
6
app/views/cards/edit.html.erb
Normal file
6
app/views/cards/edit.html.erb
Normal file
@@ -0,0 +1,6 @@
|
||||
<h1>Editing card</h1>
|
||||
|
||||
<%= render 'form' %>
|
||||
|
||||
<%= link_to 'Show', @card %> |
|
||||
<%= link_to 'Back', cards_path %>
|
||||
34
app/views/cards/index.html.erb
Normal file
34
app/views/cards/index.html.erb
Normal file
@@ -0,0 +1,34 @@
|
||||
<h1>Listing cards</h1>
|
||||
|
||||
<%= link_to 'New Card', new_card_path %>
|
||||
<%= link_to 'Upload all cards', upload_all_path %>
|
||||
<table>
|
||||
<tr>
|
||||
<th>User</th>
|
||||
<th>Note</th>
|
||||
<th>DB ID</th>
|
||||
<th>Card #</th>
|
||||
<th>Access?</th>
|
||||
<th></th>
|
||||
<th></th>
|
||||
<th></th>
|
||||
</tr>
|
||||
|
||||
<% if !@cards.blank? %>
|
||||
<% @cards.each do |card| %>
|
||||
<tr>
|
||||
<td><%= card.user.name %></td>
|
||||
<td><%= card.name %></td>
|
||||
<td><%= card.id %></td>
|
||||
<td><%= card.card_number %></td>
|
||||
<td><%= if card.card_permissions == 1 then "Access" end %></td>
|
||||
<td><%= link_to 'Upload', upload_path(card) %></td>
|
||||
<td><%= link_to 'Edit', edit_card_path(card) %></td>
|
||||
<td><%= link_to 'Destroy', card, :confirm => 'Are you sure? WARNING: THIS DOES NOT REMOVE THE CARD FROM THE DOOR SYSTEM! DISABLE AND UPLOAD IT FIRST.', :method => :delete %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</table>
|
||||
|
||||
<br />
|
||||
|
||||
5
app/views/cards/new.html.erb
Normal file
5
app/views/cards/new.html.erb
Normal file
@@ -0,0 +1,5 @@
|
||||
<h1>New card</h1>
|
||||
|
||||
<%= render 'form' %>
|
||||
|
||||
<%= link_to 'Back', cards_path %>
|
||||
24
app/views/cards/show.html.erb
Normal file
24
app/views/cards/show.html.erb
Normal file
@@ -0,0 +1,24 @@
|
||||
|
||||
<p>
|
||||
<b>Name:</b>
|
||||
<%= @card.name %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<b>Card DB ID:</b>
|
||||
<%= @card.id %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<b>Card Number:</b>
|
||||
<%= @card.card_number %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<b>Card Permissions:</b>
|
||||
<%= @card.card_permissions %>
|
||||
</p>
|
||||
|
||||
<%= link_to 'Upload to Door', upload_path(@card) %>
|
||||
<%= link_to 'Edit', edit_card_path(@card) %> |
|
||||
<%= link_to 'Back', cards_path %>
|
||||
14
app/views/cards/upload.html.erb
Normal file
14
app/views/cards/upload.html.erb
Normal file
@@ -0,0 +1,14 @@
|
||||
|
||||
<% if @upload_result %>
|
||||
<p>
|
||||
<b>Upload result:</b>
|
||||
<%= @card.name %> uploaded successfully.
|
||||
</p>
|
||||
<% else %>
|
||||
<p>
|
||||
<b>Upload result:</b>
|
||||
Error uploading <%= @card.name %>.
|
||||
</p>
|
||||
<% end %>
|
||||
|
||||
<%= link_to 'Back', cards_path %>
|
||||
@@ -9,4 +9,4 @@
|
||||
</p>
|
||||
|
||||
|
||||
<%= link_to 'Back', users_path %>
|
||||
<%= link_to 'Back', cards_path %>
|
||||
@@ -8,7 +8,7 @@
|
||||
</head>
|
||||
<body>
|
||||
<div id="header">
|
||||
<%= link_to 'Users', users_path if user_signed_in? %>
|
||||
<%= link_to 'Cards', cards_path if user_signed_in? %>
|
||||
<%= link_to 'Logs', door_logs_path if user_signed_in? %>
|
||||
<%= link_to 'Sign out', destroy_user_session_path, :method => :delete if user_signed_in? %>
|
||||
<%= link_to 'Sign in', new_user_session_path unless user_signed_in? %>
|
||||
|
||||
@@ -1,55 +0,0 @@
|
||||
<%= 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 :card_id, "Card DB ID" %><br />
|
||||
<%= f.number_field :card_id, :in => 10...201 %>
|
||||
</div>
|
||||
<div class="field">
|
||||
<%= f.label :card_number, "Card Number" %><br />
|
||||
<%= f.text_field :card_number %>
|
||||
</div>
|
||||
<div class="field">
|
||||
<%= f.label :card_permissions %><br />
|
||||
<%= f.select :card_permissions, [["Enabled",1],["Disabled",255]] %>
|
||||
</div>
|
||||
<div class="field">
|
||||
<%= f.label :admin, "Admin?" %><br />
|
||||
<%= f.check_box :admin %>
|
||||
</div>
|
||||
<div class="actions">
|
||||
<%= f.submit %>
|
||||
</div>
|
||||
<% end %>
|
||||
@@ -1,6 +0,0 @@
|
||||
<h1>Editing user</h1>
|
||||
|
||||
<%= render 'form' %>
|
||||
|
||||
<%= link_to 'Show', @user %> |
|
||||
<%= link_to 'Back', users_path %>
|
||||
@@ -1,34 +0,0 @@
|
||||
<h1>Listing users</h1>
|
||||
|
||||
<%= link_to 'New User', new_user_path %>
|
||||
<%= link_to 'Upload all users', upload_all_path %>
|
||||
<table>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Card DB ID</th>
|
||||
<th>Card #</th>
|
||||
<th>Access?</th>
|
||||
<th>Admin?</th>
|
||||
<th></th>
|
||||
<th></th>
|
||||
<th></th>
|
||||
</tr>
|
||||
|
||||
<% if !@users.blank? %>
|
||||
<% @users.each do |user| %>
|
||||
<tr>
|
||||
<td><%= user.name %></td>
|
||||
<td><%= user.card_id %></td>
|
||||
<td><%= user.card_number %></td>
|
||||
<td><%= if user.card_permissions == 1 then "Access" end %></td>
|
||||
<td><%= if user.admin? then "Admin" end %></td>
|
||||
<td><%= link_to 'Upload', upload_path(user) %></td>
|
||||
<td><%= link_to 'Edit', edit_user_path(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 %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</table>
|
||||
|
||||
<br />
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
<h1>New user</h1>
|
||||
|
||||
<%= render 'form' %>
|
||||
|
||||
<%= link_to 'Back', users_path %>
|
||||
@@ -1,24 +0,0 @@
|
||||
|
||||
<p>
|
||||
<b>Name:</b>
|
||||
<%= @user.name %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<b>Card DB ID:</b>
|
||||
<%= @user.card_id %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<b>Card Number:</b>
|
||||
<%= @user.card_number %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<b>Card Permissions:</b>
|
||||
<%= @user.card_permissions %>
|
||||
</p>
|
||||
|
||||
<%= link_to 'Upload to Door', upload_path(@user) %>
|
||||
<%= link_to 'Edit', edit_user_path(@user) %> |
|
||||
<%= link_to 'Back', users_path %>
|
||||
@@ -1,14 +0,0 @@
|
||||
|
||||
<% if @upload_result %>
|
||||
<p>
|
||||
<b>Upload result:</b>
|
||||
<%= @user.name %> uploaded successfully.
|
||||
</p>
|
||||
<% else %>
|
||||
<p>
|
||||
<b>Upload result:</b>
|
||||
Error uploading <%= @user.name %>.
|
||||
</p>
|
||||
<% end %>
|
||||
|
||||
<%= link_to 'Back', users_path %>
|
||||
Reference in New Issue
Block a user