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



50
51
52
53
# File 'app/controllers/georgia/revisions_controller.rb', line 50

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

#declineObject



55
56
57
58
# File 'app/controllers/georgia/revisions_controller.rb', line 55

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

#destroyObject



33
34
35
36
# File 'app/controllers/georgia/revisions_controller.rb', line 33

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

#editObject



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

def edit
  locale = params.fetch(:locale, current_locale)
  @slides = @revision.slides.ordered.with_locale(locale)
  @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



40
41
42
# File 'app/controllers/georgia/revisions_controller.rb', line 40

def preview
  redirect_to preview_url
end

#restoreObject



60
61
62
63
# File 'app/controllers/georgia/revisions_controller.rb', line 60

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

#reviewObject



44
45
46
47
48
# File 'app/controllers/georgia/revisions_controller.rb', line 44

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



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

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