From 70b079041c6c8c8374b0c7daec483b309b60a9ad Mon Sep 17 00:00:00 2001 From: alan <547533434@qq.com> Date: Wed, 10 Sep 2014 11:36:50 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9contests=5Fcontroller.rb?= =?UTF-8?q?=EF=BC=8Ccontest.rb,=20contest=5Fproject.rb,contests=5Fhelper.r?= =?UTF-8?q?b,=20attachments=5Fhelper.rb,=20application=5Fhelper.rb.=20?= =?UTF-8?q?=E4=B8=BB=E8=A6=81=E4=BF=AE=E6=94=B9=E5=86=85=E5=AE=B9:=20?= =?UTF-8?q?=E4=B9=A6=E5=86=99=E8=A7=84=E8=8C=83=EF=BC=8C=20for=E5=BE=AA?= =?UTF-8?q?=E7=8E=AF=E7=94=A8=20each=20=E4=BB=A3=E6=9B=BF=EF=BC=8C=20if=20?= =?UTF-8?q?=E8=AF=AD=E5=8F=A5=E7=9A=84=E5=90=88=E5=B9=B6=EF=BC=8C=20unless?= =?UTF-8?q?=20=E8=BD=AC=E6=8D=A2=E6=88=90if,=20=09=09=E5=87=BD=E6=95=B0?= =?UTF-8?q?=E5=90=8D=E7=A7=B0=E6=8B=BC=E5=86=99=E9=94=99=E8=AF=AF=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: alan <547533434@qq.com> --- app/controllers/contests_controller.rb | 243 ++++++++++++++++--------- app/helpers/application_helper.rb | 4 +- app/helpers/attachments_helper.rb | 15 +- app/helpers/contests_helper.rb | 48 +++-- app/helpers/projects_helper.rb | 58 ++++-- app/models/contest.rb | 13 +- app/models/contesting_project.rb | 2 +- app/views/contests/_new.html.erb | 32 +++- 8 files changed, 279 insertions(+), 136 deletions(-) diff --git a/app/controllers/contests_controller.rb b/app/controllers/contests_controller.rb index e2f5e3731..b099a1db5 100644 --- a/app/controllers/contests_controller.rb +++ b/app/controllers/contests_controller.rb @@ -2,33 +2,44 @@ # class BidsController < ApplicationController class ContestsController < ApplicationController layout "contest_base" + menu_item :respond menu_item :project, :only => :show_project menu_item :application, :only => :show_softapplication menu_item :attendingcontests, :only => :show_attendingcontest menu_item :contestnotifications, :only => :index - before_filter :can_show_contest,except: [] - 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] - + before_filter :can_show_contest, :except => [] # modified by alan + + # modified by longjun + 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 + ] + # end longjun + # added by fq before_filter :require_login, :only => [:join_in_contest, :unjoin_in_contest] # end - before_filter :require_login,:only => [:set_reward, :destroy, :add, :new, ] + before_filter :require_login,:only => [:set_reward, :destroy, :add, :new ] helper :watchers helper :attachments - include AttachmentsHelper - include ApplicationHelper helper :projects helper :words + include AttachmentsHelper + include ApplicationHelper + def index # @contests = Contest.visible # @contests ||= [] - @offset, @limit = api_offset_and_limit({:limit => 10}) + @offset, @limit = api_offset_and_limit(:limit => 10) #@contests = Contest.visible #@contests = @contests.like(params[:name]) if params[:name].present? @contests = Contest.visible.where("name like '%#{params[:name]}%'") @@ -41,43 +52,55 @@ class ContestsController < ApplicationController @offset ||= @contest_pages.reverse_offset if params[:contest_sort_type].present? case params[:contest_sort_type] - when '0' - unless @offset == 0 - @contests = @contests.reorder('contests.commit').offset(@offset).limit(@limit).all.reverse - else - limit = @contest_count % @limit - limit = @limit if limit == 0 - @contests = @contests.reorder('contests.commit').offset(@offset).limit(limit).all.reverse - end - @s_state = 0 - when '1' - unless @offset == 0 - @contests = @contests.reorder('contests.created_on').offset(@offset).limit(@limit).all.reverse - else - limit = @contest_count % @limit - limit = @limit if limit == 0 - @contests = @contests.reorder('contests.created_on').offset(@offset).limit(limit).all.reverse - end - @s_state = 1 - when '2' - unless @offset == 0 - @contests = @contests.offset(@offset).limit(@limit).all.reverse - else - limit = @contest_count % @limit - limit = @limit if limit == 0 - @contests = @contests.offset(@offset).limit(@limit).all.reverse - end - @s_state = 0 + when '0' + # modified by longjun + # never use unless and else + # unless @offset == 0 + if @offset != 0 + @contests = @contests.reorder('contests.commit').offset(@offset).limit(@limit).all.reverse + else + limit = @contest_count % @limit + limit = @limit if limit == 0 + @contests = @contests.reorder('contests.commit').offset(@offset).limit(limit).all.reverse end + @s_state = 0 + when '1' + # modified by longjun + # never use unless and else + # unless @offset == 0 + if @offset != 0 + @contests = @contests.reorder('contests.created_on').offset(@offset).limit(@limit).all.reverse else - unless @offset == 0 - @contests = @contests.reorder('contests.created_on').offset(@offset).limit(@limit).all.reverse - else - limit = @contest_count % @limit - limit = @limit if limit == 0 - @contests = @contests.reorder('contests.created_on').offset(@offset).limit(limit).all.reverse - end - @s_state = 1 + limit = @contest_count % @limit + limit = @limit if limit == 0 + @contests = @contests.reorder('contests.created_on').offset(@offset).limit(limit).all.reverse + end + @s_state = 1 + when '2' + # modified by longjun + # never use unless and else + # unless @offset == 0 + if @offset != 0 + @contests = @contests.offset(@offset).limit(@limit).all.reverse + else + limit = @contest_count % @limit + limit = @limit if limit == 0 + @contests = @contests.offset(@offset).limit(@limit).all.reverse + end + @s_state = 0 + end + else + # modified by longjun + # never use unless and else + # unless @offset == 0 + if @offset != 0 + @contests = @contests.reorder('contests.created_on').offset(@offset).limit(@limit).all.reverse + else + limit = @contest_count % @limit + limit = @limit if limit == 0 + @contests = @contests.reorder('contests.created_on').offset(@offset).limit(limit).all.reverse + end + @s_state = 1 end end @@ -93,7 +116,10 @@ class ContestsController < ApplicationController @bid_pages = Paginator.new @bid_count, @limit, params['page'] @offset ||= @bid_pages.reverse_offset - unless @offset == 0 + # modified by longjun + # never use unless and else + # unless @offset == 0 + if @offset != 0 @bids = @bids.offset(@offset).limit(@limit).all.reverse else limit = @bid_count % @limit @@ -149,10 +175,7 @@ class ContestsController < ApplicationController end end - def new_join - - end def show_participator render :layout => 'base_newcontest' @@ -186,26 +209,43 @@ class ContestsController < ApplicationController def show_contest_project contests = Contest.where('parent_id = ?', @contest.id) @projects = [] - for contest in contests - @projects += contest.contesting_projects - end + + # Modified by longjun + # 用 arr.each 替换 for [ according to the style guide ] + + # for contest in contests + # @projects += contest.contesting_projects + # end + + contests.each do |contest| + @projects += contest.contesting_projects + end + + # end respond_to do |format| format.html { render :layout => 'base_newcontest' } format.api - end end def show_contest_softapplication contests = Contest.where('parent_id = ?', @contest.id) @softapplications = [] - for contest in contests - @softapplications += contest.contesting_softapplications - end - + + # Modified by Longjun + # for contest in contests + # @softapplications += contest.contesting_softapplications + + + contests.each do |contest| + @softapplications += contest.contesting_softapplications + end + + # end + respond_to do |format| format.html { render :layout => 'base_newcontest' @@ -218,12 +258,21 @@ class ContestsController < ApplicationController def show_contest_user contests = Contest.find(:all) @users = [] - for contest in contests - for project in contest.projects - @users += project.users - end + + # Modified by Longjun + # for contest in contests + # for project in contest.projects + # @users += project.users + # end + + + contests.each do |contest| + contest.projects.each do |project| + @uers += project.users + end end - + # end + respond_to do |format| format.html { render :layout => 'base_newcontest' @@ -239,11 +288,20 @@ class ContestsController < ApplicationController # @contesting_project_count = @contesting_project_all.count # @contesting_project_pages = Paginator.new @contesting_project_count, per_page_option, params['page'] @membership.each do |membership| - unless(membership.project.project_type==1) - if User.current.allowed_to?(:quote_project, membership.project) + + # Modified by Longjun + # 将两个判断语句合并 + # unless membership.project.project_type==1 + # if User.current.allowed_to?(:quote_project, membership.project) + # @option << membership.project + # end + # end + if membership.project.project_type != 1 && User.current.allowed_to?(:quote_project, membership.project) @option << membership.project - end + end + # end + end @user = @contest.author @contesting_project = @contest.contesting_projects.all @@ -262,16 +320,19 @@ class ContestsController < ApplicationController @temp = [] @contesting_project.each do |pro| - if pro.project && pro.project.project_status - @temp << pro - end + # modified by longjun + # if pro.project && pro.project.project_status + # @temp << pro + # end + @temp << pro if pro.project && pro.project.project_status + # end longjun @temp end if @temp.size > 0 @contesting_project = @temp.sort {|a,b| b.project.project_status.grade <=> a.project.project_status.grade} end end - @contesting_project = paginateHelper @contesting_project + @contesting_project = paginateHelper(@contesting_project) respond_to do |format| format.html { render :layout => 'base_newcontest' @@ -290,7 +351,7 @@ class ContestsController < ApplicationController @softapplication = Softapplication.all @contesting_softapplication = @contest.contesting_softapplications - @contesting_softapplication = paginateHelper @contesting_softapplication, 10 + @contesting_softapplication = paginateHelper(@contesting_softapplication, 10) # @temp = [] # @softapplicationt.each do |pro| @@ -328,7 +389,7 @@ class ContestsController < ApplicationController # @contesting_project_count = @contesting_project_all.count # @contesting_project_pages = Paginator.new @contesting_project_count, per_page_option, params['page'] @membership.each do |membership| - unless(membership.project.project_type==1) + unless membership.project.project_type==1 #拥有编辑项目权限的可将该项目参赛 if User.current.allowed_to?(:quote_project, membership.project) @option << membership.project @@ -352,27 +413,31 @@ class ContestsController < ApplicationController @temp = [] @contesting_project.each do |pro| - if pro.project && pro.project.project_status - @temp << pro - end + # modified by longjun + # if pro.project && pro.project.project_status + # @temp << pro + # end + @temp << pro if pro.project && pro.project.project_status + # end longjun @temp end if @temp.size > 0 @contesting_project = @temp.sort {|a,b| b.project.project_status.grade <=> a.project.project_status.grade} end end -##取出参赛应用 --应用列表 + # 取出参赛应用 --应用列表 @softapplication = Softapplication.all @contesting_softapplication = @contest.contesting_softapplications. joins("LEFT JOIN softapplications ON contesting_softapplications.softapplication_id=softapplications.id"). joins("LEFT JOIN ( - SELECT * FROM seems_rateable_cached_ratings WHERE cacheable_type='Softapplication' AND DIMENSION = 'quality') AS cached - ON cached.cacheable_id=softapplications.id"). + SELECT * FROM seems_rateable_cached_ratings + WHERE cacheable_type='Softapplication' AND DIMENSION = 'quality') AS cached + ON cached.cacheable_id=softapplications.id"). order("cached.avg").reverse_order @contesting_softapplication = paginateHelper @contesting_softapplication, 10 -##引用base_newcontest整体样式 + #引用base_newcontest整体样式 @contest = Contest.find_by_id(params[:id]) respond_to do |format| format.html { @@ -384,15 +449,15 @@ class ContestsController < ApplicationController ###end -def show_notification - @contest = Contest.find_by_id(params[:id]) - respond_to do |format| - format.html { - render :layout => 'base_newcontest' - } - format.api - end -end + def show_notification + @contest = Contest.find_by_id(params[:id]) + respond_to do |format| + format.html { + render :layout => 'base_newcontest' + } + format.api + end + end def set_reward_project @@ -437,7 +502,11 @@ end project = Project.find(params[:contest]) contest_message = params[:contest_for_save][:contest_message] if ContestingProject.where("project_id = ? and contest_id = ?", project.id, @contest.id).size == 0 - if ContestingProject.cerate_contesting(@contest.id, project.id, contest_message) + # modified by longjun, create 写错了 + # if ContestingProject.cerate_contesting(@contest.id, project.id, contest_message) + if ContestingProject.create_contesting(@contest.id, project.id, contest_message) + # end longjun + flash.now[:notice] = l(:label_bidding_contest_succeed) end else @@ -633,9 +702,7 @@ end end - def manage - end private diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 807d851be..4ab09db38 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -33,8 +33,8 @@ module ApplicationHelper extend Forwardable def_delegators :wiki_helper, :wikitoolbar_for, :heads_for_wiki_formatter - #Added by young - #Define the course menu's link class + # Added by young + # Define the course menu's link class # 不是数组的转化成数组,然后判断当前menu_item是否在给定的列表 # REVIEW: 目测menu的机制,貌似不是很需要转换,再说 def link_class(label) diff --git a/app/helpers/attachments_helper.rb b/app/helpers/attachments_helper.rb index ee9d2a70d..e6f20ea60 100644 --- a/app/helpers/attachments_helper.rb +++ b/app/helpers/attachments_helper.rb @@ -22,6 +22,9 @@ module AttachmentsHelper # Options: # :author -- author names are not displayed if set to false # :thumbails -- display thumbnails if enabled in settings + + include Redmine::Pagination + def link_to_attachments(container, options = {}) options.assert_valid_keys(:author, :thumbnails) @@ -171,7 +174,9 @@ module AttachmentsHelper s.html_safe end - def private_filter resultSet + # Modified by Longjun + # 有参数的方法要加() + def private_filter(resultSet) result = resultSet.to_a.dup # modify by nwb @@ -190,8 +195,12 @@ module AttachmentsHelper result end - include Redmine::Pagination - def paginateHelper obj, pre_size=10 + # Modified by Longjun + # include 应放在class/model 的开始处 + # include Redmine::Pagination + # end + + def paginateHelper (obj, pre_size=10) @obj_count = obj.count @obj_pages = Paginator.new @obj_count, pre_size, params['page'] if obj.kind_of? ActiveRecord::Base or obj.kind_of? ActiveRecord::Relation diff --git a/app/helpers/contests_helper.rb b/app/helpers/contests_helper.rb index 01c7d544f..67d1c3b3f 100644 --- a/app/helpers/contests_helper.rb +++ b/app/helpers/contests_helper.rb @@ -43,16 +43,16 @@ module ContestsHelper def sort_contest_enterprise(state, project_type) content = ''.html_safe case state - when 0 - content << content_tag('li', link_to(l(:label_sort_by_active), calls_path(:contest_sort_type => '1', :project_type => project_type))) - content << content_tag('li', link_to(l(:label_sort_by_time), calls_path(:contest_sort_type => '0', :project_type => project_type), :class=>"selected"), :class=>"selected") - - when 1 - content << content_tag('li', link_to(l(:label_sort_by_active), calls_path(:contest_sort_type => '1', :project_type => project_type), :class=>"selected"), :class=>"selected") - content << content_tag('li', link_to(l(:label_sort_by_time), calls_path(:contest_sort_type => '0', :project_type => project_type))) - end - content = content_tag('ul', content) - content_tag('div', content, :class => "tabs_enterprise") + when 0 + content << content_tag('li', link_to(l(:label_sort_by_active), calls_path(:contest_sort_type => '1', :project_type => project_type))) + content << content_tag('li', link_to(l(:label_sort_by_time), calls_path(:contest_sort_type => '0', :project_type => project_type), :class=>"selected"), :class=>"selected") + + when 1 + content << content_tag('li', link_to(l(:label_sort_by_active), calls_path(:contest_sort_type => '1', :project_type => project_type), :class=>"selected"), :class=>"selected") + content << content_tag('li', link_to(l(:label_sort_by_time), calls_path(:contest_sort_type => '0', :project_type => project_type))) + end + content = content_tag('ul', content) + content_tag('div', content, :class => "tabs_enterprise") end #end @@ -100,7 +100,10 @@ module ContestsHelper def count_contest_project contests = Contest.find(:id) @projects = [] - for contest in contests + # Modified by alan + # for contest in contests + contests.each do |contest| + # end alan @projects += contest.contesting_projects end @projects.count @@ -109,7 +112,10 @@ module ContestsHelper def count_contest_softapplication contests = Contest.find(:id) @softapplications = [] - for contest in contests + # Modified by alan + # for contest in contests + contests.each do |contest| + # end alan @softapplications += contest.contesting_softapplications end @projects.count @@ -119,19 +125,29 @@ module ContestsHelper def count_contest_user contests = Contest.find(:id) @users = [] - for contest in contests - for project in contest.projects + # Modified by alan + # for contest in contests + contests.each do |contest| + + contest.projects.each do |project| + @users += project.users end end + # end alan + @users.count end def count_contest_softapplication_user contests = Contest.find(:id) @users = [] - for contest in contests - for project in contest.softapplications + # Modified by alan + # for contest in contests + contests.each do |contest| + + contest.projects.each do |softapplications| + # for project in contest.softapplications @users += softapplication.users end end diff --git a/app/helpers/projects_helper.rb b/app/helpers/projects_helper.rb index 6849ba83d..dfacff864 100644 --- a/app/helpers/projects_helper.rb +++ b/app/helpers/projects_helper.rb @@ -44,7 +44,7 @@ module ProjectsHelper content = ''.html_safe case state when 0 - + content << content_tag('li', link_to(l(:label_sort_by_active), projects_path(:project_sort_type => '1', :project_type => project_type))) content << content_tag('li', link_to(l(:label_sort_by_influence), projects_path(:project_sort_type => '2', :project_type => project_type))) content << content_tag('li', link_to(l(:label_sort_by_time), projects_path(:project_sort_type => '0', :project_type => project_type), :class=>"selected"), :class=>"selected") @@ -70,19 +70,19 @@ module ProjectsHelper content << content_tag('li', link_to(l(:label_sort_by_active), course_path(:project_sort_type => '1', :project_type => project_type, :school_id => school_id))) # content << content_tag('li', link_to(l(:label_sort_by_influence), course_path(:project_sort_type => '2', :project_type => project_type))) content << content_tag('li', link_to(l(:label_sort_by_activity), course_path(:project_sort_type => '3', :project_type => project_type, :school_id => school_id))) - + when 1 content << content_tag('li', link_to(l(:label_sort_by_time), course_path(:project_sort_type => '0', :project_type => project_type, :school_id => school_id))) content << content_tag('li', link_to(l(:label_sort_by_active), course_path(:project_sort_type => '1', :project_type => project_type, :school_id => school_id), :class=>"selected"), :class=>"selected") # content << content_tag('li', link_to(l(:label_sort_by_influence), course_path(:project_sort_type => '2', :project_type => project_type))) content << content_tag('li', link_to(l(:label_sort_by_activity), course_path(:project_sort_type => '3', :project_type => project_type, :school_id => school_id))) - + when 2 content << content_tag('li', link_to(l(:label_sort_by_time), course_path(:project_sort_type => '0', :project_type => project_type, :school_id => school_id))) content << content_tag('li', link_to(l(:label_sort_by_active), course_path(:project_sort_type => '1', :project_type => project_type, :school_id => school_id))) # content << content_tag('li', link_to(l(:label_sort_by_influence), course_path(:project_sort_type => '2', :project_type => project_type), :class=>"selected"), :class=>"selected") content << content_tag('li', link_to(l(:label_sort_by_activity), course_path(:project_sort_type => '3', :project_type => project_type, :school_id => school_id))) - + #gcm when 3 content << content_tag('li', link_to(l(:label_sort_by_time), course_path(:project_sort_type => '0', :project_type => project_type, :school_id => school_id))) @@ -101,7 +101,7 @@ module ProjectsHelper content = ''.html_safe case state when 0 - + content << content_tag('li', link_to(l(:label_sort_by_active), projects_path(:project_sort_type => '1', :project_type => project_type))) content << content_tag('li', link_to(l(:label_sort_by_influence), projects_path(:project_sort_type => '2', :project_type => project_type))) content << content_tag('li', link_to(l(:label_sort_by_time), projects_path(:project_sort_type => '0', :project_type => project_type), :class=>"selected"), :class=>"selected") @@ -142,7 +142,7 @@ module ProjectsHelper # end - #Added by young + # Added by young def course_settings_tabs tabs = [{:name => 'info', :action => :edit_project, :partial => 'projects/edit', :label => :label_information_plural, :course=>'1'}, #{:name => 'boards', :action => :manage_boards, :partial => 'projects/settings/boards', :label => :label_board_plural, :project_type => 1}, @@ -151,7 +151,7 @@ module ProjectsHelper ] tabs.select {|tab| User.current.allowed_to?(tab[:action], @project)} end - #Ended by young + # Ended by young @@ -174,20 +174,37 @@ module ProjectsHelper def render_project_hierarchy(projects) render_project_nested_lists(projects) do |project| #Modified by young - if (project.try(:project_type) == Project::ProjectType_course ) - unless project.is_public == 1 - s = "#{l(:lable_private)}".html_safe + if project.try(:project_type) == Project::ProjectType_course + + # modified by longjun + # never use unless and else + # unless project.is_public == 1 + + if project.is_public != 1 + s = "#{l(:lable_private)}".html_safe else s = "".html_safe end - s += link_to_project(project, {}, :class => "#{project.css_classes} #{User.current.member_of?(project) ? 'my-project' : nil}").html_safe + # end longjun + + # modified by Longjun + s += link_to_project(project, {}, + :class => "#{project.css_classes} #{User.current.member_of?(project) ? 'my-project' : nil}").html_safe + # end longjun else - unless project.is_public + # modified by longjun + # unless project.is_public + + if !project.is_public + # end longjun s = "#{l(:lable_private)}".html_safe else s = "".html_safe end - s += link_to_project(project, {}, :class => "#{project.css_classes} #{User.current.member_of?(project) ? 'my-project' : nil}") + # modified by longjun + s += link_to_project(project, {}, + :class => "#{project.css_classes} #{User.current.member_of?(project) ? 'my-project' : nil}") + # end longjun end #Ended by young if project.description.present? @@ -254,9 +271,14 @@ module ProjectsHelper def is_manager?(user_id,project_id) @result = false @user_id = ProjectInfo.find_by_project_id(project_id) - if @user_id == user.id - @result = true - end + + # modified by longjun + # if @user_id == user.id + # @result = true + # end + + @result = true if @user_id = user.id + # end longjun return @result end @@ -341,9 +363,9 @@ module ProjectsHelper return true if (project.nil? && project.course_extra.nil?) courses_year = project.course_extra.time current_year = Time.now.year - if(courses_year >= current_year) + if courses_year >= current_year return false - elsif( (courses_year < current_year) && (Time.now.month < 3) ) + elsif (courses_year < current_year) && (Time.now.month < 3) return false else return true diff --git a/app/models/contest.rb b/app/models/contest.rb index f1503f593..b2c11ceac 100644 --- a/app/models/contest.rb +++ b/app/models/contest.rb @@ -72,11 +72,14 @@ class Contest < ActiveRecord::Base end end - def self.creat_contests(budget, deadline, name, description=nil) - self.create(:author_id => User.current.id, :budget => budget, - :deadline => deadline, :name => name, :description => description, :commit => 0) - end - + # modified by longjun + # 这个函数没有用到 + # def self.creat_contests(budget, deadline, name, description=nil) + # self.create(:author_id => User.current.id, :budget => budget, + # :deadline => deadline, :name => name, :description => description, :commit => 0) + # end + # end longjun + def update_contests(budget, deadline, name, description=nil) if(User.current.id == self.author_id) self.name = name diff --git a/app/models/contesting_project.rb b/app/models/contesting_project.rb index cb2a7fe39..641990b8a 100644 --- a/app/models/contesting_project.rb +++ b/app/models/contesting_project.rb @@ -14,7 +14,7 @@ class ContestingProject < ActiveRecord::Base validate :validate_project validates_uniqueness_of :contest_id, :scope => :project_id - def self.cerate_contesting(contest_id, project_id, description = nil) + def self.create_contesting(contest_id, project_id, description = nil) self.create(:user_id => User.current.id, :contest_id => contest_id, :project_id => project_id, :description => description) end diff --git a/app/views/contests/_new.html.erb b/app/views/contests/_new.html.erb index 7ef0e71f1..a72ff6f36 100644 --- a/app/views/contests/_new.html.erb +++ b/app/views/contests/_new.html.erb @@ -30,7 +30,18 @@ <% if User.current.logged? %> - + + + +
<%= f.text_area 'message', :rows => 3, :cols => 65, :placeholder => l(:label_my_respond), :style => "resize: none;", :class => 'noline'%> + <%= f.text_area 'message', + :rows => 3, + :cols => 65, + :placeholder => l(:label_my_respond), + :style => "resize: none;", + :class => 'noline' + %> +
@@ -39,8 +50,23 @@ - + + +
<%= submit_tag l(:button_leave_meassge), :name => nil , :class => "contest_btn", :onmouseout => "this.style.backgroundPosition = 'left top'", :onmouseover => "this.style.backgroundPosition = 'left -31px'"%> - <%= submit_tag l(:button_clear_meassge), :name => nil, :onclick => "clearMessage('contest_message_message');", :type => 'button', :class => "bid_btn", :onmouseout => "this.style.backgroundPosition = 'left top'", :onmouseover => "this.style.backgroundPosition = 'left -31px'" %> + <%= submit_tag l(:button_leave_meassge), + :name => nil , + :class => "contest_btn", + :onmouseout => "this.style.backgroundPosition = 'left top'", + :onmouseover => "this.style.backgroundPosition = 'left -31px'" + %> + <%= submit_tag l(:button_clear_meassge), + :name => nil, + :onclick => "clearMessage('contest_message_message');", + :type => 'button', :class => "bid_btn", + :onmouseout => "this.style.backgroundPosition = 'left top'", + :onmouseover => "this.style.backgroundPosition = 'left -31px'" + %> +