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 1/4] =?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'" + %> +
From 64eb4d362c219272396cbd9f2a211df93fd70d3a Mon Sep 17 00:00:00 2001 From: alan <547533434@qq.com> Date: Thu, 11 Sep 2014 00:33:12 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E5=B0=86contest=E4=B8=BB=E9=A1=B5=E4=B8=AD?= =?UTF-8?q?=E9=80=9A=E7=9F=A5=E5=85=AC=E5=91=8A=E7=9A=84=E9=A2=9C=E8=89=B2?= =?UTF-8?q?=E6=94=B9=E6=88=90=E8=93=9D=E8=89=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: alan <547533434@qq.com> --- app/helpers/application_helper.rb | 18 +++++++++--------- app/helpers/contests_helper.rb | 4 ++-- app/views/welcome/contest.html.erb | 2 +- config/routes.rb | 2 +- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 4ab09db38..ef18793ab 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -679,15 +679,15 @@ module ApplicationHelper def textilizable(*args) options = args.last.is_a?(Hash) ? args.pop : {} case args.size - when 1 - obj = options[:object] - text = args.shift - when 2 - obj = args.shift - attr = args.shift - text = obj.send(attr).to_s - else - raise ArgumentError, 'invalid arguments to textilizable' + when 1 + obj = options[:object] + text = args.shift + when 2 + obj = args.shift + attr = args.shift + text = obj.send(attr).to_s + else + raise ArgumentError, 'invalid arguments to textilizable' end return '' if text.blank? project = options[:project] || @project || (obj && obj.respond_to?(:project) ? obj.project : nil) diff --git a/app/helpers/contests_helper.rb b/app/helpers/contests_helper.rb index 67d1c3b3f..0bc3e5e73 100644 --- a/app/helpers/contests_helper.rb +++ b/app/helpers/contests_helper.rb @@ -100,10 +100,10 @@ module ContestsHelper def count_contest_project contests = Contest.find(:id) @projects = [] - # Modified by alan + # Modified by longjun # for contest in contests contests.each do |contest| - # end alan + # end longjun @projects += contest.contesting_projects end @projects.count diff --git a/app/views/welcome/contest.html.erb b/app/views/welcome/contest.html.erb index 3554f85dd..39716d50d 100644 --- a/app/views/welcome/contest.html.erb +++ b/app/views/welcome/contest.html.erb @@ -191,7 +191,7 @@
-

+

<%=l(:label_notification)%>

diff --git a/config/routes.rb b/config/routes.rb index 33b5cd16a..17be94f9d 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -161,7 +161,7 @@ RedmineApp::Application.routes.draw do #end root :to => 'welcome#index', :as => 'home' - + match 'welcome/contest', :to => 'welcome#contest', :via => :get #added by baiyu match 'git_usage/ch_usage', :controller => 'git_usage', :action => 'ch_usage', :via => :get, :as => 'ch_usage' match 'git_usage/en_usage', :controller => 'git_usage', :action => 'en_usage', :via => :get, :as => 'en_usage' From dea1a299af914c9c15a016ec3c02110f93ecac48 Mon Sep 17 00:00:00 2001 From: alan <547533434@qq.com> Date: Fri, 12 Sep 2014 16:45:03 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E4=BF=AE=E6=94=B9competition=E7=9A=84view?= =?UTF-8?q?=E6=96=87=E4=BB=B6=EF=BC=8C=E5=B0=86=E5=85=B6=E4=B8=AD=E4=B8=8D?= =?UTF-8?q?=E8=A7=84=E8=8C=83=E7=9A=84=E4=BB=A3=E7=A0=81=E8=BF=9B=E8=A1=8C?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=EF=BC=8C=E5=B9=B6=E5=B0=86=E5=85=B6=E4=B8=AD?= =?UTF-8?q?=E6=89=80=E6=9C=89=E7=9A=84link=5Fto=20=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E6=88=90"link=5Fto=20=E2=80=98welcome=E2=80=99=20home=5Fpath,?= =?UTF-8?q?=20=20{option}"=20=E7=9A=84=E5=BD=A2=E5=BC=8F=EF=BC=9B=20?= =?UTF-8?q?=E7=BB=9F=E4=B8=80route=E9=A3=8E=E6=A0=BC=20match=20'path',=20:?= =?UTF-8?q?to=20=3D>=20'controller#action'=20=E5=A6=82=E6=9E=9C=20path=20?= =?UTF-8?q?=3D=20controller#action=20=E5=88=99=20match=20'path'=20Example:?= =?UTF-8?q?=20match=20'welcome/course',=20:to=20=3D>=20'welcome#course'=20?= =?UTF-8?q?=E5=8F=98=E6=88=90=20match=20'welcome/cource'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: alan <547533434@qq.com> --- app/views/boards/_project_show.html.erb | 7 +- app/views/contest_notification/show.html.erb | 8 +- app/views/contestnotifications/_form.html.erb | 19 +- app/views/contestnotifications/_news.html.erb | 37 ++- app/views/contestnotifications/edit.html.erb | 10 +- app/views/contestnotifications/new.html.erb | 4 +- app/views/contestnotifications/show.html.erb | 54 ++- app/views/contests/_contest_list.html.erb | 77 ++++- app/views/contests/_form_contest.html.erb | 50 ++- app/views/contests/_history.html.erb | 80 +++-- app/views/contests/_list_projects.html.erb | 5 +- .../contests/_list_softapplications.html.erb | 9 +- app/views/contests/_new_join.html.erb | 13 +- .../contests/_new_softapplication.html.erb | 68 +++- app/views/contests/_pre_show.html.erb | 7 +- app/views/contests/_project_list.html.erb | 8 +- .../contests/_softapplication_list.html.erb | 15 +- app/views/contests/index.html.erb | 38 ++- app/views/contests/new_contest.html.erb | 12 +- app/views/contests/set_reward_project.js.erb | 31 +- .../set_reward_softapplication.js.erb | 32 +- app/views/contests/settings.html.erb | 3 +- .../contests/show_attendingcontest.html.erb | 19 +- app/views/contests/show_contest.html.erb | 23 +- app/views/contests/show_contest_user.html.erb | 7 +- app/views/contests/show_participator.html.erb | 6 +- app/views/contests/show_project.html.erb | 43 ++- .../contests/show_softapplication.html.erb | 40 ++- config/routes.rb | 311 +++++++++--------- 29 files changed, 719 insertions(+), 317 deletions(-) diff --git a/app/views/boards/_project_show.html.erb b/app/views/boards/_project_show.html.erb index a14e32d6d..199155838 100644 --- a/app/views/boards/_project_show.html.erb +++ b/app/views/boards/_project_show.html.erb @@ -67,12 +67,15 @@ <% @topics.each do |topic| %> - +
<%= link_to image_tag(url_to_avatar(topic.author), :class => "avatar"), user_path(topic.author) %> + <%= link_to image_tag(url_to_avatar(topic.author), :class => "avatar"), user_path(topic.author) %> +     + +    

