From e9856b352465fce17553a8795d8b6c43c7c862ff Mon Sep 17 00:00:00 2001 From: xianbo Date: Mon, 28 Oct 2013 20:09:15 +0800 Subject: [PATCH] modify the style of the projects witch show --- app/controllers/users_controller.rb | 45 ++----------------------- app/helpers/users_helper.rb | 15 ++++++++- app/models/project.rb | 2 +- app/views/users/user_projects.html.erb | 9 +++-- app/views/users/user_watchlist.html.erb | 1 - app/views/users/watch_projects.html.erb | 14 +++----- 6 files changed, 26 insertions(+), 60 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 235e28792..ae2820cdf 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -64,6 +64,8 @@ class UsersController < ApplicationController events = Redmine::Activity::Fetcher.new(User.current, :author => @user).events(nil, nil, :limit => 20) @events_by_day = events.group_by(&:event_date) + @state = 0 + #add by huang unless User.current.admin? @@ -379,49 +381,7 @@ class UsersController < ApplicationController end end - - ### modified by fq def show - # has = { - # "show_issues" => true, - # "show_changesets" => true, - # "show_news" => true, - # "show_messages" => true, - # "show_bids" => true, - # } - #####fq - - # JournalsForMessage.reference_message(@user.id) - # show projects based on current user visibility - # @memberships = @user.memberships.all(:conditions => Project.visible_condition(User.current)) - - - # if @user == User.current - # events = [] - # activity = Redmine::Activity::Fetcher.new(User.current, :author => User.current) - # activity.scope_select {|t| !has["show_#{t}"].nil?} - # events += activity.events(nil, nil, :limit => 10) - # @watcher = User.watched_by(@user) - # for user in @watcher - # activity = Redmine::Activity::Fetcher.new(User.current, :author => user) - # activity.scope_select {|t| !has["show_#{t}"].nil?} - # events += activity.events(nil, nil, :limit => 10) - # end - # else - # activity = Redmine::Activity::Fetcher.new(User.current, :author => @user) - # activity.scope_select {|t| !has["show_#{t}"].nil?} - # events = activity.events(nil, nil, :limit => 10) - # end - # @events = [] - # @events_by_day = events.group_by(&:event_date) - # @events_by_day.keys.sort.reverse.each do |day| - # @events += @events_by_day[day].sort {|x,y| y.event_datetime <=> x.event_datetime} - # end - # @offset, @limit = api_offset_and_limit({:limit => 10}) - # @activity_count = @events.size - # @activity_pages = Paginator.new @activity_count, @limit, params['page'] - # @offset ||= @activity_pages.offset - # @events_by_day_ = @events.slice(@offset,@limit) case params[:type] when "1" if @user == User.current @@ -570,6 +530,7 @@ class UsersController < ApplicationController @watch_projects << Project.find(obj.watchable_id) end end + @state = 1 respond_to do |format| format.html { render :layout => 'base_users' diff --git a/app/helpers/users_helper.rb b/app/helpers/users_helper.rb index eb62f49ce..8d4a56aae 100644 --- a/app/helpers/users_helper.rb +++ b/app/helpers/users_helper.rb @@ -92,6 +92,20 @@ module UsersHelper content_tag('div', content, :class => "pagination") end + def watch_projects(state) + content = ''.html_safe + case state + when 0 + s = content_tag('span', l(:label_project_take), :class => "current-page") + content << content_tag('li', s) + content << content_tag('li', link_to(l(:label_has_watched_project), {:controller => 'users', :action => 'watch_projects', :type => 1})) + when 1 + s = content_tag('span', l(:label_has_watched_project), :class => "current-page") + content << content_tag('li', link_to(l(:label_project_take), {:controller => 'users', :action => 'user_projects'})) + content << content_tag('li', s, :class => "current-page") + end + content_tag('div', content, :class => "pagination") + end def user_course(state) content = ''.html_safe if @user != User.current @@ -193,5 +207,4 @@ def sort_user(state, project_type) content = content_tag('ul', content) content_tag('div', content, :class => "tabs_enterprise") end -#end end diff --git a/app/models/project.rb b/app/models/project.rb index 9e5c2f663..c10b95496 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -89,7 +89,7 @@ class Project < ActiveRecord::Base has_many :tags, :through => :project_tags, :class_name => 'Tag' - has_many :project_tags, :class_name => 'ProjectTags', :dependent => :destroy + has_many :project_tags, :class_name => 'ProjectTags' acts_as_nested_set :order => 'name', :dependent => :destroy acts_as_attachable :view_permission => :view_files, diff --git a/app/views/users/user_projects.html.erb b/app/views/users/user_projects.html.erb index 0996a0002..afa7e522b 100644 --- a/app/views/users/user_projects.html.erb +++ b/app/views/users/user_projects.html.erb @@ -1,11 +1,10 @@ -

-<%= l(:label_project_take)%> - <%= link_to l(:label_has_watched_project) , {:controller => 'users', :action => 'watch_projects', :id => @user.id}%> -<% unless @memberships.empty? %> <% 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) %>

+ <%= 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) %> <% end %> +

<%= watch_projects @state%> + +<% unless @memberships.empty? %>