From 005e0802d46e698fe75526b89237ce978992041c Mon Sep 17 00:00:00 2001 From: baiyu Date: Thu, 14 Nov 2013 15:55:56 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=BA=86=E7=AB=9E?= =?UTF-8?q?=E8=B5=9B=E7=9A=84=E2=80=9C=E5=8A=A0=E5=85=A5=E2=80=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/bids_controller.rb | 55 ++++++++++++++--- app/helpers/watchers_helper.rb | 23 +++++++- app/models/bid.rb | 6 +- app/models/join_in_contest.rb | 10 ++++ app/models/user.rb | 11 ++++ app/views/bids/_form_contest.html.erb | 3 + app/views/bids/_new_join.html.erb | 59 +++++++++++++++++++ app/views/bids/_set_join.js.erb | 8 +++ app/views/bids/new_join.js.erb | 3 + app/views/layouts/base_contest.html.erb | 4 +- app/views/layouts/base_courses.html.erb | 3 +- app/views/projects/_course_form.html.erb | 16 +++-- app/views/users/user_projects.html.erb | 2 +- config/locales/zh.yml | 3 + config/routes.rb | 5 +- .../20131112015232_add_password_to_bids.rb | 5 ++ .../20131113124237_create_join_in_contests.rb | 10 ++++ db/schema.rb | 8 +++ 18 files changed, 213 insertions(+), 21 deletions(-) create mode 100644 app/models/join_in_contest.rb create mode 100644 app/views/bids/_new_join.html.erb create mode 100644 app/views/bids/_set_join.js.erb create mode 100644 app/views/bids/new_join.js.erb create mode 100644 db/migrate/20131112015232_add_password_to_bids.rb create mode 100644 db/migrate/20131113124237_create_join_in_contests.rb diff --git a/app/controllers/bids_controller.rb b/app/controllers/bids_controller.rb index b44c2ba51..6c5ff1680 100644 --- a/app/controllers/bids_controller.rb +++ b/app/controllers/bids_controller.rb @@ -8,7 +8,10 @@ class BidsController < ApplicationController 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, :show_bid_project, :show_bid_user] + :show_course, :show_bid_project, :show_bid_user, :join_in_contest, :unjoin_in_contest, :new_join] + # 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, ] helper :watchers @@ -209,6 +212,41 @@ class BidsController < ApplicationController end end + + def join_in_contest + if @bid.reward_type == 2 && params[:course_password] == @bid.password + JoinInContest.create(:user_id => User.current.id, :bid_id => @bid.id) + @state = 0 + else + @state = 1 + end + + respond_to do |format| + # format.html { redirect_to_referer_or {render :text => (watching ? 'Watcher added.' : 'Watcher removed.'), :layout => true}} + # TO_DO + format.js { render :partial => 'set_join', :locals => {:user => User.current, :object_id => params[:id]} } + end + end + + def unjoin_in_contest + + joined = JoinInContest.where('bid_id = ? and user_id = ?', @bid.id, User.current.id) + + joined.each do |join| + join.delete + end + + respond_to do |format| + # format.html { redirect_to_referer_or {render :text => (watching ? 'Watcher added.' : 'Watcher removed.'), :layout => true}} + format.js { render :partial => 'set_join', :locals => {:user => User.current, :object_id => params[:id]} } + end + end + + def new_join + # added by fq + + + end def show_course bids = Bid.where('parent_id = ?', @bid.id) @@ -338,13 +376,13 @@ class BidsController < ApplicationController @homework = HomeworkAttach.new @homework_list = @bid.homeworks if params[:student_id].present? - @temp = [] - @homework_list.each do |pro| - if /#{params[:student_id]}/ =~ pro.user.user_extensions.student_id - @temp << pro - end - @temp - end + @temp = [] + @homework_list.each do |pro| + if /#{params[:student_id]}/ =~ pro.user.user_extensions.student_id + @temp << pro + end + @temp + end @homework_list = @temp end end @@ -536,6 +574,7 @@ class BidsController < ApplicationController @bid.reward_type = 2 @bid.budget = params[:bid][:budget] @bid.deadline = params[:bid][:deadline] + @bid.password = params[:bid][:password] #added by bai @bid.author_id = User.current.id @bid.commit = 0 if @bid.save diff --git a/app/helpers/watchers_helper.rb b/app/helpers/watchers_helper.rb index 2fdb4fd1c..e05ef6ebd 100644 --- a/app/helpers/watchers_helper.rb +++ b/app/helpers/watchers_helper.rb @@ -56,9 +56,9 @@ module WatchersHelper url_f = try_join_path(:object_id => course.id) method = joined ? 'delete' : 'post' if joined - link_to text, url_t, :remote => true, :method => method, :id => 'join', :confirm => l(:text_are_you_sure_out), :class => []+options + link_to text, url_t, :remote => true, :method => method, :id => "#{course.id}", :confirm => l(:text_are_you_sure_out), :class => []+options else - link_to text, url_f, :remote => true, :method => method, :id => 'join', :class => []+options + link_to text, url_f, :remote => true, :method => method, :id => "#{course.id}", :class => []+options end end @@ -76,6 +76,25 @@ module WatchersHelper end end + #added by bai + def join_in_contest(bid, user, options=[]) + if bid.reward_type == 2 + return '' unless user && user.logged? + joined = user.join_in_contest?(bid) + text = joined ? l(:label_exit_contest) : l(:label_join_contest) + url_t = join_in_contest_path(:id => bid.id) + url_f = try_join_in_contest_path(:id => bid.id) + # url = join_in_contest_path(:id => bid.id) + method = joined ? 'delete' : 'post' + if joined + link_to text, url_t, :remote => true, :method => method, :id => "#{bid.id}", :confirm => l(:text_are_you_sure_out), :class => []+options + else + link_to text, url_f, :remote => true, :method => method, :id => "#{bid.id}", :class => []+options + end + end + end + + # Returns the css class used to identify watch links for a given +object+ def watcher_css(objects) objects = Array.wrap(objects) diff --git a/app/models/bid.rb b/app/models/bid.rb index 3bad65f3c..bb7868ef8 100644 --- a/app/models/bid.rb +++ b/app/models/bid.rb @@ -1,6 +1,6 @@ ####by fq class Bid < ActiveRecord::Base - attr_accessible :author_id, :budget, :deadline, :name, :description, :homework_type + attr_accessible :author_id, :budget, :deadline, :name, :description, :homework_type, :password include Redmine::SafeAttributes belongs_to :author, :class_name => 'User', :foreign_key => :author_id @@ -13,6 +13,7 @@ class Bid < ActiveRecord::Base 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 :join_in_contests, :dependent => :destroy # has_many :fork_homework, :class_name => 'Bid', :conditions => "#{Bid.table_name}.parent_id = #{id}" @@ -63,7 +64,8 @@ class Bid < ActiveRecord::Base 'budget', 'deadline', 'homework_type', - 'reward_type' + 'reward_type', + 'password' # safe_attributes 'name', diff --git a/app/models/join_in_contest.rb b/app/models/join_in_contest.rb new file mode 100644 index 000000000..d80a096a0 --- /dev/null +++ b/app/models/join_in_contest.rb @@ -0,0 +1,10 @@ +class JoinInContest < ActiveRecord::Base + attr_accessible :bid_id, :user_id + + belongs_to :user + belongs_to :bid + + validates_presence_of :user_id, :bid_id + + +end diff --git a/app/models/user.rb b/app/models/user.rb index 40e142e92..48bda02a6 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -90,6 +90,7 @@ class User < Principal has_many :students_for_courses has_many :courses, :through => :students_for_courses, :source => :project has_many :acts, :class_name => 'Activity', :as => :act, :dependent => :destroy + has_many :join_in_contests, :dependent => :destroy ##### ######added by nie @@ -167,6 +168,16 @@ class User < Principal self.journals_for_messages << JournalsForMessage.new(:user_id => user.id, :notes => notes, :reply_id => reference_user_id, :status => true) end + # 判断用户是否加入了竞赛中 fq + def join_in_contest?(bid) + joined = JoinInContest.where('user_id = ? and bid_id =?', self.id, bid.id) + if joined.size > 0 + true + else + false + end + end + ### fq def join_in?(course) joined = StudentsForCourse.where('student_id = ? and course_id = ?', self.id, course.id) diff --git a/app/views/bids/_form_contest.html.erb b/app/views/bids/_form_contest.html.erb index b7e4dc5c7..448af2e8e 100644 --- a/app/views/bids/_form_contest.html.erb +++ b/app/views/bids/_form_contest.html.erb @@ -24,6 +24,9 @@