diff --git a/app/views/contests/show_attendingcontest.html.erb b/app/views/contests/show_attendingcontest.html.erb index 799656f36..b9616043d 100644 --- a/app/views/contests/show_attendingcontest.html.erb +++ b/app/views/contests/show_attendingcontest.html.erb @@ -79,16 +79,27 @@ <%= render_flash_messages %>
-
<%= l(:label_wellmeaning_intimation_contentone) %>
-
1) <%= l(:label_wellmeaning_intimation_contenttwo) %>
-
2) <%= l(:label_wellmeaning_intimation_contentthree) %>
+
+ <%= l(:label_wellmeaning_intimation_contentone) %> +
+
+ 1) <%= l(:label_wellmeaning_intimation_contenttwo) %> +
+
+ 2) <%= l(:label_wellmeaning_intimation_contentthree) %> +
<% if User.current.logged? %>
<%= l(:label_attending_contest) %>: - <%= link_to l(:label_new_attendingcontest_work), "javascript:void(0);", onclick: "$('#put-project-form').slideToggle();" %> + + <%= link_to l(:label_new_attendingcontest_work), + "javascript:void(0);", + onclick: "$('#put-project-form').slideToggle();" + %> +
<% else %> diff --git a/app/views/contests/show_contest.html.erb b/app/views/contests/show_contest.html.erb index 121f5e690..11937d2bd 100644 --- a/app/views/contests/show_contest.html.erb +++ b/app/views/contests/show_contest.html.erb @@ -2,9 +2,18 @@
<%= image_tag(url_to_avatar(@contest.author), :class => "avatar")%> -

<%= link_to(@contest.author.lastname+@contest.author.firstname, user_path(@contest.author))%>:<%= @contest.name %>

+

+ <%= link_to(@contest.author.lastname+@contest.author.firstname, + user_path(@contest.author)) + %> + :<%= @contest.name %>

- <%= l(:label_bids_reward_method) %><%= @contest.budget%> + + <%= l(:label_bids_reward_method) %> + + <%= @contest.budget%> + +

<%= @contest.description %> @@ -15,7 +24,11 @@
<%= render :partial => "/praise_tread/praise_tread", - :locals => {:obj => @contest,:show_flag => true,:user_id =>User.current.id,:horizontal => false}%> + :locals => {:obj => @contest, + :show_flag => true, + :user_id =>User.current.id, + :horizontal => false} + %>
@@ -23,7 +36,9 @@
- <%= render :partial => 'history', :locals => { :contest => @contest, :journals => @jour, :state => false} %> + <%= render :partial => 'history', + :locals => { :contest => @contest, :journals => @jour, :state => false} + %>
<%= link_to h(topic.subject.truncate(40,ommision:'...')), board_message_path(@board, topic),title:topic.subject.to_s %> + <%= topic.locked? ? 'locked' : '' %>"> + <%= link_to h(topic.subject.truncate(40,ommision:'...')), board_message_path(@board, topic),title:topic.subject.to_s %> diff --git a/app/views/contest_notification/show.html.erb b/app/views/contest_notification/show.html.erb index 93fa1f4af..5664d5398 100644 --- a/app/views/contest_notification/show.html.erb +++ b/app/views/contest_notification/show.html.erb @@ -9,8 +9,12 @@ - - + +
contest.trustie.net<%=link_to l(:field_homepage), home_path %> > <%=link_to l(:label_contest_innovate), :controller => 'welcome', :action => 'contest' %> > 详情 + contest.trustie.net + + <%=link_to l(:field_homepage), home_path %> > + <%=link_to l(:label_contest_innovate), welcome_contest_path %> > 详情
diff --git a/app/views/contestnotifications/_form.html.erb b/app/views/contestnotifications/_form.html.erb index afcb60657..36bcd78c6 100644 --- a/app/views/contestnotifications/_form.html.erb +++ b/app/views/contestnotifications/_form.html.erb @@ -3,8 +3,23 @@ <%= l(:bale_news_notice) %>
-

<%= f.text_field :title, :required => true, :size => 60,:maxlength => 60, :style => "width:488px;" %>

-

<%= f.text_area :description, :required => true, :cols => 60, :rows => 11, :class => 'wiki-edit', :style => "width:490px;" %>

