Class: Admin::Atreides::PostsController

Inherits:
Atreides::AdminController
  • Object
show all
Includes:
Atreides::Extendable
Defined in:
app/controllers/admin/atreides/posts_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



34
35
36
37
38
39
40
41
# File 'app/controllers/admin/atreides/posts_controller.rb', line 34

def create
  resource.author = current_user
  resource.last_editor = current_user
  super do |success, failure|
    success.html { redirect_to admin_posts_path }
    failure.html { render :template => "admin/atreides/posts/edit" }
  end
end

#destroyObject



61
62
63
64
65
# File 'app/controllers/admin/atreides/posts_controller.rb', line 61

def destroy
  super do |wants|
    wants.html { redirect_to admin_posts_path }
  end
end

#editObject



28
29
30
31
32
# File 'app/controllers/admin/atreides/posts_controller.rb', line 28

def edit
  super do |wants|
    wants.html { render :template => "admin/atreides/posts/edit" }
  end
end

#indexObject



4
5
6
7
8
9
10
# File 'app/controllers/admin/atreides/posts_controller.rb', line 4

def index
  show_as_dash
  super do |wants|
    wants.html { render :template => "admin/atreides/posts/index" }
    wants.js
  end
end

#newObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'app/controllers/admin/atreides/posts_controller.rb', line 12

def new
  # In case we refer with additional types requested
  if params.key?(:add_content)
    params[:add_content].each do |type|
      if Atreides::ContentPart.content_types.include?(type)
        resource.parts.build(:content_type => type)
      end
    end
  end

  if Atreides::ContentPart.content_types.include?(params[:type])
    resource.parts.build(:content_type => params[:type])
  end
  super
end

#showObject



55
56
57
58
59
# File 'app/controllers/admin/atreides/posts_controller.rb', line 55

def show
  super do |wants|
    wants.html { redirect_to edit_admin_post_path resource }
  end
end

#updateObject



43
44
45
46
47
48
49
50
51
52
53
# File 'app/controllers/admin/atreides/posts_controller.rb', line 43

def update
  resource.last_editor = current_user
  super do |success, failure|
    success.html {
      if params[:post] and params[:post][:state] == "publish_now"
        flash[:notice] += " <b>Your post is now live!</b>"
      end
      redirect_to admin_posts_path
    }
  end
end