fixes #143: Janitor trials issues
This commit is contained in:
@@ -19,18 +19,22 @@ class JanitorTrialsController < ApplicationController
|
|||||||
|
|
||||||
def create
|
def create
|
||||||
@janitor_trial = JanitorTrial.create(params[:janitor_trial])
|
@janitor_trial = JanitorTrial.create(params[:janitor_trial])
|
||||||
respond_with(@janitor_trial)
|
respond_with(@janitor_trial, :location => janitor_trials_path)
|
||||||
end
|
end
|
||||||
|
|
||||||
def promote
|
def promote
|
||||||
@janitor_trial = JanitorTrial.find(params[:id])
|
@janitor_trial = JanitorTrial.find(params[:id])
|
||||||
@janitor_trial.promote!
|
@janitor_trial.promote!
|
||||||
respond_with(@janitor_trial)
|
respond_with(@janitor_trial) do |format|
|
||||||
|
format.js
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def demote
|
def demote
|
||||||
@janitor_trial = JanitorTrial.find(params[:id])
|
@janitor_trial = JanitorTrial.find(params[:id])
|
||||||
@janitor_trial.demote!
|
@janitor_trial.demote!
|
||||||
respond_with(@janitor_trial)
|
respond_with(@janitor_trial) do |format|
|
||||||
|
format.js
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -15,6 +15,10 @@ class JanitorTrial < ActiveRecord::Base
|
|||||||
self.original_level = user.level
|
self.original_level = user.level
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def user_name
|
||||||
|
user.try(:name)
|
||||||
|
end
|
||||||
|
|
||||||
def user_name=(name)
|
def user_name=(name)
|
||||||
self.user_id = User.name_to_id(name)
|
self.user_id = User.name_to_id(name)
|
||||||
end
|
end
|
||||||
|
|||||||
6
app/views/janitor_trials/_secondary_links.html.erb
Normal file
6
app/views/janitor_trials/_secondary_links.html.erb
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<% content_for(:secondary_links) do %>
|
||||||
|
<menu>
|
||||||
|
<li><%= link_to "Listing", janitor_trials_path %></li>
|
||||||
|
<li><%= link_to "New", new_janitor_trial_path %></li>
|
||||||
|
</menu>
|
||||||
|
<% end %>
|
||||||
1
app/views/janitor_trials/demote.js.erb
Normal file
1
app/views/janitor_trials/demote.js.erb
Normal file
@@ -0,0 +1 @@
|
|||||||
|
location.reload();
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
<div id="a-index">
|
<div id="a-index">
|
||||||
<h1>Janitor Trials</h1>
|
<h1>Janitor Trials</h1>
|
||||||
|
|
||||||
<table>
|
<table class="striped">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>User</th>
|
<th>User</th>
|
||||||
@@ -14,7 +14,7 @@
|
|||||||
<% @janitor_trials.each do |janitor_trial| %>
|
<% @janitor_trials.each do |janitor_trial| %>
|
||||||
<tr>
|
<tr>
|
||||||
<td><%= janitor_trial.user.name %></td>
|
<td><%= janitor_trial.user.name %></td>
|
||||||
<td><%= janitor_trial.created_at %></td>
|
<td><%= time_ago_in_words janitor_trial.created_at %></td>
|
||||||
<td>
|
<td>
|
||||||
<%= link_to "Promote", promote_janitor_trial_path(janitor_trial), :remote => true, :method => :put %>
|
<%= link_to "Promote", promote_janitor_trial_path(janitor_trial), :remote => true, :method => :put %>
|
||||||
| <%= link_to "Demote", demote_janitor_trial_path(janitor_trial), :remote => true, :method => :put %>
|
| <%= link_to "Demote", demote_janitor_trial_path(janitor_trial), :remote => true, :method => :put %>
|
||||||
@@ -25,3 +25,5 @@
|
|||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<%= render "secondary_links" %>
|
||||||
@@ -3,8 +3,10 @@
|
|||||||
<h1>New Janitor Trial</h1>
|
<h1>New Janitor Trial</h1>
|
||||||
|
|
||||||
<%= simple_form_for(@janitor_trial) do |f| %>
|
<%= simple_form_for(@janitor_trial) do |f| %>
|
||||||
<%= f.input :user_id %>
|
<%= f.input :user_name %>
|
||||||
<%= f.button :submit %>
|
<%= f.button :submit, "Submit" %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<%= render "secondary_links" %>
|
||||||
|
|||||||
1
app/views/janitor_trials/promote.js.erb
Normal file
1
app/views/janitor_trials/promote.js.erb
Normal file
@@ -0,0 +1 @@
|
|||||||
|
location.reload();
|
||||||
Reference in New Issue
Block a user