<%= 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)}" %>

+ +

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

+

<%= f.text_field :budget, :required => true, :size => 60, :style => "width:350px;", :placeholder => l(:label_bids_reward_what) %> diff --git a/app/views/bids/_new_join.html.erb b/app/views/bids/_new_join.html.erb new file mode 100644 index 000000000..bbe09133d --- /dev/null +++ b/app/views/bids/_new_join.html.erb @@ -0,0 +1,59 @@ + + + +

请输入竞赛密码

+ +<%= form_tag({:controller => 'bids', + :action => 'join_in_contest', + :id => course.id}, + :remote => true, + :method => :post, + :id => 'new-watcher-form') do %> + + + + + <%= text_field_tag 'course_password', nil, :size => 45 %> + +

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

+
+<% end %> diff --git a/app/views/bids/_set_join.js.erb b/app/views/bids/_set_join.js.erb new file mode 100644 index 000000000..361cf85ae --- /dev/null +++ b/app/views/bids/_set_join.js.erb @@ -0,0 +1,8 @@ +$("#<%=object_id%>").replaceWith('<%= escape_javascript join_in_contest(@bid, user) %>'); +<% if @state %> + <% if @state == 0 %> + alert("加入成功") + <% else %> + alert("密码错误") + <% end %> +<% end %> \ No newline at end of file diff --git a/app/views/bids/new_join.js.erb b/app/views/bids/new_join.js.erb new file mode 100644 index 000000000..bf80473a2 --- /dev/null +++ b/app/views/bids/new_join.js.erb @@ -0,0 +1,3 @@ +$('#ajax-modal').html('<%= escape_javascript(render :partial => 'bids/new_join', :locals => {:course => @bid}) %>'); +showModal('ajax-modal', '400px'); +$('#ajax-modal').addClass('new-watcher'); diff --git a/app/views/layouts/base_contest.html.erb b/app/views/layouts/base_contest.html.erb index 244e6a36c..fde90107a 100644 --- a/app/views/layouts/base_contest.html.erb +++ b/app/views/layouts/base_contest.html.erb @@ -64,7 +64,9 @@ <%= h @bid.name %> - <%= watcher_link(@bid, User.current) %> + + <%= join_in_contest(@bid, User.current)%> + <%= watcher_link(@bid, User.current) %> diff --git a/app/views/layouts/base_courses.html.erb b/app/views/layouts/base_courses.html.erb index e7598af63..145457a61 100644 --- a/app/views/layouts/base_courses.html.erb +++ b/app/views/layouts/base_courses.html.erb @@ -70,13 +70,14 @@ <%= @project.name %> +
<%if User.current.logged? %> <% if @course.teacher.id == User.current.id %> <%= link_to l(:label_course_modify_settings), {:controller => 'projects', :action => 'settings', :id => @project} %> <% else %> <%= join_in_course(@project, User.current) %>
- <% end %> + <% end %> <% unless User.current.member_of?(@project) %>
diff --git a/app/views/projects/_course_form.html.erb b/app/views/projects/_course_form.html.erb index 46f3b487c..0303e8aa1 100644 --- a/app/views/projects/_course_form.html.erb +++ b/app/views/projects/_course_form.html.erb @@ -18,7 +18,12 @@ <%= f.fields_for @course do |m| %> - <% unless @course.nil?%> + + + + + + <% unless @course.nil?%>