+

+ <%= f.text_field :title, + :required => true, + :size => 60, + :maxlength => 60, + :style => "width:488px;" + %> +

+

+ <%= f.text_area :description, + :required => true, + :cols => 60, + :rows => 11, + :class => 'wiki-edit', + :style => "width:490px;" + %> +

diff --git a/app/views/contestnotifications/_news.html.erb b/app/views/contestnotifications/_news.html.erb index fbac2557f..c8af85cf4 100644 --- a/app/views/contestnotifications/_news.html.erb +++ b/app/views/contestnotifications/_news.html.erb @@ -2,24 +2,47 @@ + <%# unless news.summary.blank? %>
<%#= link_to h(news.title), news_path(news) %> <%#= "(#{l(:label_x_comments, :count => news.comments_count)})" if news.comments_count > 0 %> - <%# unless news.summary.blank? %><%#=h news.summary %><% end %><%#=h news.summary %> <%#= authoring news.created_on, news.author %>

--> - + - - + +
+ + - - + - - + diff --git a/app/views/contestnotifications/edit.html.erb b/app/views/contestnotifications/edit.html.erb index 7b91d922c..1606d97d6 100644 --- a/app/views/contestnotifications/edit.html.erb +++ b/app/views/contestnotifications/edit.html.erb @@ -1,9 +1,15 @@

<%=l(:label_news)%>

-<%= labelled_form_for @contestnotification, url: contest_contestnotification_path, :html => { :id => 'contestnotifications-form', :multipart => true, :method => :put } do |f| %> +<%= labelled_form_for @contestnotification, + :url => contest_contestnotification_path, + :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(id: @contestnotification), 'contestnotifications-form' %> +<%= preview_link preview_contestnotifications_path(id: @contestnotification), + 'contestnotifications-form' +%> <% end %>
diff --git a/app/views/contestnotifications/new.html.erb b/app/views/contestnotifications/new.html.erb index 30d5f0106..a5a1c7e58 100644 --- a/app/views/contestnotifications/new.html.erb +++ b/app/views/contestnotifications/new.html.erb @@ -1,5 +1,7 @@ -<%= labelled_form_for @contestnotification, :url => contest_contestnotifications_path(@contest), :html => { :id => 'contestnotifications-form', :multipart => true } do |f| %> +<%= labelled_form_for @contestnotification, + :url => contest_contestnotifications_path(@contest), + :html => { :id => 'contestnotifications-form', :multipart => true } do |f| %> <%= render :partial => 'contestnotifications/form', :locals => { :f => f } %> <%= submit_tag l(:button_create), :class => "whiteButton m3p10 h30" %> <%= submit_tag l(:button_cancel), :class => "whiteButton m3p10 h30",:onclick => "cancel();" %> diff --git a/app/views/contestnotifications/show.html.erb b/app/views/contestnotifications/show.html.erb index b6ac88008..a44ee5909 100644 --- a/app/views/contestnotifications/show.html.erb +++ b/app/views/contestnotifications/show.html.erb @@ -1,21 +1,26 @@
<%= link_to(l(:button_edit), - edit_contest_contestnotification_path(@contest, @contestnotification), - :class => 'icon icon-edit', - :accesskey => accesskey(:edit), - :onclick => '$("#edit-contestnotifications").show(); return true;') if (User.current.admin? && User.current.logged? )||(User.current == @contest.author && User.current.logged?)%> + edit_contest_contestnotification_path(@contest, @contestnotification), + :class => 'icon icon-edit', + :accesskey => accesskey(:edit), + :onclick => '$("#edit-contestnotifications").show(); return true;') if (User.current.admin? && User.current.logged? )||(User.current == @contest.author && User.current.logged?)%> <%= delete_link contest_contestnotification_path(@contest, @contestnotification) if (User.current.admin? && User.current.logged? )||(User.current == @contest.author && User.current.logged?) %>

<%=h @contestnotification.title %>

@@ -23,7 +28,9 @@
- <%= textilizable(@contestnotification, :description) %> + + <%= textilizable(@contestnotification, :description) %> +
<%#= link_to_attachments @contestnotification %>
@@ -31,16 +38,26 @@ <% if User.current.logged? %>

- <%= toggle_link l(:label_comment_add), "add_notificationcomment_form", :focus => "notificationcomment_notificationcomments" %> + <%= toggle_link l(:label_comment_add), + "add_notificationcomment_form", + :focus => "notificationcomment_notificationcomments" + %>

<% else %> <%= l(:label_user_login_notificationcomment) %> <%= link_to l(:label_user_login_new), signin_path %> <% end %> - <%= form_tag( contest_contestnotification_notificationcomments_path(@contest, @contestnotification) , :id => "add_notificationcomment_form", :style => "display:none;") do %> + <%= form_tag( contest_contestnotification_notificationcomments_path(@contest, @contestnotification) , + :id => "add_notificationcomment_form", + :style => "display:none;") do %>
- <%= text_area 'notificationcomment', 'notificationcomments', :cols => 80, :rows => 15, :class => 'wiki-edit' %> + <%= text_area 'notificationcomment', + 'notificationcomments', + :cols => 80, + :rows => 15, + :class => 'wiki-edit' + %> <%= wikitoolbar_for 'notificationcomment_notificationcomments' %>

@@ -65,7 +82,9 @@ <% next if notificationcomment.new_record? %>

<%=link_to contestnotifications.author,contest_contestnotification_path(contestnotifications)%> - <%= l(:label_project_newshare) %> <%= link_to h(contestnotifications.title), contest_contestnotification_path(contestnotifications) %> + + + <%=link_to contestnotifications.author, + contest_contestnotification_path(contestnotifications) + %> + + + <%= l(:label_project_newshare) %> + + <%= link_to h(contestnotifications.title), + contest_contestnotification_path(contestnotifications) + %>

