Permalink
Browse files

Add license display

  • Loading branch information...
1 parent 6e059ff commit b15493a11ce6da946c399a6ed8d809bfed461443 @marktabler committed Jun 10, 2013
Showing with 33 additions and 3 deletions.
  1. +5 −1 app/models/license.rb
  2. +11 −1 app/views/layouts/_nav.html.erb
  3. +17 −1 app/views/licenses/index.html.erb
View
@@ -5,10 +5,14 @@ class License < ActiveRecord::Base
def remaining
if capacity > 0
- capacity - active_licenses.count
+ capacity - used_count
else
999
end
end
+ def used_count
+ active_licenses.count
+ end
+
end
@@ -1 +1,11 @@
-<%= link_to "View Licenses", licenses_path %> | <%= link_to "View Assets", machines_path %>
+<table>
+ <tr>
+ <td><%= link_to "View Licenses", licenses_path %></td>
+ <td><%= link_to "View Assets", machines_path %></td>
+ <% if current_user.admin? %>
+ <td><%= link_to "Administer Licenses", licenses_path %></td>
+ <td><%= link_to "Administer Assets", machines_path %></td>
+ <td><%= link_to "Administer Users", licenses_path %></td>
+ <% end %>
+ </tr>
+</table>
@@ -1 +1,17 @@
-<h2>Licenses</h2>
+<h2>Licenses</h2>
+<table>
+ <tr>
+ <th>Name</th>
+ <th>Total</th>
+ <th>Used</th>
+ <th>Remaining</th>
+ </tr>
+ <% License.all.each do |license| %>
+ <tr>
+ <td><%= license.name %></td>
+ <td><%= license.capacity %></td>
+ <td><%= license.used_count %></td>
+ <td><%= license.remaining %></td>
+ </tr>
+ <% end %>
+</table>

0 comments on commit b15493a

Please sign in to comment.