<%= l(:label_setup_time) %> *   <%= text_field_tag :setup_time, @course.setup_time, :placeholder => "在此选择开课日期" %> <%= calendar_for('setup_time')%> @@ -53,11 +58,12 @@ <% end %> - -

+ + +

- - + + +

+

+ <% unless user.memberships.empty? %> + <% cond = Project.visible_condition(User.current) + "AND projects.project_type = 1" %> + <% memberships = user.memberships.all(:conditions => cond) %> + <%= l(:label_x_course_contribute_to, :count => memberships.count) %> + <% for member in memberships %> + <%= link_to_project(member.project) %><%= (user.memberships.last == member) ? '' : ',' %> + <% end %> + <% end %> +

+ + + diff --git a/config/locales/zh.yml b/config/locales/zh.yml index 263d15de4..18f3127bb 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -834,6 +834,11 @@ zh: one: 粉丝 other: 粉丝 #end + label_x_join_in_contest: + zero: 参与者 + one: 参与者 + other: 参与者 + #end label_user_commits: "代码提交" label_user_watchered: "关注" # huang添加的 label_user_newfeedback: "留言" ## huang添加的 @@ -1582,6 +1587,7 @@ zh: label_join_contest: 加入竞赛 label_exit_contest: 退出竞赛 + label_no_current_participate: 该竞赛暂无参与者 #end diff --git a/config/routes.rb b/config/routes.rb index 762cfdaec..7fe48d3d7 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -473,6 +473,8 @@ RedmineApp::Application.routes.draw do delete 'join_in/join', :to => 'courses#unjoin' post 'calls/:id/join_in_contest', :to => 'bids#join_in_contest', :as => 'join_in_contest' delete 'calls/:id/join_in_contest', :to => 'bids#unjoin_in_contest' + match 'calls/:id/show_participator', :to => 'bids#show_participator' #bai + delete 'attachment/:id', :to => 'attachments#delete_homework' match 'new_join', :to => 'projects#new_join', :as => 'try_join' match 'new_join_in_contest', :to => 'bids#new_join', :as => 'try_join_in_contest' From bfcb68efab7b818c6decf4207ef1bbb899f7a4c3 Mon Sep 17 00:00:00 2001 From: huangjingquan Date: Thu, 14 Nov 2013 19:29:42 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E4=BA=86=E8=AE=A8=E8=AE=BA=E5=8C=BA=20=E9=99=90=E5=88=B6?= =?UTF-8?q?=E5=AD=A6=E7=94=9F=E4=B8=8B=E4=BD=9C=E4=B8=9A=20=E8=AE=A8?= =?UTF-8?q?=E8=AE=BA=E5=8C=BA=E6=9D=83=E9=99=90=E8=AE=BE=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/boards_controller.rb | 12 ++++++------ app/views/bids/_homework_list.html.erb | 2 ++ app/views/boards/index.html.erb | 2 +- app/views/layouts/base_courses.html.erb | 9 ++++++--- config/locales/zh.yml | 1 + 5 files changed, 16 insertions(+), 10 deletions(-) diff --git a/app/controllers/boards_controller.rb b/app/controllers/boards_controller.rb index 2d1d0bba7..dc4ccbc67 100644 --- a/app/controllers/boards_controller.rb +++ b/app/controllers/boards_controller.rb @@ -30,13 +30,15 @@ class BoardsController < ApplicationController def index @boards = @project.boards.includes(:last_message => :author).all # show the board if there is only one + unless @project.project_type == 1 if @boards.size == 1 @board = @boards.first show end + end if @project.project_type == 1 - render :layout => 'base_courses' - else + render :layout => 'base_courses' + else render :layout => false if request.xhr? end end @@ -85,12 +87,10 @@ class BoardsController < ApplicationController end end - def create + def create @board = @project.boards.build @board.safe_attributes = params[:board] - if @project.project_type == 1 - render :layout => 'base_courses' - end + if @board.save flash[:notice] = l(:notice_successful_create) #Modified by young diff --git a/app/views/bids/_homework_list.html.erb b/app/views/bids/_homework_list.html.erb index 0a40e3d0e..ba6faa650 100644 --- a/app/views/bids/_homework_list.html.erb +++ b/app/views/bids/_homework_list.html.erb @@ -31,11 +31,13 @@
<% unless @course.nil? %> <% if @course.time == 2008 %> -

