diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb index 2f33ab554..d87992ec8 100644 --- a/app/controllers/files_controller.rb +++ b/app/controllers/files_controller.rb @@ -201,6 +201,7 @@ class FilesController < ApplicationController def quote_resource_show @file = Attachment.find(params[:id]) + @can_quote = attachment_candown @file end def new diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 56777fd22..e6ab0f431 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -433,16 +433,16 @@ class UsersController < ApplicationController else activity = Activity.where(where_condition).where('user_id = ?', @user.id).order('id desc') end - activity = activity.reject { |e| - ((e.act_type=="Issue") && ( !e.act.visible?(User.current))) || - ((e.act_type == "Journal") && (!e.act.project.visible?(User.current))) || - ((e.act_type == "Bid") && (e.act.courses.first && - (!e.act.homework_for_courses.first.course.visible?(User.current) || - !User.current.member_of_course?(e.act.homework_for_courses.first.course) || !User.current.admin?))) - } + @activity_count = activity.count @activity_pages = Paginator.new @activity_count, pre_count, params['page'] - @activity = activity.slice(@activity_pages.offset,@activity_pages.per_page) + activity_page = activity.slice(@activity_pages.offset,@activity_pages.per_page * 2) + activity_page = activity_page.reject { |e| + ((e.act_type=="Issue") && ( !e.act.visible?(User.current))) || + ((e.act_type == "Journal") && (!e.act.project.visible?(User.current))) || + ((e.act_type == "Bid") && ((!User.current.member_of_course?(e.act.courses.first) || !User.current.admin?))) + } + @activity = activity.slice(0,@activity_pages.per_page) @state = 0 end diff --git a/app/helpers/issues_helper.rb b/app/helpers/issues_helper.rb index dfa485a70..8390fc61c 100644 --- a/app/helpers/issues_helper.rb +++ b/app/helpers/issues_helper.rb @@ -227,7 +227,7 @@ module IssuesHelper strings = [] values_by_field = {} details.each do |detail| - unless detail.property == 'attachment' + if detail.property == 'cf' field_id = detail.prop_key field = CustomField.find_by_id(field_id) @@ -243,7 +243,7 @@ module IssuesHelper end end strings << show_detail(detail, no_html, options) - end + end values_by_field.each do |field_id, changes| detail = JournalDetail.new(:property => 'cf', :prop_key => field_id) diff --git a/app/models/issue.rb b/app/models/issue.rb index 09e093177..4dc685b3b 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -51,7 +51,7 @@ class Issue < ActiveRecord::Base acts_as_nested_set :scope => 'root_id', :dependent => :destroy - acts_as_attachable :after_add => :attachment_added, :after_remove => :attachment_removed + acts_as_attachable :before_add => :attachment_added, :after_remove => :attachment_removed acts_as_customizable acts_as_watchable acts_as_searchable :columns => ['subject', "#{table_name}.description", "#{Journal.table_name}.notes"], @@ -1359,7 +1359,7 @@ class Issue < ActiveRecord::Base # Callback on file attachment def attachment_added(obj) - if @current_journal && !obj.new_record? && @current_journal.journalized_id == obj.author_id + if @current_journal && @current_journal.user_id == obj.author_id && JournalDetail.find_all_by_value(obj.filename).count == 0 @current_journal.details << JournalDetail.new(:property => 'attachment', :prop_key => obj.id, :value => obj.filename) end end diff --git a/app/views/courses/_groups_name.html.erb b/app/views/courses/_groups_name.html.erb index e1b138666..1fe02dfeb 100644 --- a/app/views/courses/_groups_name.html.erb +++ b/app/views/courses/_groups_name.html.erb @@ -1,17 +1,19 @@ - - +