Class: PivotalReporter::StoriesController

Inherits:
ApplicationController show all
Defined in:
app/controllers/pivotal_reporter/stories_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#pivotal_project, #pivotal_unique_label

Instance Method Details

#acceptObject



29
30
31
32
33
34
# File 'app/controllers/pivotal_reporter/stories_controller.rb', line 29

def accept
  @story = pivotal_project.stories.find(params[:id])
  @story.update({current_state: 'accepted'})

  redirect_to stories_path
end

#createObject



17
18
19
20
21
22
23
24
25
26
27
# File 'app/controllers/pivotal_reporter/stories_controller.rb', line 17

def create
  story = PivotalTracker::Story.new(params[:story]).create

  if story.errors.count > 0
    flash[:error] = "Report Submission Failed: #{story.errors}"
  else
    flash[:success] = 'Report Submitted!'
  end

  redirect_to new_story_path
end

#indexObject



5
6
7
# File 'app/controllers/pivotal_reporter/stories_controller.rb', line 5

def index
  @stories = pivotal_project.stories.all(label: pivotal_unique_label)
end

#newObject



13
14
15
# File 'app/controllers/pivotal_reporter/stories_controller.rb', line 13

def new
  @pivotal_unique_label = pivotal_unique_label
end

#rejectObject



36
37
38
39
40
41
42
# File 'app/controllers/pivotal_reporter/stories_controller.rb', line 36

def reject
  @story = pivotal_project.stories.find(params[:id])
  @story.update({current_state: 'rejected'})
  @story.notes.create(:text => URI.decode(params[:reject_message]))

  redirect_to stories_path
end

#showObject



9
10
11
# File 'app/controllers/pivotal_reporter/stories_controller.rb', line 9

def show
  @story = pivotal_project.stories.find(params[:id])
end