<%=h contestnotifications.description%>

+

+ <%=h contestnotifications.description%> +

+
<%= contestnotifications.created_at %><%= link_to l(:label_project_newother),contest_contestnotification_path(contestnotifications)%> + + + <%= contestnotifications.created_at %> + + + <%= link_to l(:label_project_newother), + contest_contestnotification_path(contestnotifications) + %> <%= "(#{l(:label_x_comments, :count => contestnotifications.notificationcomments_count)})" if contestnotifications.notificationcomments_count > 0 %>
- + <%= l(:label_work_name) %> * : - + (<%= l(:label_workname_lengthlimit) %>)
@@ -101,7 +108,12 @@ <%= l(:label_running_platform) %> * : (<%= l(:label_workdescription_lengthlimit) %>) @@ -116,7 +128,9 @@ <%#= select_tag 'app_type_name', work_type_opttion, {:name => 'app_type_name',:style => "width:358px;"} %> - <%= f.select :app_type_name,work_type_opttion, {},{:style => "width:328px;",:onchange => "selectChange(this)"} %> + <%= f.select :app_type_name,work_type_opttion, + {}, + {:style => "width:328px;",:onchange => "selectChange(this)"} %> <%#= f.text_field :app_type_name, :required => true, :size => 60, :style => "width:400px;" %> <%= l(:label_work_description) %> * : - +
@@ -141,8 +161,17 @@ <%= l(:label_softapplication_developers) %> * : - - (<%= l(:label_workdescription_lengthlimit) %>) + + + (<%= l(:label_workdescription_lengthlimit) %>) +

@@ -150,8 +179,23 @@ <%= l(:label_work_deposit_project) %>: - <%= select_tag 'project', options_for_select(select_option_helper(@option)), :name => 'project', :class => 'grayline2',:style => "width:328px;" %> - <%= link_to l(:label_create_new_projects),{:controller => 'projects',:action => 'new',course: 0, project_type: 0,host: Setting.project_domain}, :target => '_blank' %> + + <%= select_tag 'project', + options_for_select(select_option_helper(@option)), + :name => 'project', + :class => 'grayline2', + :style => "width:328px;" + %> + + + + + <%= link_to l(:label_create_new_projects), + new_project_path(:course => 0, :project_type => 0, :host => Setting.project_domain), + :target => '_blank' + %> + +

@@ -177,8 +221,12 @@
<%#= submit_tag l(:button_create) %> - <%= submit_tag l(:button_cancel), :name => nil, :onclick => "cancel();", - :type => 'button', :class => "enterprise", :onmouseout => "this.style.backgroundPosition = 'left top'", + <%= submit_tag l(:button_cancel), + :name => nil, + :onclick => "cancel();", + :type => 'button', + :class => "enterprise", + :onmouseout => "this.style.backgroundPosition = 'left top'", :onmouseover => "this.style.backgroundPosition = 'left -30px'" %>
<% end %> \ No newline at end of file diff --git a/app/views/contests/_pre_show.html.erb b/app/views/contests/_pre_show.html.erb index fef1f16e4..67ceeb356 100644 --- a/app/views/contests/_pre_show.html.erb +++ b/app/views/contests/_pre_show.html.erb @@ -5,7 +5,12 @@ - +
<%= image_tag(url_to_avatar(notificationcomment.author), :class => "avatar")%> + <%= image_tag(url_to_avatar(notificationcomment.author), :class => "avatar")%> + @@ -80,8 +99,9 @@ @@ -92,7 +112,11 @@

- + diff --git a/app/views/contests/_contest_list.html.erb b/app/views/contests/_contest_list.html.erb index a91978079..967d31459 100644 --- a/app/views/contests/_contest_list.html.erb +++ b/app/views/contests/_contest_list.html.erb @@ -4,7 +4,10 @@ +  <%= link_to(contest.name, + contest_contestnotifications_path(contest), + :class => 'bid_path', + :target => "_blank") %> - +
@@ -31,5 +34,7 @@ <% end %>
<% end %> - + diff --git a/app/views/contests/_new_join.html.erb b/app/views/contests/_new_join.html.erb index 3b0cff690..fc638d218 100644 --- a/app/views/contests/_new_join.html.erb +++ b/app/views/contests/_new_join.html.erb @@ -50,8 +50,17 @@ <%= text_field_tag 'contest_password', nil, :size => 45 %>

- <%= submit_tag l(:label_new_join), :name => nil, :class => "contest_btn", :onclick => "hideModal(this);" %> - <%= submit_tag l(:button_cancel), :name => nil, :class => "contest_btn", :onclick => "hideModal(this);", :type => 'button' %> + <%= submit_tag l(:label_new_join), + :name => nil, :class => "contest_btn", + :onclick => "hideModal(this);" + %> + <%= submit_tag l(:button_cancel), + :name => nil, + :class => "contest_btn", + :onclick => "hideModal(this);", + :type => 'button' + %> +

