Class: Plugins::ContactForm::AdminFormsController
- Inherits:
-
CamaleonCms::Apps::PluginsAdminController
- Object
- CamaleonCms::Apps::PluginsAdminController
- Plugins::ContactForm::AdminFormsController
- Defined in:
- app/apps/plugins/contact_form/admin_forms_controller.rb
Overview
Camaleon CMS is a content management system
Copyright (C) 2015 by Owen Peredo Diaz
Email: [email protected]
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU Affero General Public License (GPLv3) for more details.
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #manual ⇒ Object
- #responses ⇒ Object
- #update ⇒ Object
Instance Method Details
#create ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'app/apps/plugins/contact_form/admin_forms_controller.rb', line 39 def create params[:plugins_contact_form_models_contact_form][:value] = {"fields" => []}.to_json params[:plugins_contact_form_models_contact_form][:settings] = {}.to_json data_form = params[:plugins_contact_form_models_contact_form] @form = current_site.contact_forms.new(data_form) if @form.save flash[:notice] = "#{t('plugin.contact_form.message.save')}" redirect_to action: :edit, id: @form.id else flash[:error] = @form.errors..join(', ') redirect_to action: :index end end |
#destroy ⇒ Object
56 57 58 59 60 |
# File 'app/apps/plugins/contact_form/admin_forms_controller.rb', line 56 def destroy flash[:notice] = "#{t('plugin.contact_form.message.delete')}" if @form.destroy redirect_to action: :index end |
#edit ⇒ Object
19 20 21 22 23 |
# File 'app/apps/plugins/contact_form/admin_forms_controller.rb', line 19 def edit I18n.t("camaleon_cms.admin.button.edit") append_asset_libraries({"plugin_contact_form"=> { js: [plugin_asset_path("js/contact_form.js")], css: [plugin_asset_path("css/contact-form.css")] }}) render "edit" end |
#index ⇒ Object
13 14 15 16 17 |
# File 'app/apps/plugins/contact_form/admin_forms_controller.rb', line 13 def index # here your actions for admin panel @forms = current_site.contact_forms.where("parent_id is null").all @forms = @forms.paginate(:page => params[:page], :per_page => current_site.admin_per_page) end |
#manual ⇒ Object
71 72 73 |
# File 'app/apps/plugins/contact_form/admin_forms_controller.rb', line 71 def manual end |
#responses ⇒ Object
62 63 64 65 66 67 68 69 |
# File 'app/apps/plugins/contact_form/admin_forms_controller.rb', line 62 def responses @form = current_site.contact_forms.where({id: params[:admin_form_id]}).first values = JSON.parse(@form.value).to_sym @op_fields = values[:fields] @forms = current_site.contact_forms.where({parent_id: @form.id}) @forms = @forms.paginate(:page => params[:page], :per_page => current_site.admin_per_page) end |
#update ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'app/apps/plugins/contact_form/admin_forms_controller.rb', line 25 def update if @form.update(params[:plugins_contact_form_models_contact_form]) settings = {"railscf_mail" => params[:railscf_mail], "railscf_message" => params[:railscf_message], "railscf_form_button" => params[:railscf_form_button]}.to_json current_site.contact_forms.where(id: @form.id).update_or_create({settings: (settings)}) current_site.contact_forms.where(id: @form.id).update_or_create({value: params[:meta]}) flash[:notice] = t('camaleon_cms.admin.message.updated_success') redirect_to action: :edit, id: @form.id else edit end end |