+

<%= l(:label_term) %> *  
<%= l(:label_term) %> *   <%= select_tag 'time', " @@ -263,7 +269,7 @@ <%= l(:text_command) %> <% end %>

<%= f.text_area :description, :rows => 8, :class => 'wiki-edit', :style => "font-size:small;width:490px;margin-left:10px;" %>

-

<%= f.check_box :is_public, :style => "margin-left:10px;" %>

+

<%= f.check_box :is_public, :style => "margin-left:10px;" %><%= l(:label_public_info) %>

<%= f.text_field :project_type, :value => 1 %>

diff --git a/app/views/users/user_projects.html.erb b/app/views/users/user_projects.html.erb index acf205d71..f4f3671a2 100644 --- a/app/views/users/user_projects.html.erb +++ b/app/views/users/user_projects.html.erb @@ -1,5 +1,5 @@ -

温馨提示:项目可以是一次作业,也可以是别人或者自己创建的一项小工程~

+

温馨提示:这里显示的是您创建或参与的所有项目。

<% if @user == User.current %> <%= link_to(l(:label_project_new), {:controller => 'projects', :action => 'new', :course => 0, :project_type => @project_type}, :class => 'icon icon-add') if User.current.allowed_to?(:add_project, nil, :global => true) %> diff --git a/config/locales/zh.yml b/config/locales/zh.yml index 6a8857f11..263d15de4 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -1579,6 +1579,9 @@ zh: zero: "参与了 %{count} 个课程:" one: "参与了 %{count} 个课程:" other: "参与了 %{count} 个课程:" + + label_join_contest: 加入竞赛 + label_exit_contest: 退出竞赛 #end diff --git a/config/routes.rb b/config/routes.rb index 7277dd1b3..762cfdaec 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -469,10 +469,13 @@ RedmineApp::Application.routes.draw do match 'project/:id/share', :to => 'projects#share', :as => 'share_show' #share - post 'join_in/join', :to => 'courses#join', :as => 'join' + post 'join_in/join', :to => 'courses#join', :as => 'join' delete 'join_in/join', :to => 'courses#unjoin' + post 'calls/:id/join_in_contest', :to => 'bids#join_in_contest', :as => 'join_in_contest' + delete 'calls/:id/join_in_contest', :to => 'bids#unjoin_in_contest' delete 'attachment/:id', :to => 'attachments#delete_homework' match 'new_join', :to => 'projects#new_join', :as => 'try_join' + match 'new_join_in_contest', :to => 'bids#new_join', :as => 'try_join_in_contest' match 'projects/:id/respond', :to => 'projects#project_respond', :via => :post match 'calls/:id/manage',:to => 'bids#manage',:via => [:get,:post] match 'project/course', :to => 'projects#course', :as => 'course' #nyan diff --git a/db/migrate/20131112015232_add_password_to_bids.rb b/db/migrate/20131112015232_add_password_to_bids.rb new file mode 100644 index 000000000..6379b1263 --- /dev/null +++ b/db/migrate/20131112015232_add_password_to_bids.rb @@ -0,0 +1,5 @@ +class AddPasswordToBids < ActiveRecord::Migration + def change + add_column :bids, :password, :string + end +end diff --git a/db/migrate/20131113124237_create_join_in_contests.rb b/db/migrate/20131113124237_create_join_in_contests.rb new file mode 100644 index 000000000..96b06d5e9 --- /dev/null +++ b/db/migrate/20131113124237_create_join_in_contests.rb @@ -0,0 +1,10 @@ +class CreateJoinInContests < ActiveRecord::Migration + def change + create_table :join_in_contests do |t| + t.integer :user_id + t.integer :bid_id + + t.timestamps + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 9d6b56cde..78af1a774 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -92,6 +92,7 @@ ActiveRecord::Schema.define(:version => 20131112005309) do t.integer "reward_type" t.integer "homework_type" t.integer "parent_id" + t.string "password" end create_table "boards", :force => true do |t| @@ -349,6 +350,13 @@ ActiveRecord::Schema.define(:version => 20131112005309) do add_index "issues", ["status_id"], :name => "index_issues_on_status_id" add_index "issues", ["tracker_id"], :name => "index_issues_on_tracker_id" + create_table "join_in_contests", :force => true do |t| + t.integer "user_id" + t.integer "bid_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + create_table "journal_details", :force => true do |t| t.integer "journal_id", :default => 0, :null => false t.string "property", :limit => 30, :default => "", :null => false From 2f8ef03d32d5658a1777d87ca54f8b653e40fe89 Mon Sep 17 00:00:00 2001 From: baiyu Date: Thu, 14 Nov 2013 17:01:06 +0800 Subject: [PATCH 2/4] =?UTF-8?q?1=E3=80=81=E5=A2=9E=E5=8A=A0=E4=BA=86?= =?UTF-8?q?=E5=8F=82=E4=B8=8E=E7=AB=9E=E8=B5=9B=E7=9A=84=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E5=88=97=E8=A1=A8=202=E3=80=81=E5=8C=BA=E5=88=86=E4=BA=86?= =?UTF-8?q?=E4=B8=AA=E4=BA=BA=E4=B8=BB=E9=A1=B5=E9=87=8C=E2=80=9C=E7=B2=89?= =?UTF-8?q?=E4=B8=9D=E2=80=9D=E5=88=97=E8=A1=A8=E9=87=8C=E7=9A=84=E9=A1=B9?= =?UTF-8?q?=E7=9B=AE=E4=B8=8E=E8=AF=BE=E7=A8=8B=E7=9A=84=E8=AE=A1=E6=95=B0?= =?UTF-8?q?=E4=B8=8E=E6=98=BE=E7=A4=BA=203=E3=80=81=E7=AB=9E=E8=B5=9B?= =?UTF-8?q?=E5=8F=91=E5=B8=83=E4=BA=BA=E7=9A=84=E5=90=8D=E5=AD=97=E6=94=B9?= =?UTF-8?q?=E4=B8=BA=E4=BA=86=E5=85=A8=E7=A7=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/bids_controller.rb | 9 ++++++- app/helpers/application_helper.rb | 28 ++++++++++++++++++- app/views/bids/show_participator.html.erb | 33 +++++++++++++++++++++++ app/views/layouts/base_contest.html.erb | 25 +++++++++++++++-- app/views/users/user_fanslist.html.erb | 25 ++++++++++++++--- config/locales/zh.yml | 6 +++++ config/routes.rb | 2 ++ 7 files changed, 120 insertions(+), 8 deletions(-) create mode 100644 app/views/bids/show_participator.html.erb diff --git a/app/controllers/bids_controller.rb b/app/controllers/bids_controller.rb index 6c5ff1680..a6fa6ed8c 100644 --- a/app/controllers/bids_controller.rb +++ b/app/controllers/bids_controller.rb @@ -8,7 +8,7 @@ class BidsController < ApplicationController 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, :show_bid_project, :show_bid_user, :join_in_contest, :unjoin_in_contest, :new_join] + :show_course, :show_bid_project, :show_bid_user, :join_in_contest, :unjoin_in_contest, :new_join,:show_participator] # added by fq before_filter :require_login, :only => [:join_in_contest, :unjoin_in_contest] # end @@ -247,6 +247,13 @@ class BidsController < ApplicationController end + + # added by bai + def show_participator + render :layout => 'base_contest' + + end + #end def show_course bids = Bid.where('parent_id = ?', @bid.id) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 8956a95cc..0d2b44b1b 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1393,7 +1393,7 @@ module ApplicationHelper html << (content_tag "span", l(:label_no_current_fans)) end for user in obj.watcher_users - html << (link_to image_tag(url_to_avatar(user), :class => "avatar"), user_path(user), :class => "avatar", :title => "#{user.name}") + html << (link_to image_tag(url_to_avatar(user), :class => "avatar"), user_path(user), :class => "avatar", :title => "#{user.show_name}") count = count + 1 if count >= 12 break @@ -1401,7 +1401,33 @@ module ApplicationHelper end html.html_safe end + + # added by bai + def show_more_participate?(obj) + if obj.join_in_contests.count > 12 + return true + else + return false + end + end + + def show_participate_picture(obj) + html = '' + count = 0 + if obj.join_in_contests.count == 0 + html << (content_tag "span", l(:label_no_current_participate)) + end + for temp in obj.join_in_contests + html << (link_to image_tag(url_to_avatar(temp.user), :class => "avatar"), user_path(temp.user), :class => "avatar", :title => "#{temp.user.show_name}") + count = count + 1 + if count >= 12 + break + end + end + html.html_safe + end #end + # add by huang def show_watcher_list(user) html = '' diff --git a/app/views/bids/show_participator.html.erb b/app/views/bids/show_participator.html.erb new file mode 100644 index 000000000..6ac248192 --- /dev/null +++ b/app/views/bids/show_participator.html.erb @@ -0,0 +1,33 @@ + +

