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/projects_controller.rb b/app/controllers/projects_controller.rb index af968144f..eab4feff8 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -536,7 +536,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 +590,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 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) %>