<% if notificationcomment.author==User.current|| User.current.admin? %> - <%= link_to(l(:label_bid_respond_delete), contest_contestnotification_notificationcomment_path(@contest, @contestnotification,notificationcomment), - :method => :delete,:confirm => l(:text_are_you_sure), :title => l(:button_delete)) %> + <%= link_to(l(:label_bid_respond_delete), + contest_contestnotification_notificationcomment_path(@contest, @contestnotification,notificationcomment), + :method => :delete,:confirm => l(:text_are_you_sure), :title => l(:button_delete)) %> <% end %>
<%= format_time(notificationcomment.created_at) %> + + <%= format_time(notificationcomment.created_at) %> + + <%#= link_to_if_authorized_contest image_tag('delete.png'), {:controller => 'notificationcomments', :action => 'destroy', :id => @contestnotifications, :notificationcomment_id => notificationcomment}, :data => {:confirm => l(:text_are_you_sure)}, :method => :delete, :title => l(:button_delete) %>
<% unless contest.author.nil? %> - <%= link_to(image_tag(url_to_avatar(contest.author), :class => 'avatar'), user_path(contest.author), :class => "avatar") %> + <%= link_to(image_tag(url_to_avatar(contest.author), :class => 'avatar'), + user_path(contest.author), + :class => "avatar") + %> <% end %> @@ -12,33 +15,85 @@
<% unless contest.author.nil? %> - <%= link_to(contest.author, user_path(contest.author), :class => 'bid_user') %>: + <%= link_to(contest.author, + user_path(contest.author), + :class => 'bid_user') + %>: <% end %> -  <%= link_to(contest.name, contest_contestnotifications_path(contest), :class => 'bid_path', :target => "_blank") %>
- <%= l(:label_contests_reward_method) %>:  <%= contest.budget%> + <%= l(:label_contests_reward_method) %>:   + + <%= contest.budget%> + +
- - <% if contest.id == 2 or contest.id == 3 or contest.id == 6 %> - <%= l(:label_contest_work, :count => contest.contesting_projects.count) %>(<%= link_to(contest.projects.where('is_public=1').count, show_attendingcontest_contest_path(contest), :target => "_blank") %>) + + + <% if contest.id == 2 || contest.id == 3 || contest.id == 6 %> + <%= l(:label_contest_work, + :count => contest.contesting_projects.count) + %> + ( + + <%= link_to(contest.projects.where('is_public=1').count, + show_attendingcontest_contest_path(contest), + :target => "_blank") + %> + + ) <% else %> - <%= l(:label_contest_work, :count => contest.contesting_softapplications.count) %>(<%= link_to(contest.contesting_softapplications.count, show_attendingcontest_contest_path(contest), :target => "_blank") %>) + <%= l(:label_contest_work, + :count => contest.contesting_softapplications.count) + %> + ( + + <%= link_to(contest.contesting_softapplications.count, + show_attendingcontest_contest_path(contest), + :target => "_blank") %> + + ) <% end %>
<%= l :label_create_time %>: <%= format_time contest.created_on %> + + <%= l :label_create_time %>: <%= format_time contest.created_on %> + +
@@ -58,6 +113,6 @@ diff --git a/app/views/contests/_form_contest.html.erb b/app/views/contests/_form_contest.html.erb index 79c531969..68e941a27 100644 --- a/app/views/contests/_form_contest.html.erb +++ b/app/views/contests/_form_contest.html.erb @@ -20,17 +20,55 @@ <%= error_messages_for 'contest' %> -

<%= l(:label_bids_form_contest_new_description) %>

-

<%= f.text_field :name, :required => true, :size => 60, :style => "width:490px;", :maxlength => Contest::NAME_LENGTH_LIMIT, :placeholder => "#{l(:label_contest_name)}" %>

+

+ <%= l(:label_bids_form_contest_new_description) %> +

+

+ <%= f.text_field :name, + :required => true, + :size => 60, + :style => "width:490px;", + :maxlength => Contest::NAME_LENGTH_LIMIT, + :placeholder => "#{l(:label_contest_name)}" + %> +

-

<%= f.text_area :description, :rows => 5, :class => 'wiki-edit', :style => "font-size:small;width:490px;margin-left:10px;", :maxlength => Contest::DESCRIPTION_LENGTH_LIMIT, :placeholder => "#{l(:label_contest_description)}" %>

+

+ <%= f.text_area :description, + :rows => 5, + :class => 'wiki-edit', + :style => "font-size:small;width:490px;margin-left:10px;", + :maxlength => Contest::DESCRIPTION_LENGTH_LIMIT, + :placeholder => "#{l(:label_contest_description)}" + %> +

-

<%= f.text_field :password, :size => 60, :style => "width:488px;margin-left: 10px;" %>

+

+ <%= f.text_field :password, + :size => 60, + :style => "width:488px;margin-left: 10px;" + %> +

- <%= f.text_area :budget, :required => true, :size => 60,:rows => 4,:maxlength => Contest::DESCRIPTION_LENGTH_LIMIT, :style => "width:490px;", :placeholder => l(:label_bids_reward_what) %> + <%= f.text_area :budget, + :required => true, + :size => 60, + :rows => 4, + :maxlength => Contest::DESCRIPTION_LENGTH_LIMIT, + :style => "width:490px;", + :placeholder => l(:label_bids_reward_what) + %>

-

<%= f.text_field :deadline, :required => true, :size => 60, :style => "width:150px;", :placeholder => "#{l(:label_deadline)}" %><%= calendar_for('contest_deadline')%>

+

+ <%= f.text_field :deadline, + :required => true, + :size => 60, + :style => "width:150px;", + :placeholder => "#{l(:label_deadline)}" + %> + <%= calendar_for('contest_deadline')%> +