<%= l(:label_x_join_in_contest, :count => @bid.join_in_contests.count)%>

+
+ <% for temp in @bid.join_in_contests %> + <% user = temp.user %> +
  • + + + + + +
    <%= link_to image_tag(url_to_avatar(user), :class => "avatar"), user_path(user), :title => "#{user.name}" %> + + + + + + + + + +
    <%= content_tag "div", link_to_user(user), :class => "project_avatar_name" %> +

    + <% unless user.memberships.empty? %> + <%= l(:label_x_contribute_to, :count => user.memberships.count) %> + <% for member in user.memberships %> + <%= link_to_project(member.project) %><%= (user.memberships.last == member) ? '' : ',' %> + <% end %> + <% end %> +

    <%= l(:label_user_joinin) %><%= format_date(user.created_on) %> +
+<% end %> +
\ No newline at end of file diff --git a/app/views/layouts/base_contest.html.erb b/app/views/layouts/base_contest.html.erb index fde90107a..2af659def 100644 --- a/app/views/layouts/base_contest.html.erb +++ b/app/views/layouts/base_contest.html.erb @@ -73,7 +73,7 @@
- + @@ -147,7 +147,7 @@
<%= l(:lable_contest_user) %><%= link_to(@user, user_path(@user))%><%= l(:lable_contest_user) %><%= link_to(@user.show_name, user_path(@user))%>
<%= l(:label_bids_reward_method) %><%= @bid.budget%>
- +

