From cefa6efc1ba3de2ac6b41789786a16a7713096ee Mon Sep 17 00:00:00 2001 From: huang Date: Thu, 17 Mar 2016 16:36:57 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E5=8A=A8=E6=80=81?= =?UTF-8?q?=E4=B8=AD=E5=8A=A0=E5=85=A5=E9=99=84=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/projects_controller.rb | 45 ++----------------- .../projects/_project_activities.html.erb | 2 +- app/views/users/_project_attachment.html.erb | 36 ++++++++++----- 3 files changed, 29 insertions(+), 54 deletions(-) diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 05c80a9fc..2ced977be 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -300,66 +300,27 @@ class ProjectsController < ApplicationController end # 统计访问量 @project.update_attribute(:visits, @project.visits.to_i + 1) -=begin - cond = @project.project_condition(Setting.display_subprojects_issues?) - has = { - "show_issues" => true , - "show_files" => true, - "show_documents" => true, - "show_messages" => true, - "show_news" => true, - "show_bids" => true, - "show_contests" => true, - "show_wiki_edits"=>true, - "show_journals_for_messages" => true - } - # 读取项目默认展示的动态时间天数 - @days = Setting.activity_days_default.to_i - @date_to ||= Date.today + 1 - # 时间跨度不能太大,不然很慢,所以删掉了-1.years - @date_from = @date_to - @days - @with_subprojects = params[:with_subprojects].nil? ? Setting.display_subprojects_issues? : (params[:with_subprojects] == '1') -=end - @author = params[:user_id].blank? ? nil : User.active.find(params[:user_id]) - # 决定显示所用用户或单个用户活动 -=begin - @activity = Redmine::Activity::Fetcher.new(User.current, - :project => @project, - :with_subprojects => @with_subprojects, - :author => @author) - @activity.scope_select {|t| !has["show_#{t}"].nil?} -=end - @page = params[:page] ? params[:page].to_i + 1 : 0 # 根据私密性,取出符合条件的所有数据 if User.current.member_of?(@project) || User.current.admin? case params[:type] when nil - @events_pages = ForgeActivity.where("project_id = ? and forge_act_type in ('Issue', 'Message','News', 'ProjectCreateInfo')",@project).order("updated_at desc").limit(10).offset(@page * 10) + @events_pages = ForgeActivity.where("project_id = ? and forge_act_type in ('Issue', 'Message','News', 'ProjectCreateInfo', 'Attachment')",@project).order("updated_at desc").limit(10).offset(@page * 10) when 'issue' @events_pages = ForgeActivity.where("project_id = ? and forge_act_type = 'Issue'",@project).order("updated_at desc").limit(10).offset(@page * 10) when 'news' @events_pages = ForgeActivity.where("project_id = ? and forge_act_type = 'News'",@project).order("updated_at desc").limit(10).offset(@page * 10) when 'message' @events_pages = ForgeActivity.where("project_id = ? and forge_act_type = 'Message'",@project).order("updated_at desc").limit(10).offset(@page * 10) + when 'attachment' + @events_pages = ForgeActivity.where("project_id = ? and forge_act_type = 'Attachment'",@project).order("updated_at desc").limit(10).offset(@page * 10) end - - #events = @activity.events(@date_from, @date_to) else @events_pages = ForgeActivity.includes(:project).where("forge_activities.project_id = ? and projects.is_public = ? and forge_act_type != ? ",@project,1, "Document").order("created_at desc") .page(params['page'|| 1]).per(10); - # @events = @activity.events(@date_from, @date_to, :is_public => 1) end - -=begin - @events_pages = Paginator.new events.count, 10, params['page'] - # 总的数据中取出某一页 - events = events.slice(@events_pages.offset,10) - # 按天分组 - @events_by_day = events.group_by {|event| User.current.time_to_date(event.event_datetime)} -=end boards = @project.boards.includes(:last_message => :author).all @topic_count = @project.boards.count # 根据对应的请求,返回对应的数据 diff --git a/app/views/projects/_project_activities.html.erb b/app/views/projects/_project_activities.html.erb index 7e0832257..c694393f3 100644 --- a/app/views/projects/_project_activities.html.erb +++ b/app/views/projects/_project_activities.html.erb @@ -78,7 +78,7 @@ <% end %> <% when "Attachment" %> - <%= render :partial => 'users/course_attachment', :locals => {:activity => activity.forge_act, :user_activity_id => activity.id } %> + <%= render :partial => 'users/project_attachment', :locals => {:activity => activity.forge_act, :user_activity_id => activity.id } %> diff --git a/app/views/users/_project_attachment.html.erb b/app/views/users/_project_attachment.html.erb index b98356c7b..deb0cb4c6 100644 --- a/app/views/users/_project_attachment.html.erb +++ b/app/views/users/_project_attachment.html.erb @@ -1,18 +1,32 @@ + +
-
+
- 用户头像
+ <%= link_to image_tag(url_to_avatar(activity.author), :width => "50", :height => "50"), user_path(activity.author_id), :alt => "用户头像" %> + <%= render :partial => 'users/show_detail_info', :locals => {:user => activity.author} %> +
- - -
- -
截止时间:2015-08-20
+
+ <% if activity.try(:author).try(:realname) == ' ' %> + <%= link_to activity.try(:author), user_path(activity.author_id), :class => "newsBlue mr15" %> + <% else %> + <%= link_to activity.try(:author).try(:realname), user_path(activity.author_id), :class => "newsBlue mr15" %> + <% end %> + TO + <%= link_to activity.project.name.to_s+" | 项目资源", project_files_path(activity.course), :class => "newsBlue ml15" %>
-
(作业描述)系统中有多个ckeditor,且每个ckeditor的id未知,怎么样做到当光标聚焦某个ckeditor的文本框中,该编辑器的默认值应自动消失的处理;网络拓扑图开发;
-