diff --git a/app/controllers/contestnotifications_controller.rb b/app/controllers/contestnotifications_controller.rb index 15455c806..110f26466 100644 --- a/app/controllers/contestnotifications_controller.rb +++ b/app/controllers/contestnotifications_controller.rb @@ -1,9 +1,9 @@ class ContestnotificationsController < ApplicationController # GET /contestnotifications # GET /contestnotifications.json - layout 'base_contest' - default_search_scope :contestnotification - model_object Contestnotification + layout 'base_newcontest' + default_search_scope :contestnotifications + model_object Contestnotifications before_filter :find_model_object_contest, :except => [:new, :create, :index] before_filter :find_contest_from_association, :except => [:new, :create, :index] before_filter :find_contest_by_contest_id, :only => [:new, :create] @@ -30,18 +30,18 @@ class ContestnotificationsController < ApplicationController 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_count = scope.count + @contestnotifications_pages = Paginator.new @contestnotifications_count, @limit, params['page'] + @offset ||= @contestnotifications_pages.offset @contestnotificationss = scope.all(:include => [:author, :contest], - :order => "#{Contestnotification.table_name}.created_on DESC", + :order => "#{Contestnotifications.table_name}.created_on DESC", :offset => @offset, :limit => @limit) respond_to do |format| format.html { - @contestnotifications = Contestnotifications.new # for adding news inline - render :layout => 'base_contest' + @contestnotification = Contestnotification.new # for adding news inline + render :layout => 'base_newcontest' } format.api format.atom { render_feed(@contestnotificationss, :title => (@contest ? @contest.name : Setting.app_title) + ": #{l(:label_contest_notification)}") } @@ -60,7 +60,7 @@ class ContestnotificationsController < ApplicationController # end @comments = @contestnotifications.comments @comments.reverse! if User.current.wants_comments_in_reverse_order? - render :layout => 'base_contest' + render :layout => 'base_newcontest' end diff --git a/app/controllers/contests_controller.rb b/app/controllers/contests_controller.rb index b51a11436..bd4206808 100644 --- a/app/controllers/contests_controller.rb +++ b/app/controllers/contests_controller.rb @@ -4,9 +4,9 @@ class ContestsController < ApplicationController menu_item :respond menu_item :project, :only => :show_project menu_item :application, :only => :show_softapplication - menu_item :attendingcontest, :only => :show_attendingcontest - menu_item :contestnotification, :only => :show_notification - before_filter :find_contest, :only => [:show_contest, :show_project, :show_softapplication, :show_attendingcontest, :show_notification, :set_reward_project, :set_reward_softapplication, :create,:destroy,:more,:back,:add,:add_softapplication,:new,:show_results, :set_reward, + menu_item :attendingcontests, :only => :show_attendingcontest + menu_item :contestnotifications, :only => :index + before_filter :find_contest, :only => [:show_contest, :show_project, :show_softapplication, :show_attendingcontest, :index, :set_reward_project, :set_reward_softapplication, :create,:destroy,:more,:back,:add,:add_softapplication,:new,:show_results, :set_reward, :show_contest_project, :show_contest_user, :join_in_contest, :unjoin_in_contest, :new_join,:show_participator, :settings] # added by fq diff --git a/app/controllers/roles_controller.rb b/app/controllers/roles_controller.rb deleted file mode 100644 index f4bae1e81..000000000 --- a/app/controllers/roles_controller.rb +++ /dev/null @@ -1,108 +0,0 @@ -# Redmine - project management software -# Copyright (C) 2006-2013 Jean-Philippe Lang -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - -class RolesController < ApplicationController - layout 'admin' - - before_filter :require_admin, :except => [:index, :show] - before_filter :require_admin_or_api_request, :only => [:index, :show] - before_filter :find_role, :only => [:show, :edit, :update, :destroy] - accept_api_auth :index, :show - - def index - respond_to do |format| - format.html { - @role_pages, @roles = paginate Role.sorted, :per_page => 25 - render :action => "index", :layout => false if request.xhr? - } - format.api { - @roles = Role.givable.all - } - end - end - - def show - respond_to do |format| - format.api - end - end - - def new - # Prefills the form with 'Non member' role permissions by default - @role = Role.new(params[:role] || {:permissions => Role.non_member.permissions}) - if params[:copy].present? && @copy_from = Role.find_by_id(params[:copy]) - @role.copy_from(@copy_from) - end - @roles = Role.sorted.all - end - - def create - @role = Role.new(params[:role]) - if request.post? && @role.save - # workflow copy - if !params[:copy_workflow_from].blank? && (copy_from = Role.find_by_id(params[:copy_workflow_from])) - @role.workflow_rules.copy(copy_from) - end - flash[:notice] = l(:notice_successful_create) - redirect_to roles_path - else - @roles = Role.sorted.all - render :action => 'new' - end - end - - def edit - end - - def update - if request.put? and @role.update_attributes(params[:role]) - flash[:notice] = l(:notice_successful_update) - redirect_to roles_path - else - render :action => 'edit' - end - end - - def destroy - @role.destroy - redirect_to roles_path - rescue - flash[:error] = l(:error_can_not_remove_role) - redirect_to roles_path - end - - def permissions - @roles = Role.sorted.all - @permissions = Redmine::AccessControl.permissions.select { |p| !p.public? } - if request.post? - @roles.each do |role| - role.permissions = params[:permissions][role.id.to_s] - role.save - end - flash[:notice] = l(:notice_successful_update) - redirect_to roles_path - end - end - - private - - def find_role - @role = Role.find(params[:id]) - rescue ActiveRecord::RecordNotFound - render_404 - end -end diff --git a/app/models/contestnotification.rb b/app/models/contestnotification.rb index f7087c49d..75b0f5814 100644 --- a/app/models/contestnotification.rb +++ b/app/models/contestnotification.rb @@ -31,12 +31,12 @@ class Contestnotification < ActiveRecord::Base safe_attributes 'title', 'summary', 'description' def visible?(user=User.current) - !user.nil? && user.allowed_to?(:view_contestnotification, contest) + !user.nil? && user.allowed_to?(:view_contestnotifications, contest) end # Returns true if the news can be commented by user def commentable?(user=User.current) - user.allowed_to?(:comment_contestnotification, contest) + user.allowed_to?(:comment_contestnotifications, contest) end def recipients @@ -57,5 +57,5 @@ class Contestnotification < ActiveRecord::Base def act_as_activity self.acts << Activity.new(:user_id => self.author_id) end - + end diff --git a/app/views/contestnotifications/index.html.erb b/app/views/contestnotifications/index.html.erb index 514b89060..e69de29bb 100644 --- a/app/views/contestnotifications/index.html.erb +++ b/app/views/contestnotifications/index.html.erb @@ -1,133 +0,0 @@ - - - -<% - btn_tips = l(:label_news_new) - label_tips = l(:label_news) -%> - - - <%= label_tips %> - - -<%= link_to(btn_tips, - new_contest_contestnotification_path(@contest), - :class => 'icon icon-add', - :onclick => 'showAndScrollTo("add-news", "news_title"); return false;') %> - -<% if @contest && User.current.allowed_to?(:manage_news, @contest) %> -
-<% end %> -- <%= l(:label_no_data) %> -
- <% else %> - <% @contestnotificationss.each do |contestnotifications| %> - -<%= link_to image_tag(url_to_avatar(contestnotifications.author), :class => "avatar"), user_path(contestnotifications.author) %> | -
-
|
-