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/members_controller.rb b/app/controllers/members_controller.rb index 712c86680..5168913a7 100644 --- a/app/controllers/members_controller.rb +++ b/app/controllers/members_controller.rb @@ -100,7 +100,7 @@ class MembersController < ApplicationController #added by nie if(params[:membership][:role_ids] && params[:membership][:role_ids][0] == "3") @projectInfo = ProjectInfo.new(:user_id => @member.user_id, :project_id => @project.id) - @projectInfo.save + @projectInfo.save else user_admin = ProjectInfo.where("user_id = ? and project_id = ?", @member.user_id, @project.id) if user_admin.size > 0 diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index af968144f..c0050d646 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -326,17 +326,17 @@ class ProjectsController < ApplicationController @s_type = 2 end else - @offset ||= @project_pages.reverse_offset + @offset ||= @project_pages.reverse_offset unless @offset == 0 - @projects_status = @projects_status.reorder('changesets_count').offset(@offset).limit(@limit).all.reverse + @projects_status = @projects_status.offset(@offset).limit(@limit).all.reverse else limit = @project_count % @limit if limit == 0 limit = @limit end - @projects_status = @projects_status.reorder('changesets_count').offset(@offset).limit(limit).all.reverse + @projects_status = @projects_status.offset(@offset).limit(limit).all.reverse end - @s_type = 1 + @s_type = 0 # @projects = @projects.sort {|x,y| y.created_on <=> x.created_on } # @projects = @projects[@offset, @limit] end @@ -510,11 +510,14 @@ class ProjectsController < ApplicationController @course.extra='course' + DateTime.parse(Time.now.to_s).strftime('%Y-%m-%d_%H-%M-%S').to_s @course.safe_attributes = params[:project][:course] @course.tea_id = User.current.id - # added by bai + # added by bai @course.term = params[:term] @course.time = params[:time] + @course.setup_time = params[:setup_time] + @course.endup_time = params[:endup_time] + @course.class_period = params[:class_period] end - # end + # end # @course.save # project = ProjectInfo.create(:user_id => User.current.id, :project_id => @project.id) # project_status = ProjectStatus.create(:project_id => @project.id) @@ -536,7 +539,7 @@ class ProjectsController < ApplicationController r = Role.givable.find_by_id(Setting.new_project_user_role_id.to_i) || Role.givable.first m = Member.new(:user => User.current, :roles => [r]) project = ProjectInfo.new(:user_id => User.current.id, :project_id => @project.id) - UserGrade.create(:user_id => User.current.id, :project_id => @project.id, :grade => 0) + user_grades = UserGrade.create(:user_id => User.current.id, :project_id => @project.id) if params[:project][:is_public] == '1' project_status = ProjectStatus.create(:project_id => @project.id, :watchers_count => 0, :changesets_count => 0, :grade => 0, :project_type => @course_tag) end @@ -590,6 +593,7 @@ class ProjectsController < ApplicationController r = Role.givable.find_by_id(Setting.new_project_user_role_id.to_i) || Role.givable.first m = Member.new(:user => User.current, :roles => [r]) project = ProjectInfo.new(:user_id => User.current.id, :project_id => @project.id) + user_grades = UserGrade.create(:user_id => User.current.id, :project_id => @project.id) if params[:project][:is_public] == '1' || @course_tag=="1" project_status = ProjectStatus.create(:project_id => @project.id, :watchers_count => 0, :changesets_count => 0) end @@ -744,7 +748,7 @@ class ProjectsController < ApplicationController # @course_tag = params[:course] # if @course_tag == '1' if @project.project_type == 1 - @course = Course.find_by_extra(@project.identifier) + @course = Course.find_by_extra(@project.identifier) render :layout => 'base_courses' else render :layout => 'base_projects' @@ -758,7 +762,7 @@ class ProjectsController < ApplicationController #by young def member if @project.project_type == 1 - render :layout => 'base_courses' + render :layout => 'base_courses' end # roles = Role.find_all_givable # members = @project.member_principals.includes(:roles, :principal).all.sort @@ -805,10 +809,13 @@ class ProjectsController < ApplicationController @course = Course.find_by_extra(@project.identifier) unless @course.nil? @course.password = params[:project][:course][:password] - # added by bai + # added by bai @course.term = params[:term] @course.time = params[:time] - # end + @course.setup_time = params[:setup_time] + @course.endup_time = params[:endup_time] + @course.class_period = params[:class_period] + # end @course.save end @project.set_allowed_parent!(params[:project]['parent_id']) if params[:project].has_key?('parent_id') @@ -905,7 +912,7 @@ class ProjectsController < ApplicationController def watcherlist if @watched - @users -= watched.watcher_users + @users -= watched.watcher_users end end end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index cb6b2d677..dd2b5341a 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,25 @@ 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).where('user_id in (?)', watcher).order('id desc') + elsif user_temp.size == 1 + activity = Activity.where('user_id = ?', user_temp).where('user_id in (?)', watcher).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/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/bids/_list_projects.html.erb b/app/views/bids/_list_projects.html.erb index 677cec60a..d79059ba0 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 %> + + + + + +
@@ -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_courses.html.erb b/app/views/layouts/base_courses.html.erb index 50c794012..b24684db1 100644 --- a/app/views/layouts/base_courses.html.erb +++ b/app/views/layouts/base_courses.html.erb @@ -111,14 +111,25 @@
- + - + + + + + + + + + + + + - + diff --git a/app/views/layouts/base_homework.html.erb b/app/views/layouts/base_homework.html.erb index c39459d56..67cac4ad6 100644 --- a/app/views/layouts/base_homework.html.erb +++ b/app/views/layouts/base_homework.html.erb @@ -67,7 +67,7 @@ - + <% unless @bid.parent_id.nil?%> diff --git a/app/views/layouts/base_users.html.erb b/app/views/layouts/base_users.html.erb index b92f68ac8..851ffcd2a 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'%>
<%= l(:label_main_teacher) %> :<%= link_to(@course.teacher.lastname+@course.teacher.firstname, user_path(@course.teacher)) %>
<%= l(:label_setup_time) %> :<%= @course.setup_time %>
<%= l(:label_endup_time) %> :<%= @course.endup_time %>
<%= l(:label_class_period) %> :<%= @course.class_period %> <%= l(:label_class_hour)%>
<%= l(:label_main_term) %> :<%= @course.time %> -- <%= @course.term %><%= l(:label_main_term) %> :<%= @course.time %> <%= @course.term %>
<%= l(:label_limit_time) %>: <%= @bid.deadline %><%= l(:label_limit_time) %>: <%= @bid.deadline %>
- + <% if @newss.empty? %> +

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

