From 0206d3f2c378f941ab0eebf997708fda853ef866 Mon Sep 17 00:00:00 2001 From: baiyu Date: Sat, 19 Oct 2013 09:35:14 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E9=9C=80=E6=B1=82=E9=87=8C=E9=9D=A2?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=BA=86=E7=94=A8=E6=88=B7=E5=92=8C=E9=A1=B9?= =?UTF-8?q?=E7=9B=AE=E4=B8=8E=E9=9C=80=E6=B1=82=E7=9A=84=E8=81=94=E7=B3=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/bids_controller.rb | 57 +++++++++++++++++++++++- app/helpers/bids_helper.rb | 20 +++++++++ app/models/bid.rb | 3 ++ app/views/bids/_project_list.html.erb | 10 ++--- app/views/bids/show_bid_project.html.erb | 42 +++++++++++++++++ app/views/bids/show_bid_user.html.erb | 30 +++++++++++++ app/views/layouts/base_bids.html.erb | 7 +++ config/routes.rb | 2 + 8 files changed, 165 insertions(+), 6 deletions(-) create mode 100644 app/views/bids/show_bid_project.html.erb create mode 100644 app/views/bids/show_bid_user.html.erb diff --git a/app/controllers/bids_controller.rb b/app/controllers/bids_controller.rb index d9cac4b58..8f3b184e0 100644 --- a/app/controllers/bids_controller.rb +++ b/app/controllers/bids_controller.rb @@ -6,7 +6,8 @@ class BidsController < ApplicationController menu_item :homework_respond, :only => :homework_respond menu_item :homework_statistics, :only => :homework_statistics #Ended by young - before_filter :find_bid, :only => [:show, :show_project, :create,:destroy,:more,:back,:add,:new,:show_results,:set_reward, :add_homework, :fork, :create_fork, :show_course] + before_filter :find_bid, :only => [:show, :show_project, :create,:destroy,:more,:back,:add,:new,:show_results,:set_reward, :add_homework, :fork, :create_fork, + :show_course, :show_bid_project, :show_bid_user] before_filter :require_login,:only => [:set_reward] helper :watchers @@ -234,6 +235,60 @@ class BidsController < ApplicationController end end + + def show_bid_project + bids = Bid.where('parent_id = ?', @bid.id) + @projects = [] + for bid in bids + @projects += bid.biding_projects + end + + respond_to do |format| + if @bid.reward_type == 3 + format.html { + render :layout => 'base_homework' + } + elsif @bid.reward_type == 1 + format.html { + render :layout => 'base_bids' + } + else + format.html { + render :layout => 'base_contest' + } + end + format.api + + end + end + + def show_bid_user + bids = Bid.where('parent_id = ?', @bid.id) + @users = [] + for bid in bids + for project in bid.projects + @users += project.users + end + end + + respond_to do |format| + if @bid.reward_type == 3 + format.html { + render :layout => 'base_homework' + } + elsif @bid.reward_type == 1 + format.html { + render :layout => 'base_bids' + } + else + format.html { + render :layout => 'base_contest' + } + end + format.api + + end + end def show_project # flash[:notice] = "" diff --git a/app/helpers/bids_helper.rb b/app/helpers/bids_helper.rb index 3c7528fe9..9e82fa1af 100644 --- a/app/helpers/bids_helper.rb +++ b/app/helpers/bids_helper.rb @@ -105,4 +105,24 @@ module BidsHelper def get_prize(b_project) b_project.get_reward end + + def count_bid_project + bids = Bid.where('parent_id = ?', @bid.id) + @projects = [] + for bid in bids + @projects += bid.biding_projects + end + @projects.count + end + + def count_bid_user + bids = Bid.where('parent_id = ?', @bid.id) + @users = [] + for bid in bids + for project in bid.projects + @users += project.users + end + end + @users.count + end end \ No newline at end of file diff --git a/app/models/bid.rb b/app/models/bid.rb index 0c8a4d371..0205df548 100644 --- a/app/models/bid.rb +++ b/app/models/bid.rb @@ -7,11 +7,14 @@ class Bid < ActiveRecord::Base belongs_to :course has_many :biding_projects, :dependent => :destroy has_many :projects, :through => :biding_projects + has_many :projects_member, :class_name => 'User', :through => :projects has_many :journals_for_messages, :as => :jour, :dependent => :destroy has_many :acts, :class_name => 'Activity', :as => :act, :dependent => :destroy has_many :homework_for_courses, :dependent => :destroy has_many :courses, :through => :homework_for_courses, :source => :project has_many :homeworks, :class_name => 'HomeworkAttach', :dependent => :destroy + # has_many :fork_homework, :class_name => 'Bid', :conditions => "#{Bid.table_name}.parent_id = #{id}" + acts_as_attachable diff --git a/app/views/bids/_project_list.html.erb b/app/views/bids/_project_list.html.erb index 302b57547..5c99fdce1 100644 --- a/app/views/bids/_project_list.html.erb +++ b/app/views/bids/_project_list.html.erb @@ -8,7 +8,7 @@ <% end %> - +
<%= l(:label_homework_project) %>(<%= @bidding_project.count%>)<%= l(:label_homework_project) %>(<%= bidding_project.count%>) <% if User.current.logged? && (!Member.where('user_id = ? and project_id = ?', User.current.id, @bid.courses.first.id).first.nil? && (Member.where('user_id = ? and project_id = ?', User.current.id, @bid.courses.first.id).first.roles&Role.where('id = ? or id = ?', 5, 7)).size >0) %> @@ -18,7 +18,7 @@ <% end %>
- <% end %> -<%= render :partial=> "list_projects",:locals => {:bidding_project => @bidding_project,:bid => @bid }%> +<%= render :partial=> "list_projects",:locals => {:bidding_project => bidding_project,:bid => @bid }%> diff --git a/app/views/bids/show_bid_project.html.erb b/app/views/bids/show_bid_project.html.erb new file mode 100644 index 000000000..616ab7bd9 --- /dev/null +++ b/app/views/bids/show_bid_project.html.erb @@ -0,0 +1,42 @@ +<% @projects.each do |b_project|%> + + + + +
+ + + + + + +
+
+ <%= link_to image_tag(url_to_avatar(b_project.project), :class => 'avatar3'), :class => "avatar" %> +
+ + + + + + + + + + + +
<%= link_to(b_project.project.name, project_path(b_project.project)) %><%= l(:label_jion_bidding_homework)%>
<%= b_project.project.description %>
<%=format_time(b_project.created_at) %>
+
+ + + + + + + + + + +
<%= l(:label_bidding_user_studentcode) %> : <%= @user.user_extensions.student_id %>
<%= l(:label_bidding_user_homework) %> : <%= link_to(b_project.user.name, user_path(b_project.user)) %>
<%= l(:label_bidding_reason_homewrok) %> : <%= b_project.description %>
+
+<% end %> diff --git a/app/views/bids/show_bid_user.html.erb b/app/views/bids/show_bid_user.html.erb new file mode 100644 index 000000000..5ac14ee69 --- /dev/null +++ b/app/views/bids/show_bid_user.html.erb @@ -0,0 +1,30 @@ +
+ <% for user in @users %> + +<% end %> +
\ No newline at end of file diff --git a/app/views/layouts/base_bids.html.erb b/app/views/layouts/base_bids.html.erb index c584e80b7..9d5f2d042 100644 --- a/app/views/layouts/base_bids.html.erb +++ b/app/views/layouts/base_bids.html.erb @@ -72,6 +72,13 @@
<%= l(:label_has_been)%> <%= link_to(Bid.where('parent_id = ?', @bid.id).count, show_course_path(@bid), :class => 'reference') %>  <%= l(:label_course_userd_by)%>
+ +
有 <%= link_to(count_bid_project, show_bid_project_path(@bid), :class => 'reference') %>  + 个项目正在应标需求
+ +
有 <%= link_to(count_bid_user, show_bid_user_path(@bid), :class => 'reference') %>  + 个用户正在努力完成此需求
+
<%= link_to l(:label_x_followers, :count => @bid.watcher_users.count)+"("+@bid.watcher_users.count.to_s+")", respond_path(@bid) %>   diff --git a/config/routes.rb b/config/routes.rb index bf98b2858..e9b12c866 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -456,6 +456,8 @@ RedmineApp::Application.routes.draw do match 'project/enterprise_course', :to => 'projects#enterprise_course' match 'project/course_enterprise', :to => 'projects#course_enterprise' match 'calls/:id/show_course', :to => 'bids#show_course', :as => 'show_course' + match 'calls/:id/show_bid_project', :to => 'bids#show_bid_project', :as => 'show_bid_project' + match 'calls/:id/show_bid_user', :to => 'bids#show_bid_user', :as => 'show_bid_user' post 'join_in/join', :to => 'courses#join', :as => 'join' delete 'join_in/join', :to => 'courses#unjoin' From ecdeaf123eb36de21f3b64fca505a20a5c8fbe1f Mon Sep 17 00:00:00 2001 From: baiyu Date: Sat, 19 Oct 2013 15:39:53 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BA=86=E9=83=A8?= =?UTF-8?q?=E5=88=86=E5=9B=BD=E9=99=85=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/bids_controller.rb | 2 +- app/controllers/words_controller.rb | 2 +- app/views/bids/_list_projects.html.erb | 2 +- app/views/bids/contest.html.erb | 6 ++++-- app/views/users/_my_course.html.erb | 8 ++++---- app/views/users/_my_create_homework.html.erb | 9 +++++++-- config/locales/en.yml | 8 ++++++++ config/locales/zh.yml | 10 ++++++++++ 8 files changed, 36 insertions(+), 11 deletions(-) diff --git a/app/controllers/bids_controller.rb b/app/controllers/bids_controller.rb index 8f3b184e0..9e51a8598 100644 --- a/app/controllers/bids_controller.rb +++ b/app/controllers/bids_controller.rb @@ -466,7 +466,7 @@ class BidsController < ApplicationController end # Replaces pre blocks with [...] text = text.to_s.strip.gsub(%r{
((.|\s)*?)
}m, '[...]') - @content = "> #{ll(Setting.default_language, :text_user_wrote, user)}\n> " + @content = "> #{ll(User.current.language, :text_user_wrote, user)}\n> " @content << text.gsub(/(\r?\n|\r\n?)/, "\n> ") + "\n\n" @id = user.id rescue ActiveRecord::RecordNotFound diff --git a/app/controllers/words_controller.rb b/app/controllers/words_controller.rb index 171b2f0c0..0a81d6ab6 100644 --- a/app/controllers/words_controller.rb +++ b/app/controllers/words_controller.rb @@ -71,7 +71,7 @@ class WordsController < ApplicationController end # Replaces pre blocks with [...] text = text.to_s.strip.gsub(%r{
((.|\s)*?)
}m, '[...]') - @content = "> #{ll(Setting.default_language, :text_user_wrote, user)}\n> " + @content = "> #{ll(User.current.language, :text_user_wrote, user)}\n> " @content << text.gsub(/(\r?\n|\r\n?)/, "\n> ") + "\n\n" # @content << text.gsub(/(\r?\n|\r\n?)/, "\n> ") + "\n\n" diff --git a/app/views/bids/_list_projects.html.erb b/app/views/bids/_list_projects.html.erb index 88a5ec36f..42812a5fa 100644 --- a/app/views/bids/_list_projects.html.erb +++ b/app/views/bids/_list_projects.html.erb @@ -24,7 +24,7 @@ <% if get_prize(b_project).nil? or get_prize(b_project) == "" %> <% if @bid.deadline < Date.today %> - 未评奖 + <%= l(:label_noawards)%> <% end %> <% else %> <% case @bid.reward_type %> diff --git a/app/views/bids/contest.html.erb b/app/views/bids/contest.html.erb index 51c6817ac..576323cbc 100644 --- a/app/views/bids/contest.html.erb +++ b/app/views/bids/contest.html.erb @@ -8,8 +8,10 @@ <% if User.current.logged? %> - - <%= link_to(l(:label_newtype_contest), {:controller => 'bids', :action => 'new_contest'}, :class => 'icon icon-add') %> + + <% if User.current.user_extensions.identity == 0 %> + <%= link_to(l(:label_newtype_contest), {:controller => 'bids', :action => 'new_contest'}, :class => 'icon icon-add') %> + <% end %> <% end %> diff --git a/app/views/users/_my_course.html.erb b/app/views/users/_my_course.html.erb index c06abe4b0..d7e4a4cc1 100644 --- a/app/views/users/_my_course.html.erb +++ b/app/views/users/_my_course.html.erb @@ -47,13 +47,13 @@ <%= format_time(membership.created_on) %> - 课程角色: + <%= l(:role_of_course)%>: <% if membership.roles.sort.collect(&:to_s).join(', ') =='Manager' %> - 老师 + <%= l(:label_teacher)%> <% elsif membership.roles.sort.collect(&:to_s).join(', ') =='Reporter' %> - 学生 + <%= l(:label_student)%> <% elsif membership.roles.sort.collect(&:to_s).join(', ') =='TA' %> - 助教 + <%= l(:label_ta)%> <% end %> diff --git a/app/views/users/_my_create_homework.html.erb b/app/views/users/_my_create_homework.html.erb index d5652fe0a..4c7cbe02f 100644 --- a/app/views/users/_my_create_homework.html.erb +++ b/app/views/users/_my_create_homework.html.erb @@ -12,8 +12,13 @@ - + - + - +
<%= link_to(bid.author.lastname+bid.author.firstname, user_path(bid.author), :class => 'bid_user') %> - 在课程: <%= link_to(bid.courses.first.name, project_path(bid.courses.first)) %> - 中布置了作业: <%= link_to(bid.name, respond_path(bid), :class => 'bid_path') %> + <%if @user.language=='zh'%> + <%= l(:label_in_course)%>: <%= link_to(bid.courses.first.name, project_path(bid.courses.first)) %> + <%= l(:label_assign_homework)%>: <%= link_to(bid.name, respond_path(bid), :class => 'bid_path') %> + <%else%> + <%= l(:label_assign_homework)%>: <%= link_to(bid.name, respond_path(bid), :class => 'bid_path') %> + <%= l(:label_in_course)%>: <%= link_to(bid.courses.first.name, project_path(bid.courses.first)) %> + <%end%> <%= link_to( l(:button_delete), diff --git a/config/locales/en.yml b/config/locales/en.yml index e07bd5fee..9098f3eea 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1535,3 +1535,11 @@ en: label_task_submit_form_accessory: Submitted as accessory label_task_submit_form_project: Submitted as project label_news_notice: Release course news + + role_of_course: Role + label_student: student + label_teacher: teacher + label_ta: teacher assistant + label_in_course: in course + label_assign_homework: assigned homewok + label_noawards: No awards diff --git a/config/locales/zh.yml b/config/locales/zh.yml index 355c2c40e..ee6c3a62e 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -1626,3 +1626,13 @@ zh: label_new_join_order: 请输入课程密码 label_task_submit_form_accessory: 作业最终以附件形式提交 label_task_submit_form_project: 作业最终以项目形式提交 + label_has_been: 已经被 + label_course_userd_by: 个课程引用 + + role_of_course: 课程角色 + label_student: 学生 + label_teacher: 老师 + label_ta: 助教 + label_in_course: 在课程中 + label_assign_homework: 中布置了作业 + label_noawards: 未评奖 \ No newline at end of file From a44713ba6d09f19a848a38a6e12cbb88f360a04e Mon Sep 17 00:00:00 2001 From: baiyu Date: Sat, 19 Oct 2013 16:16:54 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BA=86=E9=9C=80?= =?UTF-8?q?=E6=B1=82=E9=A1=B5=E9=9D=A2=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/layouts/base_bids.html.erb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/views/layouts/base_bids.html.erb b/app/views/layouts/base_bids.html.erb index 9d5f2d042..72530b8ff 100644 --- a/app/views/layouts/base_bids.html.erb +++ b/app/views/layouts/base_bids.html.erb @@ -69,15 +69,15 @@ <%= l(:label_investment_time_limit) %><%= @bid.deadline%>
<%= l(:label_has_been)%> <%= link_to(Bid.where('parent_id = ?', @bid.id).count, show_course_path(@bid), :class => 'reference') %>  - <%= l(:label_course_userd_by)%>
被 <%= link_to(Bid.where('parent_id = ?', @bid.id).count, show_course_path(@bid)) %>  + 个高校课程引用为作业!
有 <%= link_to(count_bid_project, show_bid_project_path(@bid), :class => 'reference') %>  - 个项目正在应标需求
有 <%= link_to(count_bid_project, show_bid_project_path(@bid)) %>  + 个项目正在实现该需求!
有 <%= link_to(count_bid_user, show_bid_user_path(@bid), :class => 'reference') %>  - 个用户正在努力完成此需求
有 <%= link_to(count_bid_user, show_bid_user_path(@bid)) %>  + 个高校用户正在努力完成此需求!