From b55c5d20a3ccff9fbd16cb2b2ea0d6682cd81790 Mon Sep 17 00:00:00 2001 From: yanxd Date: Thu, 31 Oct 2013 20:13:49 +0800 Subject: [PATCH 1/8] added activity info from event, warning. --- app/helpers/projects_helper.rb | 17 +++++++++++++++++ app/views/projects/member.html.erb | 5 +++-- app/views/projects/show.html.erb | 7 +++---- 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/app/helpers/projects_helper.rb b/app/helpers/projects_helper.rb index 8e792d690..9f9d0f35d 100644 --- a/app/helpers/projects_helper.rb +++ b/app/helpers/projects_helper.rb @@ -225,4 +225,21 @@ module ProjectsHelper end return @result end + + # 将动态中类型转换为可读的字符串 + def eventToLanguage event_type + case event_type + when "issue-note" + l :label_issue + when "issue" + l :label_issue + when "attachment" + l :label_attachment + when "news" + l :label_news + else + "" + end + end + end diff --git a/app/views/projects/member.html.erb b/app/views/projects/member.html.erb index d70831279..83c668744 100644 --- a/app/views/projects/member.html.erb +++ b/app/views/projects/member.html.erb @@ -7,8 +7,9 @@ <%= error_messages_for 'member' %> <% roles = Role.find_all_givable %> <% members = @project.member_principals.includes(:roles, :principal).all.sort %> - <% members = searchPeopleByRoles(@project, 3).sort if params[:role] == '1' %> - <% members = searchPeopleByRoles(@project, 5).sort if params[:role] == '2' %> + + <% members = searchPeopleByRoles(@project, 3).sort if params[:role] == '1' %> + <% members = searchPeopleByRoles(@project, 5).sort if params[:role] == '2' %> <% if @project.project_type == 1 %> <%= render :partial => 'member_list', :locals => {:members => members} %> <% else %> diff --git a/app/views/projects/show.html.erb b/app/views/projects/show.html.erb index 23061be39..81d2ac2dc 100644 --- a/app/views/projects/show.html.erb +++ b/app/views/projects/show.html.erb @@ -21,15 +21,14 @@ <%= h(e.project) if @project.nil? || @project.id != e.project.id %> <%= link_to_user(e.event_author) if e.respond_to?(:event_author) %> - <%= l(:label_new_activity) %> - <%= link_to format_activity_title(e.event_title), e.event_url %> + <%= l(:label_new_activity) %> + <%= link_to "#{eventToLanguage(e.event_type)}: "<

- - <%= textilizable( stringCut240(e.event_description) ) %> + <%= textilizable( truncate(e.event_description, :length => 240)) %>