+ <% else %> + <% @newss.each do |news| %> - -
<%= image_tag(url_to_avatar(news.author), :class => "avatar") %> - <% if @project.project_type == 1 %> - - - - <% else %> - - - - <% end %> - - - - - - - -
<%=link_to_user(news.author)if news.respond_to?(:author) %> <%= l(:label_project_notice)%> <%= link_to h(news.title), news_path(news) %>
<%=link_to_user(news.author)if news.respond_to?(:author) %> <%= l(:label_project_newshare)%> <%= link_to h(news.title), news_path(news) %>
<%= textilizable(news, :description) %>
<%= format_time(news.created_on) %><%= link_to l(:label_project_newother),news_path(news)%><%= "(#{l(:label_x_comments, :count => news.comments_count)})" if news.comments_count >= 0 %>
-<% end %> -<% end %>
+
<%= link_to image_tag(url_to_avatar(news.author), :class => "avatar"), user_path(news.author) %> + + <% if @project.project_type == 1 %> + + + + <% else %> + + + + <% end %> + + + + + + + +
<%= link_to_user(news.author)if news.respond_to?(:author) %><%= l(:label_project_notice)%><%= link_to h(news.title), news_path(news) %> + <%= delete_link news_path(news) if User.current.allowed_to?(:manage_news, @project) %>
<%= link_to_user(news.author)if news.respond_to?(:author) %><%= l(:label_project_newshare)%> <%= link_to h(news.title), news_path(news) %> + <%= delete_link news_path(news) if User.current.allowed_to?(:manage_news, @project) %>
<%= textilizable(news, :description) %>
<%= format_time(news.created_on) %><%= link_to l(:label_project_newother),news_path(news)%><%= "(#{l(:label_x_comments, :count => news.comments_count)})" if news.comments_count >= 0 %>
+ <% end %> + <% end %> +
+ + <% other_formats_links do |f| %> + <%= f.link_to 'Atom', :url => {:project_id => @project, :key => User.current.rss_key} %> + <% end %> + + <% content_for :header_tags do %> + <%= auto_discovery_link_tag(:atom, params.merge({:format => 'atom', :page => nil, :key => User.current.rss_key})) %> + <%= stylesheet_link_tag 'scm' %> + <% end %> + + <% html_title(l(:label_news_plural)) -%>
- -<% other_formats_links do |f| %> - <%= f.link_to 'Atom', :url => {:project_id => @project, :key => User.current.rss_key} %> -<% end %> - -<% content_for :header_tags do %> - <%= auto_discovery_link_tag(:atom, params.merge({:format => 'atom', :page => nil, :key => User.current.rss_key})) %> - <%= stylesheet_link_tag 'scm' %> -<% end %> - -<% html_title(l(:label_news_plural)) -%> diff --git a/app/views/news/show.html.erb b/app/views/news/show.html.erb index b8296716d..3c7d0adad 100644 --- a/app/views/news/show.html.erb +++ b/app/views/news/show.html.erb @@ -8,7 +8,7 @@ <%= delete_link news_path(@news) if User.current.allowed_to?(:manage_news, @project) %> -

<%= h @news.title %>

+

<%=h @news.title %>

<% if authorize_for('news', 'edit') %>