diff --git a/app/views/contests/_history.html.erb b/app/views/contests/_history.html.erb index 6be572c65..f59bc0fc7 100644 --- a/app/views/contests/_history.html.erb +++ b/app/views/contests/_history.html.erb @@ -11,36 +11,66 @@
    <% for journal in journals%>
  • - <%= image_tag(url_to_avatar(journal.user), :class => "avatar") %> - - <%= link_to journal.user, user_path(journal.user)%> - <% label = l(:label_contest_requirement) %> -
    <%= textilizable journal.notes%>
    - <%= l(:label_bids_published) %> <%= time_tag(journal.created_on).html_safe %> <%= l(:label_bids_published_ago) %> - - <% ids = 'project_respond_form_'+ journal.id.to_s%> - - - <% if reply_allow %> - <%#= link_to(l(:button_quote), {:controller => 'contests', :action => 'new', :id => contest, :journal_id => journal}, :remote => true, :method => 'post', :title => l(:button_quote))%> - <%= link_to(l(:button_quote), contests_path(:id => contest, :journal_id => journal), :remote => true, :method => 'post', :title => l(:button_quote))%> - <%= link_to l(:label_bid_respond_quote),'', - {:focus => 'project_respond', :onclick => "toggleAndSettingWordsVal($('##{ids}'), $('##{ids} textarea'), '#{l(:label_reply_plural)} #{journal.user.show_name}: '); $('##{ids} textarea') ;return false;"}%> - <% end %> - - <% if @user==User.current|| User.current.admin? %> - <%#= link_to(l(:label_bid_respond_delete), {:controller => 'bids', :action => 'destroy', :object_id => journal, :id => bid},:confirm => l(:label_delete_confirm), - :remote => true, :method => 'delete', :class => "delete", :confirm => l(:text_are_you_sure), :title => l(:button_delete)) %> - <%= link_to(l(:label_bid_respond_delete), {:controller => 'words', :action => 'destroy', :object_id => journal, :user_id => @user}, :remote => true, :confirm => l(:text_are_you_sure), :method => 'delete', :class => "delete", :title => l(:button_delete)) %> - <% end %> - -
    + + <%= image_tag(url_to_avatar(journal.user), :class => "avatar") %> + + + + <%= link_to journal.user, user_path(journal.user)%> + + + <% label = l(:label_contest_requirement) %> + +
    <%= textilizable journal.notes%>
    + + <%= l(:label_bids_published) %>  + <%= time_tag(journal.created_on).html_safe %>  + <%= l(:label_bids_published_ago) %> + + + <% ids = 'project_respond_form_'+ journal.id.to_s%> + + + <% if reply_allow %> + <%#= link_to(l(:button_quote), {:controller => 'contests', :action => 'new', :id => contest, :journal_id => journal}, :remote => true, :method => 'post', :title => l(:button_quote))%> + <%= link_to(l(:button_quote), + contests_path(:id => contest, + :journal_id => journal), + :remote => true, + :method => 'post', + :title => l(:button_quote)) + %> + <%= link_to l(:label_bid_respond_quote), + '', + {:focus => 'project_respond', + :onclick => "toggleAndSettingWordsVal($('##{ids}'), $('##{ids} textarea'), '#{l(:label_reply_plural)} #{journal.user.show_name}: '); $('##{ids} textarea') ;return false;" + } + %> + <% end %> + + <% if @user==User.current|| User.current.admin? %> + <%#= link_to(l(:label_bid_respond_delete), {:controller => 'bids', :action => 'destroy', :object_id => journal, :id => bid},:confirm => l(:label_delete_confirm), + :remote => true, :method => 'delete', :class => "delete", :confirm => l(:text_are_you_sure), :title => l(:button_delete)) %> + + <%= link_to(l(:label_bid_respond_delete), + + words_destroy_path(:user_id => @user, :object_id => journal), + :remote => true, + :confirm => l(:text_are_you_sure), + :method => 'delete', + :class => "delete", + :title => l(:button_delete)) %> + <% end %> + +
    <% ids = 'project_respond_form_'+ journal.id.to_s%> <% if reply_allow %>
    - <%= render :partial => 'words/new_respond', :locals => {:journal => journal, :m_reply_id => journal} %> + <%= render :partial => 'words/new_respond', + :locals => {:journal => journal, :m_reply_id => journal} + %>
    <% end %>
    diff --git a/app/views/contests/_list_projects.html.erb b/app/views/contests/_list_projects.html.erb index 10086e5a3..fec4cf24c 100644 --- a/app/views/contests/_list_projects.html.erb +++ b/app/views/contests/_list_projects.html.erb @@ -26,8 +26,9 @@
