Skip to content

Commit

Permalink
Hide controls from the rabble.
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrés Mejía committed Mar 26, 2012
1 parent c3c45f0 commit 1a7fc07
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 13 deletions.
7 changes: 6 additions & 1 deletion app/controllers/application_controller.rb
Expand Up @@ -6,9 +6,14 @@ class ApplicationController < ActionController::Base
redirect_to new_session_url, :alert => exception.message
end

helper_method :current_user
helper_method :current_user, :logged_in?

def current_user
session[:admin]
end

def logged_in?
current_user.present?
end

end
11 changes: 6 additions & 5 deletions app/views/contests/index.html.erb
Expand Up @@ -6,17 +6,18 @@
<th>Start Date</th>
<th>End Date</th>
<th>Status</th>
<th colspan="3">Controls</th>
</tr>
<% for contest in @contests %>
<tr>
<td><%= contest.name %></td>
<td><%= link_to contest.name, contest %></td>
<td><%= l contest.start_date, :format => :long %></td>
<td><%= l contest.end_date, :format => :long %></td>
<td><%= contest_status(contest) %></td>
<td><%= link_to "Show", contest %></td>
<td><%= link_to "Edit", edit_contest_path(contest) %></td>
<td><%= link_to "Destroy", contest, :confirm => 'Are you sure?', :method => :delete %></td>

<% if logged_in? %>
<td><%= link_to "Edit", edit_contest_path(contest) %></td>
<td><%= link_to "Destroy", contest, :confirm => 'Are you sure?', :method => :delete %></td>
<% end %>
</tr>
<% end %>
</table>
Expand Down
16 changes: 9 additions & 7 deletions app/views/contests/show.html.erb
@@ -1,12 +1,14 @@
<% title "Contest: #{@contest.name}" %>
<div>
<p>
<%= link_to "Edit this contest", edit_contest_path(@contest) %> |
<%= link_to "Destroy this contest", @contest, :confirm => 'Are you sure?', :method => :delete %> |
<%= link_to "View all contests", contests_path %>
</p>
</div>
<% if logged_in? %>
<div>
<p>
<%= link_to "Edit this contest", edit_contest_path(@contest) %> |
<%= link_to "Destroy this contest", @contest, :confirm => 'Are you sure?', :method => :delete %> |
<%= link_to "View all contests", contests_path %>
</p>
</div>
<% end %>

<div>
<span><b>Duration:</b> <%= format_time(@contest.duration) %></span>
Expand Down

0 comments on commit 1a7fc07

Please sign in to comment.