From 75c0480071916da633df46bc74e5f40e9efff21f Mon Sep 17 00:00:00 2001 From: nieguanghui Date: Thu, 31 Oct 2013 21:44:10 +0800 Subject: [PATCH 2/8] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=B8=AA=E4=BA=BA?= =?UTF-8?q?=E6=B4=BB=E5=8A=A8=E5=88=97=E8=A1=A8=EF=BC=8C=E4=BD=9C=E4=B8=9A?= =?UTF-8?q?=E8=BF=87=E6=BB=A4=E5=8A=9F=E8=83=BD=EF=BC=8C=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E4=BD=9C=E4=B8=9A=E6=90=9C=E7=B4=A2=E6=A1=86?= =?UTF-8?q?=EF=BC=8C=E4=BF=AE=E5=A4=8D=E8=AF=BE=E7=A8=8B=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E4=BB=A5=E5=AD=A6=E7=94=9F=E8=A7=92=E8=89=B2=E6=90=9C=E7=B4=A2?= =?UTF-8?q?=E4=B9=9F=E4=BC=9A=E5=87=BA=E7=8E=B0=E6=96=B0=E5=BB=BA=E8=AF=BE?= =?UTF-8?q?=E7=A8=8B=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/bids_controller.rb | 36 ++++++++++++------- app/controllers/users_controller.rb | 21 ++++++++++- app/views/bids/_list_projects.html.erb | 23 ++++++++++-- app/views/layouts/base_users.html.erb | 2 ++ app/views/projects/_project.html.erb | 2 +- app/views/projects/search.html.erb | 7 ++-- app/views/users/show.html.erb | 16 +++++++++ app/views/users/user_activities.html.erb | 1 + config/locales/zh.yml | 7 +++- config/routes.rb | 1 + .../stylesheets/application.css | 13 ++++++- 11 files changed, 109 insertions(+), 20 deletions(-) diff --git a/app/controllers/bids_controller.rb b/app/controllers/bids_controller.rb index 13ef9be5d..9161287bf 100644 --- a/app/controllers/bids_controller.rb +++ b/app/controllers/bids_controller.rb @@ -7,7 +7,7 @@ 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, + 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, :destroy, :add, :new, ] @@ -27,8 +27,6 @@ class BidsController < ApplicationController else @bids = Bid.visible.where('reward_type = ?', 1) end - - @bids = @bids.like(params[:name]) if params[:name].present? @bid_count = @bids.count @@ -206,7 +204,7 @@ class BidsController < ApplicationController format.html { render :layout => 'base_contest' } - end + end format.api end @@ -232,12 +230,12 @@ class BidsController < ApplicationController format.html { render :layout => 'base_contest' } - end + end format.api end end - + def show_bid_project bids = Bid.where('parent_id = ?', @bid.id) @projects = [] @@ -258,12 +256,12 @@ class BidsController < ApplicationController format.html { render :layout => 'base_contest' } - end + end format.api end end - + def show_bid_user bids = Bid.where('parent_id = ?', @bid.id) @users = [] @@ -286,7 +284,7 @@ class BidsController < ApplicationController format.html { render :layout => 'base_contest' } - end + end format.api end @@ -310,6 +308,18 @@ class BidsController < ApplicationController # @project = Project.where("id in []", a) @user = @bid.author @bidding_project = @bid.biding_projects.all + if params[:student_id].present? + @temp = [] + @bidding_project.each do |pro| + if pro.project && pro.project.project_status + if /#{params[:student_id]}/ =~ pro.user.user_extensions.student_id + @temp << pro + end + end + @temp + end + @bidding_project = @temp + else #added by nie @temp = [] @bidding_project.each do |pro| @@ -319,9 +329,11 @@ class BidsController < ApplicationController @temp end if @temp.size > 0 - @bidding_project = @temp.sort {|a,b| b.project.project_status.grade <=> a.project.project_status.grade} + @bidding_project = @temp.sort {|a,b| b.project.project_status.grade <=> a.project.project_status.grade} end #ended + end + if @bid.homework_type == 1 @homework = HomeworkAttach.new @homework_list = @bid.homeworks @@ -340,7 +352,7 @@ class BidsController < ApplicationController format.html { render :layout => 'base_contest' } - end + end format.api end end @@ -369,7 +381,7 @@ class BidsController < ApplicationController format.html { render :layout => 'base_contest' } - end + end format.api end end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index cb6b2d677..abb9b3079 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -112,7 +112,9 @@ class UsersController < ApplicationController for user in @watcher events << Redmine::Activity::Fetcher.new(User.current, :author => @user).events(nil, nil, :limit => 30) end - + + + @events_by_day = events.group_by(&:event_date) unless User.current.admin? @@ -424,6 +426,23 @@ class UsersController < ApplicationController @state = 0 end + if params[:user].present? + user_temp = User.find_by_sql("select id from users where firstname like '%#{params[:user]}%' or lastname like '%#{params[:user]}%'") + if user_temp.size > 1 + activity = Activity.where('user_id in (?)', user_temp).order('id desc') + elsif user_temp.size == 1 + activity = Activity.where('user_id = ?', user_temp).order('id desc') + else + activity = Activity.where("1 = 0") + end + @offset, @limit = api_offset_and_limit({:limit => 10}) + @activity_count = activity.count + @activity_pages = Paginator.new @activity_count, @limit, params['page'] + @offset ||= @activity_pages.offset + @activity = activity.offset(@offset).limit(@limit) + @state = 0 + end + #Modified by nie unless User.current.admin? diff --git a/app/views/bids/_list_projects.html.erb b/app/views/bids/_list_projects.html.erb index 790ee53d2..cd0494aea 100644 --- a/app/views/bids/_list_projects.html.erb +++ b/app/views/bids/_list_projects.html.erb @@ -1,6 +1,25 @@ - +<%= form_tag(:controller => 'bids', :action => "show_project", :method => :get) do %> +
+ + + + + + + + +
<%= l(:label_task_plural)%> +
+
+<% end %> <% bidding_project.each do |b_project|%> <% if b_project.project %> + + + <% else %> - <%= l(:label_new_course)%> - + + <%= l(:label_new_course)%> + + <% if User.current.user_extensions.identity == 0 %> + <% end %> <% end %>
@@ -24,7 +43,7 @@ - <%= l(:label_system_grade) %>:<%= (b_project.project.project_status.nil? ? 0 : b_project.project.project_status.grade) unless (b_project.project.project_status.nil? && b_project.project.nil?) %> + <%= l(:label_system_grade) %>:<%= (b_project.project.project_status.nil? ? 0.0 : b_project.project.project_status.grade) unless (b_project.project.project_status.nil? && b_project.project.nil?) %> <% if get_prize(b_project).nil? or get_prize(b_project) == "" %> <% if @bid.deadline < Date.today %> <%= l(:label_noawards)%> diff --git a/app/views/layouts/base_users.html.erb b/app/views/layouts/base_users.html.erb index 5b031bda1..bf17535d6 100644 --- a/app/views/layouts/base_users.html.erb +++ b/app/views/layouts/base_users.html.erb @@ -213,12 +213,14 @@ <%= render_menu :user_menu %> <% end %> + <%= yield %> <%= call_hook :view_layouts_base_content %>
<%= render_flash_messages %> + <%= render :partial => 'layouts/base_footer'%>
<% if @project.project_type !=1 %> - <%= content_tag('span', "#{l(:label_project_grade)}: ")%><%= @project.project_status.grade%> + <%= content_tag('span', "#{l(:label_project_grade)}: ")%><%=@project.project_status ? @project.project_status.grade : 0.0 %> <% end %>
diff --git a/app/views/projects/search.html.erb b/app/views/projects/search.html.erb index 195e49618..7363b63c0 100644 --- a/app/views/projects/search.html.erb +++ b/app/views/projects/search.html.erb @@ -12,10 +12,13 @@
<%= link_to(l(:label_project_new), {:controller => 'projects', :action => 'new'}, :class => 'icon icon-add') if User.current.allowed_to?(:add_project, nil, :global => true) %><%= link_to(l(:label_course_new), {:controller => 'projects', :action => 'new', :course => 1, :project_type => @project_type}, :class => 'icon icon-add') if User.current.allowed_to?(:add_project, nil, :global => true) %>