- <%= l(:label_system_grade) %>:<%= (c_project.project.project_status.nil? ? 0.0 : c_project.project.project_status.grade) unless (c_project.project.project_status.nil? && c_project.project.nil?) %> - <% if get_prize(c_project).nil? or get_prize(c_project) == "" %> + <%= l(:label_system_grade) %>: + <%= (c_project.project.project_status.nil? ? 0.0 : c_project.project.project_status.grade) unless (c_project.project.project_status.nil? && c_project.project.nil?) %> + <% if get_prize(c_project).nil? || get_prize(c_project) == "" %> <% if @contest.deadline < Date.today %> <%= l(:label_noawards)%> <% end %> diff --git a/app/views/contests/_list_softapplications.html.erb b/app/views/contests/_list_softapplications.html.erb index 89e8a3172..40a6f1cb2 100644 --- a/app/views/contests/_list_softapplications.html.erb +++ b/app/views/contests/_list_softapplications.html.erb @@ -6,7 +6,10 @@
<%=l(:label_softapplication)%>: - <%= link_to(c_softapplication.softapplication.name, softapplication_path(c_softapplication.softapplication), :target => '_blank') %> + <%= link_to(c_softapplication.softapplication.name, + softapplication_path(c_softapplication.softapplication), + :target => '_blank') + %>
<% end %> diff --git a/app/views/contests/_new_softapplication.html.erb b/app/views/contests/_new_softapplication.html.erb index 9fb3fc7f1..11be49fbc 100644 --- a/app/views/contests/_new_softapplication.html.erb +++ b/app/views/contests/_new_softapplication.html.erb @@ -90,7 +90,14 @@
<%= f.text_field :name, :required => true, :size => 60, :style => "width:320px;", :onblur => "regexName();" %> + <%= f.text_field :name, + :required => true, + :size => 60, + :style => "width:320px;", + :onblur => "regexName();" + %> +
- <%= f.text_field :android_min_version_available, :required => true, :size => 60, :style => "width:320px;", :onblur=>"regexWorkdescription();"%> + <%= f.text_field :android_min_version_available, + :required => true, + :size => 60, + :style => "width:320px;", + :onblur=>"regexWorkdescription();" + %>
<%= f.text_field :description, :required => true, :size => 60, :style => "width:320px;" %> + <%= f.text_field :description, + :required => true, + :size => 60, + :style => "width:320px;" + %> +
<%= f.text_field :application_developers, :required => true, :size => 60, :style => "width:320px;", :onblur => 'regexDevelopers();' %> + <%= f.text_field :application_developers, + :required => true, + :size => 60, + :style => "width:320px;", + :onblur => 'regexDevelopers();' + %> +
<%= textilizable content %>
<%= hidden_field_tag 'reference_content', params[:reference_content], :value => content%> + <%= hidden_field_tag 'reference_content', + params[:reference_content], + :value => content + %> +
<% end %> diff --git a/app/views/contests/_project_list.html.erb b/app/views/contests/_project_list.html.erb index 325e87105..33e884020 100644 --- a/app/views/contests/_project_list.html.erb +++ b/app/views/contests/_project_list.html.erb @@ -2,7 +2,9 @@ <%= render_flash_messages %> - + <% if User.current.logged? %>
<%= l(:label_bidding_project) %>(<%= contesting_project.count%>) + <%= l(:label_bidding_project) %>(<%= contesting_project.count%>) +
@@ -12,4 +14,6 @@ <% end %>
-<%= render :partial=> "list_projects",:locals => {:contesting_project => contesting_project,:contest => @contest }%> +<%= render :partial=> "list_projects", + :locals => {:contesting_project => contesting_project,:contest => @contest } +%> diff --git a/app/views/contests/_softapplication_list.html.erb b/app/views/contests/_softapplication_list.html.erb index e5d030123..d93923d72 100644 --- a/app/views/contests/_softapplication_list.html.erb +++ b/app/views/contests/_softapplication_list.html.erb @@ -2,14 +2,23 @@ <%= render_flash_messages %> - + <% if User.current.logged? %> <% end %>
<%= l(:label_contest_softapplication) %>(<%= @contest.contesting_softapplications.count%>) + <%= l(:label_contest_softapplication) %> + (<%= @contest.contesting_softapplications.count%>) +
- <%= link_to l(:button_contesting_as_application), "javascript:void(0);", onclick: "$('#put-bid-form').toggle();" %> + <%= link_to l(:button_contesting_as_application), + "javascript:void(0);", + onclick: "$('#put-bid-form').toggle();" + %>
-<%= render :partial=> "list_softapplications",:locals => {:contesting_softapplication => contesting_softapplication,:contest => @contest }%> +<%= render :partial=> "list_softapplications", + :locals => {:contesting_softapplication => contesting_softapplication, + :contest => @contest } +%> diff --git a/app/views/contests/index.html.erb b/app/views/contests/index.html.erb index 6f8430ca0..60608fd89 100644 --- a/app/views/contests/index.html.erb +++ b/app/views/contests/index.html.erb @@ -6,22 +6,44 @@
<%= l(:label_user_location) %> : <% if User.current.logged? %> - <% unless User.current.user_extensions.identity == 1 %> - <%= link_to(l(:label_newtype_contest), {:controller => 'contests', :action => 'new_contest'}, :class => 'icon icon-add', :target => "_blank") %> - <% end %> + <% unless User.current.user_extensions.identity == 1 %> + + <%= link_to(l(:label_newtype_contest), contest_new_contest_path, :class => 'icon icon-add', :target => "_blank") %> + + <% end %> <% end %>
<%= link_to request.host()+"/contests", :controller => 'contests', :action => 'index' %> <%=link_to l(:field_homepage), home_path %> > <%=link_to l(:label_contest_innovate), :controller => 'contests', :action => 'index' %> + + + <%= link_to request.host()+"/contests", contests_path %> + + + + <%=link_to l(:field_homepage), home_path %> > + + <%=link_to l(:label_contest_innovate), :controller => 'contests', :action => 'index' %> + +
<% end %> diff --git a/app/views/contests/new_contest.html.erb b/app/views/contests/new_contest.html.erb index 7366b4203..019c8c1db 100644 --- a/app/views/contests/new_contest.html.erb +++ b/app/views/contests/new_contest.html.erb @@ -1,10 +1,12 @@

<%=l(:label_newtype_contest)%>

