diff --git a/app/controllers/bids_controller.rb b/app/controllers/bids_controller.rb index 9e51a859..f2e197cd 100644 --- a/app/controllers/bids_controller.rb +++ b/app/controllers/bids_controller.rb @@ -307,11 +307,14 @@ class BidsController < ApplicationController # a = [1] # @project = Project.where("id in []", a) @user = @bid.author - @bidding_project = @bid.biding_projects + @bidding_project = @bid.biding_projects.all + + @bidding_project = @bidding_project.sort {|a,b| b.project.project_status.grade <=> a.project.project_status.grade} if @bid.homework_type == 1 @homework = HomeworkAttach.new @homework_list = @bid.homeworks end + respond_to do |format| if @bid.reward_type == 3 format.html { diff --git a/app/controllers/members_controller.rb b/app/controllers/members_controller.rb index fadeec3e..940172e9 100644 --- a/app/controllers/members_controller.rb +++ b/app/controllers/members_controller.rb @@ -48,12 +48,14 @@ class MembersController < ApplicationController def create members = [] project_info = [] + user_grade = [] if params[:membership] if params[:membership][:user_ids] attrs = params[:membership].dup user_ids = attrs.delete(:user_ids) user_ids.each do |user_id| members << Member.new(:role_ids => params[:membership][:role_ids], :user_id => user_id) + user_grade << UserGrade.new(:user_id => user_id, :project_id => @project.id) ## added by nie if(params[:membership][:role_ids] && params[:membership][:role_ids][0] == "3") project_info << ProjectInfo.new(:user_id => user_id, :project_id => @project.id) @@ -65,13 +67,14 @@ class MembersController < ApplicationController members << Member.new(:role_ids => params[:membership][:role_ids], :user_id => params[:membership][:user_id]) ## added by nie if(params[:membership][:role_ids] && params[:membership][:role_ids][0] == "3") - project_info << ProjectInfo.new(:role_ids => params[:membership][:role_ids], :user_id => params[:membership][:user_id]) + project_info << ProjectInfo.new(:project_id => @project.id, :user_id => params[:membership][:user_id]) end ## end end @project.members << members # added by nie @project.project_infos << project_info + @project.user_grades << user_grade # end end @@ -124,13 +127,20 @@ class MembersController < ApplicationController def destroy if request.delete? && @member.deletable? @member.destroy - end + # end user_admin = ProjectInfo.where("user_id = ? and project_id = ?", @member.user_id, @project.id) if user_admin.size > 0 user_admin.each do |user| user.destroy end end + user_grade = UserGrade.where("user_id = ? and project_id = ?", @member.user_id, @project.id) + if user_grade.size > 0 + user_grade.each do |grade| + grade.destroy + end + end + end respond_to do |format| format.html { redirect_to_settings_in_projects } format.js diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 783e8222..b7427b1e 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -146,8 +146,20 @@ class ProjectsController < ApplicationController # # end # end + # @projects = Project.where("project_type <> ? or project_type is null", 1) # @projects.each do |project| - # ProjectStatus.create(:changesets_count => project.changesets.count, :project_id => project.id, :watchers_count => project.watcher_users.count) + # @id = project.id + # @users = Member.find_by_sql("SELECT + # members.user_id + # FROM members + # INNER JOIN users + # ON members.user_id = users.id + # WHERE members.project_id = #{@id} + # AND (users.type = 'User' AND users.status = 1);") + # @users.each do |user| + # UserGrade.create(:project_id => project.id, :user_id => user.user_id) + # end + # #ProjectStatus.create(:changesets_count => project.changesets.count, :project_id => project.id, :watchers_count => project.watcher_users.count) # end # @projects_status = Project.visible.like(params[:name]) if params[:name].present? @project_count = @projects_status.count @@ -175,13 +187,13 @@ class ProjectsController < ApplicationController when '1' @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.reorder('grade').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.reorder('grade').offset(@offset).limit(limit).all.reverse end @s_type = 1 @@ -202,13 +214,13 @@ class ProjectsController < ApplicationController else @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.reorder('grade').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.reorder('grade').offset(@offset).limit(limit).all.reverse end @s_type = 1 # @projects = @projects.sort {|x,y| y.created_on <=> x.created_on } @@ -524,8 +536,9 @@ 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) - if (params[:project][:is_public] == '1' && @course_tag != "1") || (@course_tag=="1" && params[:project][:is_public] == '1') - project_status = ProjectStatus.create(:project_id => @project.id, :watchers_count => 0, :changesets_count => 0, :project_type => @course_tag) + UserGrade.create(:user_id => User.current.id, :project_id => @project.id, :grade => 0) + 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 @project.members << m @project.project_infos << project @@ -747,6 +760,20 @@ class ProjectsController < ApplicationController if @project.project_type == 1 render :layout => 'base_courses' end + # roles = Role.find_all_givable + # members = @project.member_principals.includes(:roles, :principal).all.sort +# + # users = UserGrade.find_by_sql("select * from user_grades where project_id = #{@project.id}").sort {|a,b| a[:grade] <=> b[:grade]} +# + # temp = [] + # users.each do |user| + # members.each do |member| + # if member[:user_id] == user[:user_id] + # temp << member + # end + # end + # end + # temps = temp.reverse end # def news @@ -790,7 +817,7 @@ class ProjectsController < ApplicationController project_status = ProjectStatus.find_by_project_id(@project.id) project_status.destroy elsif params[:project][:is_public] == '1' - project_status = ProjectStatus.create(:project_id => @project.id, :watchers_count => 0, :changesets_count => 0, :project_type => 1) + project_status = ProjectStatus.create(:project_id => @project.id, :watchers_count => 0, :changesets_count => 0,:grade => 0, :project_type => 1) end respond_to do |format| diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index f9d4a30e..eb8e675e 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -280,13 +280,13 @@ class UsersController < ApplicationController when '1' @offset ||= @user_pages.reverse_offset unless @offset == 0 - @users_statuses = scope.reorder('changesets_count').offset(@offset).limit(@limit).all.reverse + @users_statuses = scope.reorder('grade').offset(@offset).limit(@limit).all.reverse else limit = @user_count % @limit if limit == 0 limit = @limit end - @users_statuses = scope.reorder('changesets_count').offset(@offset).limit(limit).all.reverse + @users_statuses = scope.reorder('grade').offset(@offset).limit(limit).all.reverse end @s_type = 1 #sort {|x,y| y.user_status.changesets_count <=> x.user_status.changesets_count} diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 571eb0b8..0db12e24 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -254,11 +254,13 @@ module ApplicationHelper s << "" end if @project.project_type == 1 - unless Course.find_by_extra(@project.identifier).tea_id == User.current.id + unless Course.find_by_extra(@project.identifier).nil? + unless Course.find_by_extra(@project.identifier).tea_id == User.current.id s << "" s << join_in_course(@project, User.current)#, ['whiteButton']) s << "" end + end end s << (render :partial => 'projects/project', :locals => {:project => project}).to_s s << "\n" diff --git a/app/models/project.rb b/app/models/project.rb index e45c8dc2..ab558ec9 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -70,6 +70,7 @@ class Project < ActiveRecord::Base has_one :project_status, :class_name => "ProjectStatus", :dependent => :destroy has_one :project_status, :class_name => "ProjectStatus", :dependent => :destroy has_one :project_status, :class_name => "ProjectStatus", :dependent => :destroy + has_many :user_grades, :class_name => "UserGrade", :dependent => :destroy #end has_one :wiki, :dependent => :destroy diff --git a/app/models/user_grade.rb b/app/models/user_grade.rb new file mode 100644 index 00000000..f79fcd2c --- /dev/null +++ b/app/models/user_grade.rb @@ -0,0 +1,4 @@ +class UserGrade < ActiveRecord::Base + # attr_accessible :title, :body + belongs_to :project +end diff --git a/app/views/bids/_list_projects.html.erb b/app/views/bids/_list_projects.html.erb index 42812a5f..06a7a85f 100644 --- a/app/views/bids/_list_projects.html.erb +++ b/app/views/bids/_list_projects.html.erb @@ -8,12 +8,14 @@
<%= link_to(b_project.project.name, project_path(b_project.project)) %> + <%= l(:label_join_bidding)%> | @@ -21,7 +23,7 @@
-
+ <%= l(:label_system_grade) %>:<%= (b_project.project.project_status.grade.nil? ? 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/projects/_project.html.erb b/app/views/projects/_project.html.erb
index ad750fe9..0a4f0b0e 100644
--- a/app/views/projects/_project.html.erb
+++ b/app/views/projects/_project.html.erb
@@ -87,19 +87,12 @@
<%= content_tag('span', "#{l(:label_create_time)}: ") %><%= content_tag('span', format_time(@project.created_on)) %>
+
+ <%= content_tag('span', "#{l(:label_project_grade)}: ")%><%= @project.project_status.grade%>
+
-
-
diff --git a/app/views/projects/member.html.erb b/app/views/projects/member.html.erb
index f0b94c6e..a3cd24ce 100644
--- a/app/views/projects/member.html.erb
+++ b/app/views/projects/member.html.erb
@@ -4,16 +4,29 @@
<%= error_messages_for 'member' %>
<% roles = Role.find_all_givable
members = @project.member_principals.includes(:roles, :principal).all.sort %>
-<% if members.any? %>
-<% members.each do |member| %>
+ <%
+ users = UserGrade.find_by_sql("select * from user_grades where project_id = #{@project.id}").sort {|a,b| a[:grade] <=> b[:grade]}
+ %>
+ <% temp = [] %>
+ <% users.each do |user|%>
+ <% members.each do |member|%>
+ <% if member[:user_id] == user[:user_id] %>
+ <% temp << member%>
+ <% end %>
+ <% end %>
+ <% end %>
+ <% temps = temp.reverse %>
+<% if temps.any? %>
+<% temps.each do |member| %>
- <% next if member.new_record? %>
- <% unless member.created_on.nil? %>
+ <% next if member.new_record? %>
+ <% unless member.created_on.nil? %>
<%= content_tag "p", "#{format_date(member.created_on)}#{l(:label_member_since)}", :class => "float_right member_since" %>
<% end %>
<%= member.user.nil? ? '' : (link_to image_tag(url_to_avatar(member.user), :class => 'avatar'), :class => "avatar") %>
<%= content_tag "div", link_to_user(member.principal), :class => "nomargin avatar_name" %>
+
<% if @project.project_type == 1 %>
<% else%>
<%= content_tag "div", content_tag("p", member.roles.sort.collect(&:to_s).join(', ')), :class => "clear avatar_name" %>
+ <% users.each do |user|%>
+ <% if user[:user_id] == member[:user_id]%>
+ @@ -26,9 +39,17 @@ <% else %> <% end %> -
+
+ <% end %>
+ <% end %>
<% end %>
<%= call_hook(:view_projects_settings_members_table_row, { :project => @project, :member => member}) %>
@@ -40,4 +61,6 @@
<%= l(:label_no_data) %>
<% end %>
-
\ No newline at end of file
+
+
+
diff --git a/app/views/projects/search.html.erb b/app/views/projects/search.html.erb
index 8671d5ad..195e4961 100644
--- a/app/views/projects/search.html.erb
+++ b/app/views/projects/search.html.erb
@@ -28,25 +28,13 @@
<%end%>
-
+
<%= l(:label_user_for_project_grade) %>: <%= user[:grade] %> +
<%= render_project_hierarchy(@projects)%>
-
+
<%= link_to image_tag(url_to_avatar(user), :class => 'avatar'), user_path(user) %>
<%= content_tag "span", link_to_user(user), :class => "nomargin avatar_name" %>
+
+
<%= l(:label_x_has_fans,:count=>user.watcher_users.count)%>
<%= l(:label_has_watchers,:count=>User.watched_by(user.id).count) %>
+
+
+ <%= l(:label_user_grade) %>: <%= user.user_status.grade %>
+
<% unless user.memberships.empty? %>
@@ -139,7 +145,7 @@
+ <% if @memberships.empty? %>
+ <% if @user != User.current %>
+
diff --git a/lib/redmine/activity/fetcher.rb b/lib/redmine/activity/fetcher.rb
index 58424bb6..c2e174ef 100644
--- a/lib/redmine/activity/fetcher.rb
+++ b/lib/redmine/activity/fetcher.rb
@@ -56,7 +56,7 @@ module Redmine
when :default
default_scope!
else
- @scope = s & event_types
+ @scope = s & event_types
end
end
@@ -70,7 +70,7 @@ module Redmine
def events(from = nil, to = nil, options={})
e = []
@options[:limit] = options[:limit]
-
+
@scope.each do |event_type|
constantized_providers(event_type).each do |provider|
e += provider.find_events(event_type, @user, from, to, @options)
diff --git a/public/themes/redpenny-master/stylesheets/application.css b/public/themes/redpenny-master/stylesheets/application.css
index ebd19e8b..0f1e8781 100644
--- a/public/themes/redpenny-master/stylesheets/application.css
+++ b/public/themes/redpenny-master/stylesheets/application.css
@@ -1877,11 +1877,15 @@ a.font-user-after-color{
height:25px;
line-height:23px;
}
-/*end*/
-.create-share{
+div.avatar_user{
+ position: relative;
+ float:left;
+ margin-top:-30px;
+ margin-left: 550px;
+}.create-share{
border-radius: 5px;
padding-top: 3px;
margin-top: 5px;
margin-bottom: 5px;
-}
+}
\ No newline at end of file
+ <%= l(:label_project_course_un) %> + + <% else %> ++ <%= l(:label_project_course_unadd) %> + <% if User.current.user_extensions.identity == 0 %> + <%= link_to"#{l(:label_course_new)}",{:controller=>'projects',:action=>'new', :course => 1}, :class => 'icon icon-add' %> + <% end %> + + <% end %> + <% else %> + <% if User.current.user_extensions.identity == 0 %> + <%= link_to"#{l(:label_course_new)}",{:controller=>'projects',:action=>'new', :course => 1}, :class => 'icon icon-add' %> + <% end %> +
|