-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b7c09a0
commit 3cc99ce
Showing
4 changed files
with
45 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,20 @@ | ||
class Admin::LicensesController < ApplicationController | ||
|
||
before_filter :admin_required | ||
|
||
|
||
def edit | ||
@license = License.find(params[:id]) | ||
end | ||
|
||
def update | ||
@license = License.find(params[:id]) | ||
@license.update_attributes(license_params) | ||
return redirect_to admin_licenses_path | ||
end | ||
|
||
private | ||
|
||
def license_params | ||
params.require(:license).permit(:name, :capacity) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<%= form_for @license, url: admin_license_path(@license), method: :put do |f| %> | ||
<%= f.label :name %> | ||
<%= f.text_field :name %> | ||
<%= f.label :capacity %> | ||
<%= f.text_field :capacity %> | ||
<%= f.submit %> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<h2>Administer Licenses</h2> | ||
<table> | ||
<tr> | ||
<th>Name</th> | ||
<th>Total</th> | ||
<th>Used</th> | ||
<th>Remaining</th> | ||
<th>Delete</th> | ||
</tr> | ||
<% License.all.each do |license| %> | ||
<tr> | ||
<td><%= link_to license.name, edit_admin_license_path(license) %></td> | ||
<td><%= license.capacity %></td> | ||
<td><%= license.used_count %></td> | ||
<td><%= license.remaining %></td> | ||
<td><%= link_to "Delete", admin_license_path(license), method: :delete, data: { confirm: "Delete #{license.name} and all installation records? This action cannot be undone."} %></td> | ||
</tr> | ||
<% end %> | ||
</table> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters