Class: Pulitzer::PostTypesController
Defined Under Namespace
Classes: CreateSingletonPost, CreateTemplateVersion, Export, Import, ImportVersion
Instance Method Summary
collapse
Instance Method Details
#create ⇒ Object
25
26
27
28
29
|
# File 'app/controllers/pulitzer/post_types_controller.rb', line 25
def create
@post_type = Pulitzer::PostType.create(post_type_params)
CreateTemplateVersion.new(@post_type).call
render partial: 'show_wrapper', locals: {post_type: @post_type}
end
|
#destroy ⇒ Object
66
67
68
69
|
# File 'app/controllers/pulitzer/post_types_controller.rb', line 66
def destroy
@post_type.destroy
head :ok and return
end
|
#edit ⇒ Object
56
57
58
|
# File 'app/controllers/pulitzer/post_types_controller.rb', line 56
def edit
render partial: 'form', locals: {post_type: @post_type}
end
|
#export ⇒ Object
35
36
37
38
39
40
|
# File 'app/controllers/pulitzer/post_types_controller.rb', line 35
def export
post_type_json = Export.new(@post_type).call
send_data(post_type_json,
disposition: 'attachment',
filename: @post_type.name.parameterize + '.json')
end
|
#import ⇒ Object
42
43
44
45
|
# File 'app/controllers/pulitzer/post_types_controller.rb', line 42
def import
@post_type = Import.new(params).call
render partial: 'show_wrapper', locals: {post_type: @post_type}
end
|
#import_version ⇒ Object
47
48
49
50
51
52
53
54
|
# File 'app/controllers/pulitzer/post_types_controller.rb', line 47
def import_version
@post_type_version = ImportVersion.new(@post_type, post_type_params).call
if @post_type_version.errors.empty?
render partial: '/pulitzer/post_type_versions/show_wrapper', locals: {post_type_version: @post_type_version}
else
render json: {flash_message: "Error importing: #{@post_type_version.errors.full_messages}"}, status: 409
end
end
|
#index ⇒ Object
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
# File 'app/controllers/pulitzer/post_types_controller.rb', line 4
def index
if params[:post_type_kind]
@post_type_kind = params[:post_type_kind]
else
@post_type_kind = 'template'
end
if request.xhr?
if Pulitzer.skip_metadata_auth? || self.instance_eval(&Pulitzer.metadata_closure)
@post_types = Pulitzer::PostType.send(@post_type_kind).order(name: :asc)
else
@post_types = Pulitzer::PostType.send(@post_type_kind).joins(:post_type_versions).where(pulitzer_post_type_versions: {status: 'published'}).distinct.order(name: :asc)
end
render_ajax
end
end
|
#new ⇒ Object
20
21
22
23
|
# File 'app/controllers/pulitzer/post_types_controller.rb', line 20
def new
@post_type = Pulitzer::PostType.new(post_type_params)
render partial: 'new', locals: {post_type: @post_type}
end
|
#show ⇒ Object
31
32
33
|
# File 'app/controllers/pulitzer/post_types_controller.rb', line 31
def show
render partial: 'show', locals: {post_type: @post_type}
end
|
#update ⇒ Object
60
61
62
63
64
|
# File 'app/controllers/pulitzer/post_types_controller.rb', line 60
def update
@post_type.update_attributes(post_type_params)
Pulitzer::UpdateSingletonPost.new(@post_type, post_params_name).call
render partial: 'show', locals: {post_type: @post_type}
end
|