<%= l(:label_bidding_project) %> @@ -178,6 +178,27 @@
+ +
+ +
+
+ <%= l(:label_x_join_in_contest, :count => @bid.join_in_contests.count) %> + <% if show_more_participate?(@bid) %> +
+ <%= link_to l(:label_more), :controller => "bids", :action => "show_participator"%> +
+ <% end %> +
+
+ + + + +
<%= show_participate_picture(@bid) %>
+
+
+
<% if display_main_menu?(@bid) %> diff --git a/app/views/users/user_fanslist.html.erb b/app/views/users/user_fanslist.html.erb index 2c8c6b18e..5a9e5b314 100644 --- a/app/views/users/user_fanslist.html.erb +++ b/app/views/users/user_fanslist.html.erb @@ -11,16 +11,33 @@
<%= content_tag "div", link_to_user(user), :class => "project_avatar_name" %>

+ +

<% unless user.memberships.empty? %> - <%= l(:label_x_contribute_to, :count => user.memberships.count) %> + <% cond = Project.visible_condition(User.current) + "AND projects.project_type <> 1" %> + <% memberships = user.memberships.all(:conditions => cond) %> + <%= l(:label_x_contribute_to, :count => memberships.count) %> <% for member in user.memberships %> <%= link_to_project(member.project) %><%= (user.memberships.last == member) ? '' : ',' %> <% end %> <% end %> -

