diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 06e2285c2..27829fa08 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -296,9 +296,9 @@ class ApplicationController < ActionController::Base end def find_contest_from_association - render_404 unless @object.present? + render_404 unless @contest.present? - @contest = @object.contest + @contest = @contest.contest end def find_model_object diff --git a/app/controllers/comments_controller.rb b/app/controllers/comments_controller.rb index 5b5578c09..d54e9ae7e 100644 --- a/app/controllers/comments_controller.rb +++ b/app/controllers/comments_controller.rb @@ -54,9 +54,9 @@ class CommentsController < ApplicationController def find_model_object_contest super - @contestnotification = @object + @contestnotifications = @object @comment = nil - @contestnotification + @contestnotifications end end diff --git a/app/controllers/contestnotifications_controller.rb b/app/controllers/contestnotifications_controller.rb index 4ca19e6ed..15455c806 100644 --- a/app/controllers/contestnotifications_controller.rb +++ b/app/controllers/contestnotifications_controller.rb @@ -28,23 +28,23 @@ class ContestnotificationsController < ApplicationController @limit = 10 end - scope = @contest ? @contest.contestnotification.visible : Contestnotification.visible + scope = @contest ? @contest.contestnotifications.visible : Contestnotifications.visible @contestnotification_count = scope.count @contestnotification_pages = Paginator.new @contestnotification_count, @limit, params['page'] @offset ||= @contestnotification_pages.offset - @contestnotifications = scope.all(:include => [:author, :contest], + @contestnotificationss = scope.all(:include => [:author, :contest], :order => "#{Contestnotification.table_name}.created_on DESC", :offset => @offset, :limit => @limit) respond_to do |format| format.html { - @contestnotification = Contestnotification.new # for adding news inline + @contestnotifications = Contestnotifications.new # for adding news inline render :layout => 'base_contest' } format.api - format.atom { render_feed(@contestnotifications, :title => (@contest ? @contest.name : Setting.app_title) + ": #{l(:label_contest_notification)}") } + format.atom { render_feed(@contestnotificationss, :title => (@contest ? @contest.name : Setting.app_title) + ": #{l(:label_contest_notification)}") } end ### end ### end @@ -58,7 +58,7 @@ class ContestnotificationsController < ApplicationController # format.html # show.html.erb # format.json { render json: @contestnotification } # end - @comments = @contestnotification.comments + @comments = @contestnotifications.comments @comments.reverse! if User.current.wants_comments_in_reverse_order? render :layout => 'base_contest' @@ -73,7 +73,7 @@ class ContestnotificationsController < ApplicationController # format.html # new.html.erb # format.json { render json: @contestnotification } # end - @contestnotification = Contestnotification.new(:contest => @contest, :author => User.current) + @contestnotifications = Contestnotifications.new(:contest => @contest, :author => User.current) render :layout => 'base_contest' end @@ -96,11 +96,11 @@ class ContestnotificationsController < ApplicationController # format.json { render json: @contestnotification.errors, status: :unprocessable_entity } # end # end - @contestnotification = Contestnotification.new(:contest => @contest, :author => User.current) - @contestnotification.safe_attributes = params[:contestnotification] + @contestnotifications = Contestnotifications.new(:contest => @contest, :author => User.current) + @contestnotifications.safe_attributes = params[:contestnotifications] @news.save_attachments(params[:attachments]) - if @contestnotification.save - render_attachment_warning_if_needed(@contestnotification) + if @contestnotifications.save + render_attachment_warning_if_needed(@contestnotifications) flash[:notice] = l(:notice_successful_create) redirect_to project_news_index_path(@contest) else @@ -123,12 +123,12 @@ class ContestnotificationsController < ApplicationController # format.json { render json: @contestnotification.errors, status: :unprocessable_entity } # end # end - @contestnotification.safe_attributes = params[:contestnotification] - @contestnotification.save_attachments(params[:attachments]) - if @contestnotification.save - render_attachment_warning_if_needed(@contestnotification) + @contestnotifications.safe_attributes = params[:contestnotifications] + @contestnotifications.save_attachments(params[:attachments]) + if @contestnotifications.save + render_attachment_warning_if_needed(@contestnotifications) flash[:notice] = l(:notice_successful_update) - redirect_to contestnotification_path(@contestnotification) + redirect_to contestnotification_path(@contestnotifications) else render :action => 'edit' end @@ -144,7 +144,7 @@ class ContestnotificationsController < ApplicationController # format.html { redirect_to contestnotifications_url } # format.json { head :no_content } # end - @contestnotification.destroy + @contestnotifications.destroy redirect_to contest_contestnotification_index_path(@contest) end diff --git a/app/helpers/welcome_helper.rb b/app/helpers/welcome_helper.rb index 330010212..dc651d38a 100644 --- a/app/helpers/welcome_helper.rb +++ b/app/helpers/welcome_helper.rb @@ -319,9 +319,10 @@ module WelcomeHelper "show_documents" => true, "show_messages" => true, "show_news" => true, - "show_bids" => true + "show_bids" => true, + "show_contest" => true } - activity.scope_select{|t| ['changesets', 'documents', 'memos', 'messages', 'journals_for_messages', 'bids', 'news'].include?(t) ? nil : 'You may think you know what the following code does, may be. but why don"t you close this file and go play with something else, Now?' } + activity.scope_select{|t| ['changesets', 'documents', 'memos', 'messages', 'journals_for_messages', 'bids', 'news', 'contestnotification'].include?(t) ? nil : 'You may think you know what the following code does, may be. but why don"t you close this file and go play with something else, Now?' } activity.events_welcome(nil, nil, {:limit => limit, :types => 'welcome'}) end diff --git a/app/models/contestnotification.rb b/app/models/contestnotification.rb index b0021c98a..f7087c49d 100644 --- a/app/models/contestnotification.rb +++ b/app/models/contestnotification.rb @@ -45,7 +45,7 @@ class Contestnotification < ActiveRecord::Base # returns latest news for contests visible by user def self.latest(user = User.current, count = 5) - visible(user).includes([:author, :contest]).order("#{Contestnotification.table_name}.created_on DESC").limit(count).all + visible(user).includes([:author, :contest]).order("#{Contestnotifications.table_name}.created_on DESC").limit(count).all end private diff --git a/app/views/contestnotifications/_contestnotifications.html.erb b/app/views/contestnotifications/_contestnotifications.html.erb index 0866ea198..4a062f3b5 100644 --- a/app/views/contestnotifications/_contestnotifications.html.erb +++ b/app/views/contestnotifications/_contestnotifications.html.erb @@ -10,17 +10,17 @@
<%=link_to contestnotification.author,contestnotification_path(contestnotification)%> - <%= l(:label_project_newshare) %> <%= link_to h(contestnotification.title), news_path(contestnotification) %> + | <%=link_to contestnotifications.author,contestnotifications_path(contestnotifications)%> + <%= l(:label_project_newshare) %> <%= link_to h(contestnotifications.title), news_path(contestnotifications) %> | ||
<%=h contestnotification.description%> |
+ <%=h contestnotifications.description%> |
||
<%= contestnotification.created_on %> | -<%= link_to l(:label_project_newother),contestnotification_path(contestnotification)%> - <%= "(#{l(:label_x_comments, :count => contestnotification.comments_count)})" if contestnotification.comments_count > 0 %> + | <%= contestnotifications.created_on %> | +<%= link_to l(:label_project_newother),contestnotifications_path(contestnotifications)%> + <%= "(#{l(:label_x_comments, :count => contestnotifications.comments_count)})" if contestnotifications.comments_count > 0 %> |
<%= f.text_field :title, :required => true, :size => 60, :style => "width:488px;" %>
<%= f.text_area :description, :required => true, :cols => 60, :rows => 11, :class => 'wiki-edit', :style => "width:490px;" %>
-<%= render :partial => 'attachments/form', :locals => {:container => @contestnotification} %>
+<%= render :partial => 'attachments/form', :locals => {:container => @contestnotifications} %>
<%= wikitoolbar_for 'news_description' %> diff --git a/app/views/contestnotifications/edit.html.erb b/app/views/contestnotifications/edit.html.erb index 6d680f2e6..121b15d9a 100644 --- a/app/views/contestnotifications/edit.html.erb +++ b/app/views/contestnotifications/edit.html.erb @@ -7,10 +7,10 @@<%= l(:label_no_data) %>
<% else %> - <% @contestnotifications.each do |contestnotification| %> + <% @contestnotificationss.each do |contestnotifications| %><%= link_to image_tag(url_to_avatar(contestnotification.author), :class => "avatar"), user_path(contestnotification.author) %> | +<%= link_to image_tag(url_to_avatar(contestnotifications.author), :class => "avatar"), user_path(contestnotifications.author) %> |
|
diff --git a/app/views/contestnotifications/new.html.erb b/app/views/contestnotifications/new.html.erb
index cd5920273..6e474b4ea 100644
--- a/app/views/contestnotifications/new.html.erb
+++ b/app/views/contestnotifications/new.html.erb
@@ -7,7 +7,7 @@
-<%= labelled_form_for @contestnotification, :url => contest_contestnotification_index_path(@contest),
+<%= labelled_form_for @contestnotifications, :url => contest_contestnotifications_index_path(@contest),
:html => { :id => 'news-form', :multipart => true } do |f| %>
<%= render :partial => 'news/form', :locals => { :f => f } %>
<%= submit_tag l(:button_create), :class => "whiteButton m3p10 h30" %>
diff --git a/app/views/contestnotifications/show.html.erb b/app/views/contestnotifications/show.html.erb
index 3b3a53fd8..a8069c73c 100644
--- a/app/views/contestnotifications/show.html.erb
+++ b/app/views/contestnotifications/show.html.erb
@@ -36,24 +36,24 @@
|||||||||
<%= format_time(comment.created_on) %> | -<%= link_to_if_authorized image_tag('delete.png'), {:controller => 'comments', :action => 'destroy', :id => @contestnotification, :comment_id => comment}, + | <%= link_to_if_authorized image_tag('delete.png'), {:controller => 'comments', :action => 'destroy', :id => @contestnotifications, :comment_id => comment}, :data => {:confirm => l(:text_are_you_sure)}, :method => :delete, :title => l(:button_delete) %> |
- <%= link_to_attachments @contestnotification %> + <%= link_to_attachments @contestnotifications %>
- <% if @contestnotification.commentable? %> + <% if @contestnotifications.commentable? %>
<%= toggle_link l(:label_comment_add), "add_comment_form", :focus => "comment_comments" %>
- <%= form_tag({:controller => 'comments', :action => 'create', :id => @contestnotification}, :id => "add_comment_form", :style => "display:none;") do %> + <%= form_tag({:controller => 'comments', :action => 'create', :id => @contestnotifications}, :id => "add_comment_form", :style => "display:none;") do %>