Module: OpenProject::AutoProject::Patches::UserPatch::InstanceMethods

Defined in:
lib/open_project/auto_project/patches/user_patch.rb

Instance Method Summary collapse

Instance Method Details

#build_user_projectObject



31
32
33
34
35
36
# File 'lib/open_project/auto_project/patches/user_patch.rb', line 31

def build_user_project
  return unless @was_activated

  user_project = Project.create :identifier => user_project_identifier, :name => name, :is_public => false
  memberships.create :project => user_project, :roles => [user_project_role]
end

#remember_if_activatedObject



19
20
21
22
23
24
25
26
27
28
29
# File 'lib/open_project/auto_project/patches/user_patch.rb', line 19

def remember_if_activated
  @was_activated = false
  # Return unless user was registered, is now active
  # Or the user is created and activated immediately
  return unless ((self.status_change == [User::STATUSES[:registered], User::STATUSES[:active]] ) ||
    (self.new_record? && self.status == User::STATUSES[:active]))

  # Or the project exists already
  return if Project.find_by_identifier user_project_identifier
  @was_activated = true
end