dfg
This commit is contained in:
parent
f1555bf134
commit
0255a61d2f
|
@ -47,6 +47,10 @@ module ApplicationHelper
|
|||
User.current.allowed_to?({:controller => controller, :action => action}, @project)
|
||||
end
|
||||
|
||||
def authorize_for_contest(controller, action)
|
||||
User.current.allowed_to?({:controller => controller, :action => action}, @contest)
|
||||
end
|
||||
|
||||
# Display a link if user is authorized
|
||||
#
|
||||
# @param [String] name Anchor text (passed to link_to)
|
||||
|
@ -57,6 +61,9 @@ module ApplicationHelper
|
|||
link_to(name, options, html_options, *parameters_for_method_reference) if authorize_for(options[:controller] || params[:controller], options[:action])
|
||||
end
|
||||
|
||||
def link_to_if_authorized_contest(name, options = {}, html_options = nil, *parameters_for_method_reference)
|
||||
link_to(name, options, html_options, *parameters_for_method_reference) if authorize_for_contest(options[:controller] || params[:controller], options[:action])
|
||||
end
|
||||
# Displays a link to user's account page if active
|
||||
def link_to_user(user, options={})
|
||||
if user.is_a?(User)
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
api.array :contestnotifications, api_meta(:total_count => @contestnotifications_count, :offset => @offset, :limit => @limit) do
|
||||
@contestnotificationss.each do |contestnotifications|
|
||||
api.contestnotifications do
|
||||
api.id contestnotifications.id
|
||||
api.contest(:id => contestnotifications.contest_id, :name => contestnotifications.contest.name) unless contestnotifications.contest.nil?
|
||||
api.author(:id => contestnotifications.author_id, :name => contestnotifications.author.name) unless contestnotifications.author.nil?
|
||||
|
||||
api.title contestnotifications.title
|
||||
api.summary contestnotifications.summary
|
||||
api.description contestnotifications.description
|
||||
api.created_at contestnotifications.created_at
|
||||
end
|
||||
end
|
||||
end
|
|
@ -38,23 +38,23 @@
|
|||
<div class="contextual">
|
||||
<%= watcher_link(@contestnotifications, User.current) %>
|
||||
<%= link_to(l(:button_edit),
|
||||
edit_news_path(@news),
|
||||
edit_contest_contestnotification_path(@contestnotifications),
|
||||
:class => 'icon icon-edit',
|
||||
:accesskey => accesskey(:edit),
|
||||
:onclick => '$("#edit-news").show(); return false;') if User.current.allowed_to?(:manage_contestnotification, @contest) %>
|
||||
<%= delete_link news_path(@contestnotifications) if User.current.allowed_to?(:manage_contestnotification, @contest) %>
|
||||
:onclick => '$("#edit-contestnotifications").show(); return false;') if User.current.allowed_to?(:manage_contestnotifications, @contest) %>
|
||||
<%= delete_link contest_contestnotification_path(@contestnotifications) if User.current.allowed_to?(:manage_contestnotifications, @contest) %>
|
||||
</div>
|
||||
|
||||
<h3><strong><%=h @contestnotifications.title %></strong></h3>
|
||||
|
||||
<% if authorize_for('contestnotifications', 'edit') %>
|
||||
<div id="edit-news" style="display:none;">
|
||||
<%= labelled_form_for :contestnotifications, @contestnotifications, :url => contestnotifications_path(@contestnotifications),
|
||||
<% if authorize_for_contest('contestnotifications', 'edit') %>
|
||||
<div id="edit-contestnotifications" style="display:none;">
|
||||
<%= labelled_form_for :contestnotifications, @contestnotifications, :url => contest_contestnotification_path(@contestnotifications),
|
||||
:html => { :id => 'contestnotifications-form', :multipart => true, :method => :put } do |f| %>
|
||||
<%= render :partial => 'form', :locals => { :f => f } %>
|
||||
<%= submit_tag l(:button_save) %>
|
||||
<%= preview_link preview_contestnotifications_path(:contest_id => @contest, :id => @contestnotifications), 'contestnotifications-form',target='preview',{:class => ''} %> |
|
||||
<%= link_to l(:button_cancel), "#", :onclick => '$("#edit-news").hide(); return false;' %>
|
||||
<%= link_to l(:button_cancel), "#", :onclick => '$("#edit-contestnotifications").hide(); return false;' %>
|
||||
<% end %>
|
||||
<div id="preview" class="wiki"></div>
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue