diff --git a/app/controllers/bids_controller.rb b/app/controllers/bids_controller.rb index e3cc685a7..1042c8809 100644 --- a/app/controllers/bids_controller.rb +++ b/app/controllers/bids_controller.rb @@ -24,7 +24,7 @@ class BidsController < ApplicationController # elsif # @bids = Bid.visible.where('reward_type = ? or reward_type = ?', 4) else - @bids = Bid.visible.where('reward_type = ? or reward_type = ?', 1, 2) + @bids = Bid.visible.where('reward_type = ?', 1) end @bids = @bids.like(params[:name]) if params[:name].present? @@ -76,6 +76,64 @@ class BidsController < ApplicationController #end end + def contest + @project_type = params[:project_type] + # Modified by nie + # @requirement_title = "4" + @offset, @limit = api_offset_and_limit({:limit => 10}) + + @bids = Bid.visible.where('reward_type = ?', 2) + + # elsif + # @bids = Bid.visible.where('reward_type = ? or reward_type = ?', 4) + @bids = @bids.like(params[:name]) if params[:name].present? + @bid_count = @bids.count + @bid_pages = Paginator.new @bid_count, @limit, params['page'] + + @offset ||= @bid_pages.reverse_offset + #added by nie + if params[:bid_sort_type].present? + case params[:bid_sort_type] + when '0' + unless @offset == 0 + @bids = @bids.offset(@offset).limit(@limit).all.reverse + else + limit = @bid_count % @limit + limit = @limit if limit == 0 + @bids = @bids.offset(@offset).limit(limit).all.reverse + end + @s_state = 0 + when '1' + unless @offset == 0 + @bids = @bids.reorder('bids.commit').offset(@offset).limit(@limit).all.reverse + else + limit = @bid_count % @limit + limit = @limit if limit == 0 + @bids = @bids.reorder('bids.commit').offset(@offset).limit(limit).all.reverse + end + @s_state = 1 + when '2' + unless @offset == 0 + @bids = @bids.offset(@offset).limit(@limit).all.reverse + else + limit = @bid_count % @limit + limit = @limit if limit == 0 + @bids = @bids.offset(@offset).limit(@limit).all.reverse + end + @s_state = 0 + end + else + unless @offset == 0 + @bids = @bids.reorder('bids.commit').offset(@offset).limit(@limit).all.reverse + else + limit = @bid_count % @limit + limit = @limit if limit == 0 + @bids = @bids.reorder('bids.commit').offset(@offset).limit(limit).all.reverse + end + @s_state = 1 + end + end + def fork @courses = [] @membership = User.current.memberships.all(:conditions => Project.visible_condition(User.current)) @@ -307,6 +365,36 @@ class BidsController < ApplicationController @bid = Bid.new @bid.safe_attributes = params[:bid] end + + #huang + def create_contest + @bid = Bid.new + @bid.name = params[:bid][:name] + @bid.description = params[:bid][:description] + @bid.reward_type = params[:bid_reward_type] + @bid.budget = params[:bid][:budget] + @bid.deadline = params[:bid][:deadline] + @bid.author_id = User.current.id + @bid.commit = 0 + if @bid.save + unless @bid.watched_by?(User.current) + if @bid.add_watcher(User.current) + flash[:notice] = l(:label_bid_succeed) + end + end + redirect_to respond_path(@bid) + else + @bid.safe_attributes = params[:bid] + render :action => 'new_bid' + end + end + + + #huang + def new_contest + @bid = Bid.new + @bid.safe_attributes = params[:bid] + end def create_bid @bid = Bid.new diff --git a/app/views/bids/_form.html.erb b/app/views/bids/_form.html.erb index 4b1530714..70fec0960 100644 --- a/app/views/bids/_form.html.erb +++ b/app/views/bids/_form.html.erb @@ -1,5 +1,5 @@ - +<% else %> - <%= error_messages_for 'bid' %>

<%= l(:label_bids_form_new_description) %>

@@ -34,4 +33,5 @@

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

\ No newline at end of file +

+ diff --git a/app/views/bids/_form_contest.html.erb b/app/views/bids/_form_contest.html.erb new file mode 100644 index 000000000..d41f4f880 --- /dev/null +++ b/app/views/bids/_form_contest.html.erb @@ -0,0 +1,34 @@ + + +<%= error_messages_for 'bid' %> + +

<%= l(:label_bids_form_contest_new_description) %>

+

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

+ +

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

+

<%= select_tag 'bid_reward_type', "".html_safe, + :onChange => "show('bid_reward_type', 'bid_budget', '"+l(:label_bids_reward_what)+"','"+l(:label_bids_new_money)+"','"+l(:label_bids_new_credit)+"','"+l(:label_bids_new_content)+"')" %> + <%= f.text_field :budget, :required => true, :size => 60, :style => "width:350px;", :placeholder => l(:label_bids_reward_what) %> + + +

+ +

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

diff --git a/app/views/bids/contest.html.erb b/app/views/bids/contest.html.erb new file mode 100644 index 000000000..c5a97f0b9 --- /dev/null +++ b/app/views/bids/contest.html.erb @@ -0,0 +1,53 @@ + +<%= form_tag(calls_path, :method => :get) do %> +
+ + + + + + +
+ 竞赛列表 + <% if User.current.logged? %> + + + <%= link_to(l(:label_newtype_contest), {:controller => 'bids', :action => 'new_contest'}, :class => 'icon icon-add') %> + + + <% end %> +
+
+<%end%> + +<% if User.current.logged? %> + +<% end %> + +<%= sort_bid(@s_state, @project_type)%> + + + + +
+ <%= render :partial => 'contest_show', :locals => {:bids => @bids, :bid_pages => @bid_pages} %> +
+ diff --git a/app/views/bids/new_contest.html.erb b/app/views/bids/new_contest.html.erb new file mode 100644 index 000000000..df35523e3 --- /dev/null +++ b/app/views/bids/new_contest.html.erb @@ -0,0 +1,10 @@ + +

<%=l(:label_newtype_contest)%>

+ +<%= labelled_form_for @bid, :url => {:controller => 'bids', :action => 'create_bid'} do |f| %> +
+ <%= 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/layouts/base_courses.html.erb b/app/views/layouts/base_courses.html.erb index c12a8ea0e..7d7f6f6c9 100644 --- a/app/views/layouts/base_courses.html.erb +++ b/app/views/layouts/base_courses.html.erb @@ -87,13 +87,10 @@ <%= l(:label_main_teacher) %><%= @course.teacher.lastname+@course.teacher.firstname %> - + + - <%= l(:label_course_time) %><%= @course.time %> - - - - <%= l(:label_main_term) %><%= @course.term %> + <%= l(:label_main_term) %><%= @course.time %> -- <%= @course.term %> diff --git a/app/views/users/_my_create_homework.html.erb b/app/views/users/_my_create_homework.html.erb index daafc9eef..79c631d56 100644 --- a/app/views/users/_my_create_homework.html.erb +++ b/app/views/users/_my_create_homework.html.erb @@ -11,7 +11,9 @@ - +
<%= link_to(bid.author.lastname+bid.author.firstname, user_path(bid.author), :class => 'bid_user') %>:  <%= link_to(bid.name, respond_path(bid), :class => 'bid_path') %><%= link_to(bid.author.lastname+bid.author.firstname, user_path(bid.author), :class => 'bid_user') %>:   + <%= link_to(bid.name, respond_path(bid), :class => 'bid_path') %>    + <%= l(:label_course_homework) %> : <%= link_to(bid.courses.first.name, project_path(bid.courses.first)) %>
diff --git a/app/views/users/_my_homework.html.erb b/app/views/users/_my_homework.html.erb index e00e84691..5ffdffba4 100644 --- a/app/views/users/_my_homework.html.erb +++ b/app/views/users/_my_homework.html.erb @@ -11,7 +11,10 @@ - +
<%= link_to(bid.author.lastname+bid.author.firstname, user_path(bid.author), :class => 'bid_user') %>:  <%= link_to(bid.name, respond_path(bid), :class => 'bid_path') %><%= link_to(bid.author.lastname+bid.author.firstname, user_path(bid.author), :class => 'bid_user') %>:  <%= link_to(bid.name, respond_path(bid), :class => 'bid_path') %> +     + <%= l(:label_course_homework) %> : <%= link_to(bid.courses.first.name, project_path(bid.courses.first)) %> +
diff --git a/config/locales/zh.yml b/config/locales/zh.yml index d3adb6055..38515ed06 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -741,6 +741,7 @@ zh: label_time_tracking: 时间跟踪 label_change_plural: 变更 label_statistics: 统计 + label_contest: 竞赛 label_commits_per_month: 每月提交次数 label_commits_per_author: 每用户提交次数 label_view_diff: 查看差别 @@ -972,6 +973,7 @@ zh: text_caracters_minimum: "至少需要 %{count} 个字符。" text_length_between: "长度必须在 %{min} 到 %{max} 个字符之间。" text_command: 学生或其他成员申请加入课程时候需要使用该口令,该口令可以由老师在课堂上公布。 + text_contest_reward: 选择奖励后输入描述。 text_tracker_no_workflow: 此跟踪标签未定义工作流程 text_unallowed_characters: 非法字符 text_comma_separated: 可以使用多个值(用逗号,分开)。 @@ -1287,6 +1289,8 @@ zh: label_bid_me: 我要应标 label_new_call: 发布需求 + + label_newtype_contest: 发布竞赛 label_user_information: "与我相关" label_bid_succeed: "需求发布成功" label_wrong_budget: 错误的金额格式 @@ -1337,7 +1341,9 @@ zh: label_question_requirement: 对作业提出了问题! label_deadline: 投资时限yyyy-mm-dd label_requirement_name: 在此输入需求名称 + label_contest_name: 在此输入竞赛名称 label_requirement_description: 内容:对你的需求进行描述 + label_contest_description: 内容:对你的竞赛进行描述 label_requirement_bargain_money: 输入具体奖励方式(如金钱、奖项、学分) button_upload_photo: 上传图片 label_leave_me_message: 给我留言了 @@ -1466,6 +1472,7 @@ zh: label_bids_reward_what: 输入奖励内容 label_call_bonus: 奖金 label_bids_form_new_description: 企业可以在此发布一个软件开发任务或者一个技术方案需求:(1)获得价廉物美的解决方案;(2)发现对此项任务有贡献的大学生,获得可以招聘的人才。 + label_bids_form_contest_new_description: 企业或者高校可以在此发布一个竞赛。 label_homeworks_form_new_description: 发布一个作业,作业提交方式可以是附件或者项目形式,在作业类型里面设置。 label_fork_form_new_description: 该需求将作为某课程的作业被发布,作业提交方式可以使附件或者项目形式,在作业类型里面设置。 label_bids_new_money: 输入奖励金额,如 500,2.5等 diff --git a/config/routes.rb b/config/routes.rb index a21e9d65e..000a152f0 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -437,6 +437,7 @@ RedmineApp::Application.routes.draw do get 'calls/more', :to => 'bids#more' get 'calls/back', :to=> 'bids#back' match 'calls/new_bid', :controller => 'bids', :action => 'new_bid' + match 'contest/new_contest', :controller => 'bids', :action => 'new_contest' #huang match 'calls/:id/show_project', :controller => 'bids', :action => 'show_project', :as => 'project_for_bid' match 'calls/:id/show_project_homework', :controller => 'bids', :action => 'show_project_homework', :as => 'project_for_bid_homework' # by huang match 'calls/:id/add', :controller => 'bids', :action => 'add' @@ -444,6 +445,7 @@ RedmineApp::Application.routes.draw do match 'words/add_project_respond', :controller => 'words', :action => 'add_project_respond' match 'projects/:id/feedback', :to => 'projects#feedback', :via => :get, :as => 'project_feedback' match 'calls/create_bid', :to => 'bids#create_bid' + match 'contest/create_contest', :to => 'bids#create_contest' #huang match 'calls/create_homework', :to => 'bids#create_homework' match 'calls/:id/homework_respond', :to => 'bids#homework_respond' match 'calls/:id/homework_statistics', :to => 'bids#homework_statistics' @@ -471,6 +473,7 @@ RedmineApp::Application.routes.draw do match 'calls', :controller => 'bids', :action => 'index' match 'calls/:id', :controller => 'bids', :action => 'show', :as => 'respond' + match 'contest', :controller => 'bids', :action => 'contest' ######added by nie match 'tags/show_projects_tags',:to => 'tags#show_projects_tags' diff --git a/lib/redmine.rb b/lib/redmine.rb index 156fb5c8e..509fa8e73 100644 --- a/lib/redmine.rb +++ b/lib/redmine.rb @@ -239,7 +239,7 @@ Redmine::MenuManager.map :top_college_menu do |menu| menu.push :home, :home_path menu.push :new_course, {:controller => 'projects', :action => 'course', :project_type => 1 } menu.push :new_homework, {:controller => 'bids', :action => 'index', :project_type => 1 } - # menu.push :new_contest, {:controller => 'bids', :action => 'index', :project_type => 1 } + menu.push :new_contest, {:controller => 'bids', :action => 'contest', :project_type => 1} menu.push :projects, { :controller => 'projects', :action => 'index', :project_type => 1 }, :caption => :label_project_plural menu.push :developer, {:controller => 'users', :action => 'index', :project_type => 1 } menu.push :enterprise_into, {:controller=>'projects', :action=>'enterprise_course', :project_type => 0 }