Class: Georgia::RevisionsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/georgia/revisions_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#current_ability, #current_locale

Instance Method Details

#approveObject



48
49
50
51
# File 'app/controllers/georgia/revisions_controller.rb', line 48

def approve
  @revision.approve
  redirect_to @page, notice: "#{current_user.name} has successfully approved and published #{@revision.title}."
end

#declineObject



53
54
55
56
# File 'app/controllers/georgia/revisions_controller.rb', line 53

def decline
  @revision.decline
  redirect_to [:edit, @page, @revision], notice: "#{current_user.name} has successfully published #{@revision.title}."
end

#destroyObject



31
32
33
34
# File 'app/controllers/georgia/revisions_controller.rb', line 31

def destroy
  @revision.destroy
  redirect_to page_revisions_path(@page), notice: "#{@revision.title or 'Revision'} was successfully deleted."
end

#editObject



18
19
20
# File 'app/controllers/georgia/revisions_controller.rb', line 18

def edit
  @ui_sections = Georgia::UiSection.all
end

#indexObject



10
11
12
# File 'app/controllers/georgia/revisions_controller.rb', line 10

def index
  @revisions = @page.revisions.order('created_at DESC').reject{|r| r == @page.current_revision}
end

#previewObject

Sends revision to main_app router FIXME: bypass this once Georgia will be loaded on root



38
39
40
# File 'app/controllers/georgia/revisions_controller.rb', line 38

def preview
  redirect_to main_app.preview_page_path(id: @page.id, revision_id: @revision.id)
end

#restoreObject



58
59
60
61
# File 'app/controllers/georgia/revisions_controller.rb', line 58

def restore
  @revision.restore
  redirect_to @page, notice: "#{current_user.name} has successfully published #{@revision.title}."
end

#reviewObject



42
43
44
45
46
# File 'app/controllers/georgia/revisions_controller.rb', line 42

def review
  @revision.review
  notify("#{current_user.name} is asking you to review #{@revision.title}.", edit_page_revision_path(@page, @revision, only_path: false))
  redirect_to [:edit, @page, @revision], notice: "You successfully submited #{@revision.title} for review."
end

#showObject



14
15
16
# File 'app/controllers/georgia/revisions_controller.rb', line 14

def show
  redirect_to [:edit, @page, @revision]
end

#updateObject

Stores a copy of the current revision before updating



23
24
25
26
27
28
29
# File 'app/controllers/georgia/revisions_controller.rb', line 23

def update
  if RevisionPolicy.update(self, @page, @revision, params[:revision])
    redirect_to [:edit, @page, @revision], notice: "#{@revision.title} was successfully updated."
  else
    redirect_to [:edit, @page, @revision], alert: @revision.errors.full_messages.join('. ')
  end
end