-<%= labelled_form_for @contest, :url => {:controller => 'contests', :action => 'create_contest'}, method: :post do |f| %> +<%= labelled_form_for @contest, + :url => {:controller => 'contests', :action => 'create_contest'}, + method: :post do |f| %>
- <%= render :partial => 'form_contest', :locals => { :f => f } %> - <%= submit_tag l(:button_create) %> - <%= javascript_tag "$('#bid_name').focus();" %> - <% end %> + <%= render :partial => 'form_contest', :locals => { :f => f } %> + <%= submit_tag l(:button_create) %> + <%= javascript_tag "$('#bid_name').focus();" %> + <% end %>
\ No newline at end of file diff --git a/app/views/contests/set_reward_project.js.erb b/app/views/contests/set_reward_project.js.erb index c0de3e2ef..2ea06abb1 100644 --- a/app/views/contests/set_reward_project.js.erb +++ b/app/views/contests/set_reward_project.js.erb @@ -1,26 +1,27 @@ + $('#reward_result_<%= @contesting_project_id %>').html('<%= j( -if get_prize(@c_p).nil? or get_prize(@c_p) == "" +if get_prize(@c_p).nil? || get_prize(@c_p) == "" if @contest.deadline < Date.today puts '未评奖' end else case get_prize(@c_p) - when '-1' - image_tag("/images/bid/special_reward.png") - when '0' - image_tag("/images/bid/first_reward.png") - when '1' - image_tag("/images/bid/second_reward.png") - when '2' - image_tag("/images/bid/third_reward.png") - when '3' - image_tag("/images/bid/forth_reward.png") - when '4' - image_tag("/images/bid/fifth_reward.png") - when '5' - image_tag("/images/bid/qualified.png") + when '-1' + image_tag("/images/bid/special_reward.png") + when '0' + image_tag("/images/bid/first_reward.png") + when '1' + image_tag("/images/bid/second_reward.png") + when '2' + image_tag("/images/bid/third_reward.png") + when '3' + image_tag("/images/bid/forth_reward.png") + when '4' + image_tag("/images/bid/fifth_reward.png") + when '5' + image_tag("/images/bid/qualified.png") end end diff --git a/app/views/contests/set_reward_softapplication.js.erb b/app/views/contests/set_reward_softapplication.js.erb index a8cf0d486..2906d95d3 100644 --- a/app/views/contests/set_reward_softapplication.js.erb +++ b/app/views/contests/set_reward_softapplication.js.erb @@ -1,26 +1,28 @@ + $('#reward_result_<%= @contesting_softapplication_id %>').html('<%= j( -if get_prize(@c_sa).nil? or get_prize(@c_sa) == "" + +if get_prize(@c_sa).nil? || get_prize(@c_sa) == "" if @contest.deadline < Date.today puts '未评奖' end else case get_prize(@c_sa) - when '-1' - image_tag("/images/bid/special_reward.png") - when '0' - image_tag("/images/bid/first_reward.png") - when '1' - image_tag("/images/bid/second_reward.png") - when '2' - image_tag("/images/bid/third_reward.png") - when '3' - image_tag("/images/bid/forth_reward.png") - when '4' - image_tag("/images/bid/fifth_reward.png") - when '5' - image_tag("/images/bid/qualified.png") + when '-1' + image_tag("/images/bid/special_reward.png") + when '0' + image_tag("/images/bid/first_reward.png") + when '1' + image_tag("/images/bid/second_reward.png") + when '2' + image_tag("/images/bid/third_reward.png") + when '3' + image_tag("/images/bid/forth_reward.png") + when '4' + image_tag("/images/bid/fifth_reward.png") + when '5' + image_tag("/images/bid/qualified.png") end end diff --git a/app/views/contests/settings.html.erb b/app/views/contests/settings.html.erb index a2780f060..4f8b8b0f2 100644 --- a/app/views/contests/settings.html.erb +++ b/app/views/contests/settings.html.erb @@ -1,6 +1,7 @@

-

<%=l(:label_contest_settings)%><%=l(:label_contest_settings)%> <%= image_tag(url_to_avatar(user), :class => "avatar") %> - - +
<%= content_tag "div", link_to_user(user), :class => "project_avatar_name" %> + + + <%= content_tag "div", link_to_user(user), :class => "project_avatar_name" %> +

<% unless user.memberships.empty? %> diff --git a/app/views/contests/show_participator.html.erb b/app/views/contests/show_participator.html.erb index da51aef3a..9c829b9f2 100644 --- a/app/views/contests/show_participator.html.erb +++ b/app/views/contests/show_participator.html.erb @@ -1,5 +1,9 @@ -

<%=link_to l(:label_x_join_in_contest, :count => @contest.join_in_contests.count)+"("+@contest.join_in_contests(@user.id).count.to_s+")", :controller=>"contests", :action=>"show_participator"%>

+

+ <%=link_to l(:label_x_join_in_contest, :count => @contest.join_in_contests.count)+"("+@contest.join_in_contests(@user.id).count.to_s+")", + show_participator_contest_path + %> +

<% for temp in @contest.join_in_contests %> <% user = temp.user %> diff --git a/app/views/contests/show_project.html.erb b/app/views/contests/show_project.html.erb index 3e759cfc1..84dfbbbc2 100644 --- a/app/views/contests/show_project.html.erb +++ b/app/views/contests/show_project.html.erb @@ -60,15 +60,28 @@ <% end %>
- <%= render :partial => 'project_list', :locals => {:contesting_project => @contesting_project,:contest => @contest} %> + <%= render :partial => 'project_list', + :locals => {:contesting_project => @contesting_project,:contest => @contest} + %>
diff --git a/app/views/contests/show_softapplication.html.erb b/app/views/contests/show_softapplication.html.erb index d12a70e35..7bb4b0231 100644 --- a/app/views/contests/show_softapplication.html.erb +++ b/app/views/contests/show_softapplication.html.erb @@ -60,15 +60,29 @@
+ + +
+ <%= render "new_softapplication" %> +
+ <% else %>
<%= l(:label_user_login_attending_contest) %> @@ -109,10 +115,7 @@
<% end %> - -
- <%= render "new_softapplication" %> -
+