<%= l(:label_user_joinin) %><%= format_date(user.created_on) %>
+ <% unless 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 = ? or id =?',5, 10, 7)).size >0) %>

<% options = {:author => true, :deletable => attach_delete(homework)} %> <%= render :partial => 'attachments/links', :locals => {:attachments => homework.attachments, :options => options} %>

+ <% end %>
diff --git a/app/views/boards/index.html.erb b/app/views/boards/index.html.erb index c7e4f5b54..614066613 100644 --- a/app/views/boards/index.html.erb +++ b/app/views/boards/index.html.erb @@ -1,5 +1,5 @@

- <% if User.current.logged? %> + <% if User.current.logged? && User.current.member_of?(@project) %> <%= link_to l(:label_board_new), new_project_board_path(@project), :class => 'icon icon-add' %> <% end %>
diff --git a/app/views/layouts/base_courses.html.erb b/app/views/layouts/base_courses.html.erb index 145457a61..7bcb78ad5 100644 --- a/app/views/layouts/base_courses.html.erb +++ b/app/views/layouts/base_courses.html.erb @@ -210,20 +210,23 @@
  • - <%= link_to l(:label_course_overview), project_path(@project), :class => link_class(:overview)%> + <%= link_to l(:label_course_overview), project_path(@project), :class => link_class(:overview) %>
  • <%= link_to l(:label_homework), {:controller => 'projects', :action => 'homework'}, :class => link_class('Task')%>
  • +
  • + <%= link_to l(:label_course_board), { :controller => 'boards', :action => 'index', :project_id => @project}, :class => link_class(:boards) %> +
  • <%= link_to l(:label_course_file), project_files_path(@project), :class => link_class(:files)%>
  • - <%= link_to l(:label_course_news), {:controller => 'news', :action => 'index', :project_id => @project}, :class => link_class(:news)%> + <%= link_to l(:label_course_news), {:controller => 'news', :action => 'index', :project_id => @project}, :class => link_class(:news) %>
  • <%= link_to l(:label_course_feedback), project_feedback_path(@project), :class => link_class('Feedback')%> -
  • + <% if User.current.logged? && (User.current.admin? || (!Member.where('user_id = ? and project_id = ?', User.current.id, @project.id).first.nil? && (Member.where('user_id = ? and project_id = ?', User.current.id, @project.id).first.roles&Role.where('id = ? or id = ?', 7, 9)).size >0))%> diff --git a/config/locales/zh.yml b/config/locales/zh.yml index 18f3127bb..5c529ee7f 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -623,6 +623,7 @@ zh: label_homework_commit: 提交作业 #huang label_homework_info: 作业情况 #huang label_course_news: 课程通知 + label_course_board: 讨论区 label_version: 版本 label_version_new: 新建版本 label_version_plural: 版本 From 4d8345593da03c5934f22b234bc6e3fa84b1f8da Mon Sep 17 00:00:00 2001 From: huangjingquan Date: Thu, 14 Nov 2013 19:39:07 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E5=B0=86=E4=BD=9C=E4=B8=9A=E6=83=85?= =?UTF-8?q?=E5=86=B5=E6=94=B9=E6=88=90=E4=BD=9C=E4=B8=9A=E6=8F=90=E4=BA=A4?= =?UTF-8?q?=E6=83=85=E5=86=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/locales/zh.yml | 2 +- public/stylesheets/application.css | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/config/locales/zh.yml b/config/locales/zh.yml index 5c529ee7f..95cccd3cc 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -621,7 +621,7 @@ zh: label_course_overview: "课程动态" label_question_student: 作业交流 #bai label_homework_commit: 提交作业 #huang - label_homework_info: 作业情况 #huang + label_homework_info: 作业提交情况 #huang label_course_news: 课程通知 label_course_board: 讨论区 label_version: 版本 diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css index d6709d448..a0135fbbe 100644 --- a/public/stylesheets/application.css +++ b/public/stylesheets/application.css @@ -1723,7 +1723,7 @@ button.tab-right { #content .tabs_new {height: 2.6em; margin-bottom:1.2em; margin-top: 0.8em; position:relative; overflow:hidden;} #content .tabs_new ul {margin:0; position:absolute; bottom:0; padding-left: 0.5em; width: 2000px; border-bottom: 1px solid #15BCCF;font-size:14px;} #content .tabs_new ul li { - width:85px; /*modified by linchun*/ + width:100px; /*modified by linchun*/ float:left; list-style-type:none; white-space:nowrap;