diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index fd1f6f162..f558f1e7a 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -46,6 +46,10 @@ module ApplicationHelper def authorize_for(controller, action) 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 # @@ -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) diff --git a/app/views/contestnotifications/index.api.rsb b/app/views/contestnotifications/index.api.rsb new file mode 100644 index 000000000..6509d2915 --- /dev/null +++ b/app/views/contestnotifications/index.api.rsb @@ -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 diff --git a/app/views/contestnotifications/show.html.erb b/app/views/contestnotifications/show.html.erb index bd4c8a4f8..ead40aef7 100644 --- a/app/views/contestnotifications/show.html.erb +++ b/app/views/contestnotifications/show.html.erb @@ -38,23 +38,23 @@