Class: Story

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::MassAssignmentSecurity, Model::MongoDb::Commentable, Model::MongoDb::Customizable, Mongoid::Document, Mongoid::Slug, Mongoid::Timestamps, StateMachines::Story
Defined in:
app/models/story.rb

Constant Summary collapse

PARENT_TYPES =
['project']

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Model::MongoDb::Commentable

#comments

Instance Attribute Details

#tasks_fileObject

Returns the value of attribute tasks_file.



31
32
33
# File 'app/models/story.rb', line 31

def tasks_file
  @tasks_file
end

Class Method Details

.for_user(user) ⇒ Object

Raises:

  • (NotImplementedError)


46
47
48
# File 'app/models/story.rb', line 46

def self.for_user(user)
  raise NotImplementedError
end

Instance Method Details

#after_creation_pathObject



80
81
82
# File 'app/models/story.rb', line 80

def after_creation_path
  Rails.application.routes.url_helpers.edit_story_path self
end

#custom_tasksObject



84
85
86
# File 'app/models/story.rb', line 84

def custom_tasks
  tasks
end

#next_task_for_user(user) ⇒ Object



57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'app/models/story.rb', line 57

def next_task_for_user(user)
  return nil if (users_without_tasks_ids || []).include?(user.id)
  
  task = tasks.assigned.not.in(state: ['under_supervision', 'completed']).
         where(user_id: user.id).first
  
  return task if task
  
  task = tasks.current.unassigned.where(:unassigned_user_ids.ne => user.id).first
  
  if task
    task.user_id = user.id
  
    raise task.errors.full_messages.join('<br/>') unless task.assign
  else
    self.users_without_tasks_ids ||= []
    self.users_without_tasks_ids << user.id
    save
  end
  
  task
end

#offerorObject

belongs_to (SQL)



51
# File 'app/models/story.rb', line 51

def offeror; offeror_id ? User.find(offeror_id) : nil; end

#offeror=(value) ⇒ Object



52
# File 'app/models/story.rb', line 52

def offeror=(value); self.offeror_id = value.id; end

#projectObject



54
# File 'app/models/story.rb', line 54

def project; project_id ? Project.find(project_id) : nil; end

#project=(value) ⇒ Object



55
# File 'app/models/story.rb', line 55

def project=(value); @project = value; self.project_id = value.id; end