Permalink
Browse files

Hide controls from the rabble.

  • Loading branch information...
1 parent c3c45f0 commit 1a7fc07f3215c2baa03dbe18f98bdeac755b9580 @andmej committed Mar 26, 2012
View
7 app/controllers/application_controller.rb
@@ -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
View
11 app/views/contests/index.html.erb
@@ -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>
View
16 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>

0 comments on commit 1a7fc07

Please sign in to comment.