Project

General

Profile

Feature #1605 » activity-store-user-selection-v2.diff

Added property methods for "activity_scope" to UserPreference model - Go MAEDA, 2015-10-06 05:20

View differences:

app/controllers/activities_controller.rb (working copy)
37 37
    @activity = Redmine::Activity::Fetcher.new(User.current, :project => @project,
38 38
                                                             :with_subprojects => @with_subprojects,
39 39
                                                             :author => @author)
40
    pref = User.current.pref
40 41
    @activity.scope_select {|t| !params["show_#{t}"].nil?}
41
    @activity.scope = (@author.nil? ? :default : :all) if @activity.scope.empty?
42
    if @activity.scope.present?
43
      pref.activity_scope = @activity.scope
44
      pref.save
45
    else
46
      if @author.nil?
47
        scope = pref.activity_scope & @activity.event_types
48
        @activity.scope = scope.present? ? scope : :default
49
      else
50
        @activity.scope = :all
51
      end
52
    end
42 53

  
43 54
    events = @activity.events(@date_from, @date_to)
44 55

  
app/models/user_preference.rb (working copy)
59 59

  
60 60
  def no_self_notified; (self[:no_self_notified] == true || self[:no_self_notified] == '1'); end
61 61
  def no_self_notified=(value); self[:no_self_notified]=value; end
62

  
63
  def activity_scope; self[:activity_scope].to_a ; end
64
  def activity_scope=(value); self[:activity_scope]=value ; end
62 65
end
(2-2/2)