cd2_catton_cms 1.1.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Rakefile +37 -0
- data/app/assets/config/c_manifest.js +2 -0
- data/app/assets/images/c/drag_handle.gif +0 -0
- data/app/assets/images/c/login_background.jpg +0 -0
- data/app/assets/images/c/main_application/hero.jpg +0 -0
- data/app/assets/images/c/main_application/search.png +0 -0
- data/app/assets/images/c/placeholder_product_image.png +0 -0
- data/app/assets/images/c/select_arrow_down_blk.png +0 -0
- data/app/assets/images/c/small_icon.png +0 -0
- data/app/assets/images/c/vendor/chosen-sprite.png +0 -0
- data/app/assets/javascripts/c/application.js +59 -0
- data/app/assets/javascripts/c/change_tag.js +49 -0
- data/app/assets/javascripts/c/chosen.js +2 -0
- data/app/assets/javascripts/c/confirm_delete.js +55 -0
- data/app/assets/javascripts/c/draggable_tree.js +223 -0
- data/app/assets/javascripts/c/dropzone_init.js +98 -0
- data/app/assets/javascripts/c/fake_table.js +87 -0
- data/app/assets/javascripts/c/master_form2/collection.js +180 -0
- data/app/assets/javascripts/c/master_form2/eu_cookie.js +1 -0
- data/app/assets/javascripts/c/master_form2/jrecord.js +116 -0
- data/app/assets/javascripts/c/master_form2/master_form.coffee +4 -0
- data/app/assets/javascripts/c/split_buttons.js.erb +15 -0
- data/app/assets/javascripts/c/things_to_be_done.js +138 -0
- data/app/assets/javascripts/c/unloadevent.js +35 -0
- data/app/assets/stylesheets/c/_core.sass +237 -0
- data/app/assets/stylesheets/c/_engine.sass +4 -0
- data/app/assets/stylesheets/c/_variables.sass +32 -0
- data/app/assets/stylesheets/c/_vendor.sass +6 -0
- data/app/assets/stylesheets/c/application/checkout/_cart.sass +85 -0
- data/app/assets/stylesheets/c/application/checkout/_checkout.sass +87 -0
- data/app/assets/stylesheets/c/application/elements/buttons.sass +34 -0
- data/app/assets/stylesheets/c/application/elements/forms.sass +135 -0
- data/app/assets/stylesheets/c/application/elements/shadows.sass +23 -0
- data/app/assets/stylesheets/c/application/partials/_breadcrumbs.sass +10 -0
- data/app/assets/stylesheets/c/application/partials/_categories_sidebars/_1.sass +53 -0
- data/app/assets/stylesheets/c/application/partials/_categories_sidebars/_2.sass +77 -0
- data/app/assets/stylesheets/c/application/partials/_footer.sass +43 -0
- data/app/assets/stylesheets/c/application/partials/_header.sass +317 -0
- data/app/assets/stylesheets/c/engine/_draggable_trees.sass +68 -0
- data/app/assets/stylesheets/c/engine/_form_pages.sass +153 -0
- data/app/assets/stylesheets/c/engine/_header_bar.sass +29 -0
- data/app/assets/stylesheets/c/engine/_index_header.sass +17 -0
- data/app/assets/stylesheets/c/engine/_layout.sass +15 -0
- data/app/assets/stylesheets/c/engine/_login.sass +38 -0
- data/app/assets/stylesheets/c/engine/_navbar.sass +19 -0
- data/app/assets/stylesheets/c/engine/_pagination.sass +16 -0
- data/app/assets/stylesheets/c/engine/_settings.sass +5 -0
- data/app/assets/stylesheets/c/engine/_sidebar.sass +20 -0
- data/app/assets/stylesheets/c/engine/_tables.sass +76 -0
- data/app/assets/stylesheets/c/engine/flash_messages.sass +2 -0
- data/app/assets/stylesheets/c/print_application.sass +167 -0
- data/app/assets/stylesheets/c/vendor/_flex_mixins.scss +394 -0
- data/app/assets/stylesheets/c/vendor/_normalize.sass +340 -0
- data/app/controllers/c/admin/blogs_controller.rb +57 -0
- data/app/controllers/c/admin/devise/passwords_controller.rb +5 -0
- data/app/controllers/c/admin/devise/sessions_controller.rb +5 -0
- data/app/controllers/c/admin/documents_controller.rb +50 -0
- data/app/controllers/c/admin/enquiries_controller.rb +22 -0
- data/app/controllers/c/admin/images_controller.rb +21 -0
- data/app/controllers/c/admin/locations_controller.rb +63 -0
- data/app/controllers/c/admin/menu_items_controller.rb +49 -0
- data/app/controllers/c/admin/pages_controller.rb +94 -0
- data/app/controllers/c/admin/projects_controller.rb +55 -0
- data/app/controllers/c/admin/redirects_controller.rb +55 -0
- data/app/controllers/c/admin/roles_controller.rb +49 -0
- data/app/controllers/c/admin/slides_controller.rb +50 -0
- data/app/controllers/c/admin/slideshows_controller.rb +34 -0
- data/app/controllers/c/admin/team_members_controller.rb +61 -0
- data/app/controllers/c/admin/testimonials_controller.rb +43 -0
- data/app/controllers/c/admin/users_controller.rb +51 -0
- data/app/controllers/c/admin_controller.rb +43 -0
- data/app/controllers/c/application_controller.rb +15 -0
- data/app/controllers/c/errors_controller.rb +12 -0
- data/app/controllers/c/front/devise/passwords_controller.rb +6 -0
- data/app/controllers/c/front/devise/registrations_controller.rb +32 -0
- data/app/controllers/c/front/devise/sessions_controller.rb +27 -0
- data/app/controllers/c/front/mailchimp_controller.rb +32 -0
- data/app/controllers/c/front_controller.rb +7 -0
- data/app/controllers/c/front_end/blogs_controller.rb +21 -0
- data/app/controllers/c/front_end/enquiries_controller.rb +32 -0
- data/app/controllers/c/front_end/pages_controller.rb +19 -0
- data/app/controllers/c/main_application_controller.rb +22 -0
- data/app/helpers/c/application_helper.rb +51 -0
- data/app/helpers/c/blogs_helper.rb +113 -0
- data/app/helpers/c/c_form_builder.rb +43 -0
- data/app/helpers/c/link_to_helper.rb +25 -0
- data/app/helpers/c/navigation_helper.rb +28 -0
- data/app/helpers/c/pages_helper.rb +27 -0
- data/app/helpers/c/storefront_helper.rb +63 -0
- data/app/mailers/c/application_mailer.rb +7 -0
- data/app/mailers/c/enquiries_mailer.rb +10 -0
- data/app/models/c/ability.rb +21 -0
- data/app/models/c/application_record.rb +6 -0
- data/app/models/c/author_record.rb +13 -0
- data/app/models/c/blog.rb +43 -0
- data/app/models/c/document.rb +17 -0
- data/app/models/c/enquiry.rb +95 -0
- data/app/models/c/image.rb +11 -0
- data/app/models/c/location.rb +18 -0
- data/app/models/c/menu_item.rb +35 -0
- data/app/models/c/non_delete.rb +10 -0
- data/app/models/c/page.rb +48 -0
- data/app/models/c/page_info.rb +16 -0
- data/app/models/c/permission.rb +9 -0
- data/app/models/c/permission_subject.rb +12 -0
- data/app/models/c/project.rb +20 -0
- data/app/models/c/redirect.rb +33 -0
- data/app/models/c/role.rb +18 -0
- data/app/models/c/slide.rb +16 -0
- data/app/models/c/slideshow.rb +23 -0
- data/app/models/c/team_member.rb +33 -0
- data/app/models/c/testimonial.rb +42 -0
- data/app/models/c/user.rb +42 -0
- data/app/models/c/user_role.rb +7 -0
- data/app/models/c/weight.rb +10 -0
- data/app/models/concerns/c/authorable.rb +18 -0
- data/app/models/concerns/c/documentable.rb +18 -0
- data/app/models/concerns/c/imageable.rb +49 -0
- data/app/models/concerns/c/non_deletable.rb +30 -0
- data/app/models/concerns/c/orderable.rb +30 -0
- data/app/models/concerns/c/previewable.rb +20 -0
- data/app/models/concerns/c/site_page.rb +89 -0
- data/app/uploaders/c/file_uploader.rb +9 -0
- data/app/uploaders/c/image_uploader.rb +39 -0
- data/app/views/c/admin/_background_jobs_dropdown.html.haml +18 -0
- data/app/views/c/admin/_bread_crumbs.html.haml +7 -0
- data/app/views/c/admin/_ebay_categories.html.haml +20 -0
- data/app/views/c/admin/_flash_messages.html.haml +5 -0
- data/app/views/c/admin/_header_bar.html.haml +18 -0
- data/app/views/c/admin/_index_table.html.haml +113 -0
- data/app/views/c/admin/_index_table_data.html.haml +17 -0
- data/app/views/c/admin/_navigation_bar.html.haml +1 -0
- data/app/views/c/admin/_preview_image.html.haml +2 -0
- data/app/views/c/admin/_preview_upload.html.haml +18 -0
- data/app/views/c/admin/_seo.html.haml +11 -0
- data/app/views/c/admin/_side_menu.html.haml +26 -0
- data/app/views/c/admin/_uploaded_images_new.html.haml +13 -0
- data/app/views/c/admin/blogs/_form.html.haml +58 -0
- data/app/views/c/admin/blogs/index.html.haml +9 -0
- data/app/views/c/admin/confirm_destroy.html.haml +6 -0
- data/app/views/c/admin/confirm_mass_destroy.html.haml +10 -0
- data/app/views/c/admin/documents/_form.html.haml +8 -0
- data/app/views/c/admin/documents/index.html.haml +9 -0
- data/app/views/c/admin/edit.html.haml +15 -0
- data/app/views/c/admin/enquiries/index.html.haml +14 -0
- data/app/views/c/admin/locations/_form.html.haml +58 -0
- data/app/views/c/admin/locations/index.html.haml +9 -0
- data/app/views/c/admin/menu_items/_form.html.haml +44 -0
- data/app/views/c/admin/menu_items/_menu_item_list_item.html.haml +10 -0
- data/app/views/c/admin/menu_items/index.html.haml +10 -0
- data/app/views/c/admin/new.html.haml +8 -0
- data/app/views/c/admin/pages/_form.html.haml +93 -0
- data/app/views/c/admin/pages/_page_list_item.html.haml +10 -0
- data/app/views/c/admin/pages/dashboard.html.erb +0 -0
- data/app/views/c/admin/pages/index.html.haml +11 -0
- data/app/views/c/admin/projects/_form.html.haml +46 -0
- data/app/views/c/admin/projects/index.html.haml +9 -0
- data/app/views/c/admin/quick_edit.js.erb +6 -0
- data/app/views/c/admin/redirects/_form.html.haml +14 -0
- data/app/views/c/admin/redirects/index.html.haml +9 -0
- data/app/views/c/admin/reload_images.js.erb +2 -0
- data/app/views/c/admin/roles/_form.html.haml +42 -0
- data/app/views/c/admin/roles/index.html.haml +17 -0
- data/app/views/c/admin/set_preview_image.js.erb +1 -0
- data/app/views/c/admin/show.html.haml +1 -0
- data/app/views/c/admin/slides/_form.html.haml +19 -0
- data/app/views/c/admin/slideshows/_form.html.haml +25 -0
- data/app/views/c/admin/slideshows/index.html.haml +8 -0
- data/app/views/c/admin/team_members/_form.html.haml +20 -0
- data/app/views/c/admin/team_members/index.html.haml +10 -0
- data/app/views/c/admin/testimonials/_form.html.haml +13 -0
- data/app/views/c/admin/testimonials/index.html.haml +8 -0
- data/app/views/c/admin/users/_form.html.haml +17 -0
- data/app/views/c/admin/users/index.html.haml +12 -0
- data/app/views/c/enquiries_mailer/new_enquiry.html.haml +14 -0
- data/app/views/c/enquiries_mailer/new_enquiry.text.haml +9 -0
- data/app/views/c/errors/404.html.haml +5 -0
- data/app/views/c/errors/500.html.haml +5 -0
- data/app/views/c/front/application/_category_item.html.haml +2 -0
- data/app/views/c/front/application/_menu_item.html.haml +4 -0
- data/app/views/c/front/application/_sales_highlight.html.haml +1 -0
- data/app/views/c/front/application/_slide.html.haml +6 -0
- data/app/views/c/front/blogs/_archive_filter_month.html.haml +2 -0
- data/app/views/c/front/blogs/_archive_filter_year.html.haml +1 -0
- data/app/views/c/front/blogs/_menu_item.html.haml +2 -0
- data/app/views/c/front_end/enquiries/new.html.haml +23 -0
- data/app/views/c/front_end/enquiries/thanks.html.haml +5 -0
- data/app/views/c/front_end/pages/_sales_highlight.html.haml +7 -0
- data/app/views/c/front_end/pages/about.html.haml +8 -0
- data/app/views/c/front_end/pages/home.html.haml +19 -0
- data/app/views/c/front_end/pages/search.html.haml +16 -0
- data/app/views/c/front_end/pages/show.html.haml +7 -0
- data/app/views/c/front_end/pages/sitemap.xml.builder +25 -0
- data/app/views/c/mailchimp/_signup_newsletter.html.haml +4 -0
- data/app/views/c/main_application/_application_bar.html.haml +22 -0
- data/app/views/c/main_application/_breadcrumbs.html.haml +7 -0
- data/app/views/c/main_application/_contact_info.html.haml +5 -0
- data/app/views/c/main_application/_footer.html.haml +49 -0
- data/app/views/c/main_application/_front_head_tags.html.haml +3 -0
- data/app/views/c/main_application/_header.html.haml +55 -0
- data/app/views/c/main_application/_site_search.html.haml +3 -0
- data/app/views/c/main_application/_yield.html.haml +5 -0
- data/app/views/devise/confirmations/new.html.erb +16 -0
- data/app/views/devise/mailer/confirmation_instructions.html.erb +5 -0
- data/app/views/devise/mailer/password_change.html.erb +3 -0
- data/app/views/devise/mailer/reset_password_instructions.html.erb +8 -0
- data/app/views/devise/mailer/unlock_instructions.html.erb +7 -0
- data/app/views/devise/passwords/edit.html.haml +26 -0
- data/app/views/devise/passwords/new.html.haml +14 -0
- data/app/views/devise/registrations/edit.html.haml +40 -0
- data/app/views/devise/registrations/new.html.haml +24 -0
- data/app/views/devise/sessions/new.html.haml +20 -0
- data/app/views/devise/shared/_links.html.erb +25 -0
- data/app/views/devise/unlocks/new.html.erb +16 -0
- data/app/views/layouts/c/application.html.haml +18 -0
- data/app/views/layouts/c/cms_login_layout.html.haml +18 -0
- data/app/views/layouts/c/mailer.html.erb +245 -0
- data/app/views/layouts/c/mailer.text.erb +3 -0
- data/app/views/layouts/c/main_application.html.haml +13 -0
- data/config/environment.rb +0 -0
- data/config/initializers/carrierwave.rb +18 -0
- data/config/initializers/devise.rb +283 -0
- data/config/initializers/rack_profiler.rb +8 -0
- data/config/locales/devise.en.yml +62 -0
- data/config/locales/en.yml +17 -0
- data/config/routes.rb +150 -0
- data/db/migrate/20160819000000_migrate_schema.rb +273 -0
- data/db/seed_data/countries.txt +227 -0
- data/lib/c/engine.rb +38 -0
- data/lib/c/version.rb +4 -0
- data/lib/cd2_catton_cms.rb +51 -0
- data/lib/tasks/c_tasks.rake +28 -0
- data/spec/dummy/Gemfile +4 -0
- data/spec/dummy/Gemfile.lock +20 -0
- data/spec/dummy/Rakefile +6 -0
- data/spec/dummy/app/assets/config/manifest.js +5 -0
- data/spec/dummy/app/assets/images/placeholder.png +0 -0
- data/spec/dummy/app/assets/javascripts/application.js +26 -0
- data/spec/dummy/app/assets/javascripts/cable.js +13 -0
- data/spec/dummy/app/assets/javascripts/pages.coffee +3 -0
- data/spec/dummy/app/assets/stylesheets/application.sass +13 -0
- data/spec/dummy/app/assets/stylesheets/c/application.sass +2 -0
- data/spec/dummy/app/controllers/application_controller.rb +10 -0
- data/spec/dummy/app/controllers/blogs_controller.rb +11 -0
- data/spec/dummy/app/controllers/pages_controller.rb +13 -0
- data/spec/dummy/app/models/application_record.rb +4 -0
- data/spec/dummy/app/models/page.rb +3 -0
- data/spec/dummy/bin/bundle +4 -0
- data/spec/dummy/bin/rails +5 -0
- data/spec/dummy/bin/rake +5 -0
- data/spec/dummy/bin/setup +35 -0
- data/spec/dummy/bin/update +30 -0
- data/spec/dummy/config/application.rb +17 -0
- data/spec/dummy/config/boot.rb +6 -0
- data/spec/dummy/config/cable.yml +9 -0
- data/spec/dummy/config/database.travis.yml +3 -0
- data/spec/dummy/config/database.yml +85 -0
- data/spec/dummy/config/environment.rb +6 -0
- data/spec/dummy/config/environments/development.rb +61 -0
- data/spec/dummy/config/environments/production.rb +87 -0
- data/spec/dummy/config/environments/test.rb +43 -0
- data/spec/dummy/config/initializers/application_controller_renderer.rb +7 -0
- data/spec/dummy/config/initializers/assets.rb +21 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +8 -0
- data/spec/dummy/config/initializers/carrierwave.rb +15 -0
- data/spec/dummy/config/initializers/commercity.rb +4 -0
- data/spec/dummy/config/initializers/cookies_serializer.rb +6 -0
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +5 -0
- data/spec/dummy/config/initializers/inflections.rb +17 -0
- data/spec/dummy/config/initializers/mime_types.rb +5 -0
- data/spec/dummy/config/initializers/new_framework_defaults.rb +25 -0
- data/spec/dummy/config/initializers/session_store.rb +4 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +15 -0
- data/spec/dummy/config/locales/en.yml +23 -0
- data/spec/dummy/config/puma.rb +48 -0
- data/spec/dummy/config/routes.rb +4 -0
- data/spec/dummy/config/secrets.yml +22 -0
- data/spec/dummy/config/sidekiq.yml +6 -0
- data/spec/dummy/config/spring.rb +7 -0
- data/spec/dummy/config.ru +5 -0
- data/spec/dummy/db/schema.rb +1110 -0
- data/spec/dummy/lib/tasks/reprocess_images.rake +12 -0
- data/spec/dummy/lib/tasks/reset_all.rake +44 -0
- data/spec/dummy/lib/tasks/seeds/seed_blogs.rake +8 -0
- data/spec/dummy/lib/tasks/seeds/seed_pages.rake +24 -0
- data/spec/dummy/public/404.html +67 -0
- data/spec/dummy/public/422.html +67 -0
- data/spec/dummy/public/500.html +66 -0
- data/spec/dummy/public/apple-touch-icon-precomposed.png +0 -0
- data/spec/dummy/public/apple-touch-icon.png +0 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/seed/highlight1.png +0 -0
- data/spec/dummy/seed/highlight2.png +0 -0
- data/spec/dummy/seed/images/1/main.jpg +0 -0
- data/spec/dummy/seed/images/1/thumb.JPG +0 -0
- data/spec/dummy/seed/images/1/thumb2.jpg +0 -0
- data/spec/dummy/seed/images/2/main.jpeg +0 -0
- data/spec/dummy/seed/images/2/thumb.JPG +0 -0
- data/spec/dummy/seed/images/2/thumb2.JPG +0 -0
- data/spec/dummy/spec/models/redirect_spec.rb +57 -0
- data/spec/dummy/spec/support/factory_girl.rb +8 -0
- data/spec/dummy/spec/support/seed/images/product_image.png +0 -0
- data/spec/rails_helper.rb +49 -0
- data/spec/spec_helper.rb +52 -0
- metadata +734 -0
@@ -0,0 +1,55 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require_dependency 'c/admin_controller'
|
3
|
+
|
4
|
+
module C
|
5
|
+
class Admin::ProjectsController < AdminController
|
6
|
+
before_action :load_from_url, only: [:edit, :update, :destroy]
|
7
|
+
load_and_authorize_resource class: C::Project
|
8
|
+
|
9
|
+
def index
|
10
|
+
@projects = filter_and_paginate(@projects, 'created_at desc')
|
11
|
+
end
|
12
|
+
|
13
|
+
def create
|
14
|
+
@project = C::Project.new(project_params)
|
15
|
+
if @project.save
|
16
|
+
redirect_to projects_path, notice: 'Project created'
|
17
|
+
else
|
18
|
+
render :new
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def update
|
23
|
+
if params[:commit] == 'upload'
|
24
|
+
@project.assign_attributes(new_image_params)
|
25
|
+
render :edit
|
26
|
+
elsif @project.update(project_params)
|
27
|
+
redirect_to projects_path, notice: 'Project updated'
|
28
|
+
else
|
29
|
+
render :edit
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def destroy
|
34
|
+
@project.destroy
|
35
|
+
respond_to do |format|
|
36
|
+
format.js
|
37
|
+
format.html { redirect_to projects_path }
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
private
|
42
|
+
|
43
|
+
def load_from_url
|
44
|
+
@project = C::Project.get_from_url(params[:id])
|
45
|
+
end
|
46
|
+
|
47
|
+
def new_image_params
|
48
|
+
params.require(:project).permit(new_images: [], images_attributes: [:id, :_destroy, :alt, :caption])
|
49
|
+
end
|
50
|
+
|
51
|
+
def project_params
|
52
|
+
params.require(:project).permit(:name, :body, :published, :url_alias, C::Page::IMAGEABLE_ATTRIBUTES, C::Page::PAGE_INFO_ATTRIBUTES, new_images: [])
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require_dependency 'c/admin_controller'
|
3
|
+
|
4
|
+
module C
|
5
|
+
class Admin::RedirectsController < AdminController
|
6
|
+
load_and_authorize_resource class: C::Redirect
|
7
|
+
before_action :set_redirect, only: [:edit, :update, :destroy]
|
8
|
+
|
9
|
+
def index
|
10
|
+
@redirects = filter_and_paginate(@redirects, 'old_url asc')
|
11
|
+
end
|
12
|
+
|
13
|
+
def create
|
14
|
+
if @redirect.save
|
15
|
+
redirect_to redirects_path, notice: 'Redirect Created'
|
16
|
+
else
|
17
|
+
render :new
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def update
|
22
|
+
if @redirect.update(redirect_params)
|
23
|
+
redirect_to redirects_path, notice: 'Redirect Updated'
|
24
|
+
else
|
25
|
+
render :edit
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def destroy
|
30
|
+
@redirect.destroy!
|
31
|
+
respond_to do |format|
|
32
|
+
format.js
|
33
|
+
format.html { redirect_to [:redirect] }
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def confirm_destroy; end
|
38
|
+
|
39
|
+
def bulk_actions
|
40
|
+
@redirects = C::Redirect.where(id: params[:redirect])
|
41
|
+
action = @redirects.bulk_action(params[:bulk_actions])
|
42
|
+
redirect_back(fallback_location: order_sales_path, notice: action)
|
43
|
+
end
|
44
|
+
|
45
|
+
private
|
46
|
+
|
47
|
+
def set_redirect
|
48
|
+
@redirect = Redirect.find(params[:id])
|
49
|
+
end
|
50
|
+
|
51
|
+
def redirect_params
|
52
|
+
params.require(:redirect).permit(:old_url, :new_url, :last_used, :used_counter)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require_dependency 'c/admin_controller'
|
3
|
+
|
4
|
+
module C
|
5
|
+
class Admin::RolesController < AdminController
|
6
|
+
load_and_authorize_resource class: C::Role
|
7
|
+
|
8
|
+
def index; end
|
9
|
+
|
10
|
+
def new; end
|
11
|
+
|
12
|
+
def create
|
13
|
+
if @role.save
|
14
|
+
flash[:success] = 'Role saved.'
|
15
|
+
redirect_to roles_path
|
16
|
+
else
|
17
|
+
render :new
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def edit; end
|
22
|
+
|
23
|
+
def update
|
24
|
+
if @role.update(role_params)
|
25
|
+
flash[:success] = 'Role updated.'
|
26
|
+
redirect_to roles_path
|
27
|
+
else
|
28
|
+
render :edit
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def destroy
|
33
|
+
if @role.destroy
|
34
|
+
flash[:success] = 'Role deleted.'
|
35
|
+
else
|
36
|
+
flash[:error] = 'An error occurred.'
|
37
|
+
end
|
38
|
+
redirect_to roles_path
|
39
|
+
end
|
40
|
+
|
41
|
+
def confirm_destroy; end
|
42
|
+
|
43
|
+
private
|
44
|
+
|
45
|
+
def role_params
|
46
|
+
params.require(:role).permit(:name, :body, permissions_attributes: [:id, :permission_subject_id, :read, :new, :edit, :remove])
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require_dependency 'c/admin_controller'
|
3
|
+
|
4
|
+
module C
|
5
|
+
class Admin::SlidesController < AdminController
|
6
|
+
load_and_authorize_resource :slideshow, class: C::Slideshow
|
7
|
+
load_and_authorize_resource :slide, class: C::Slide, through: :slideshow
|
8
|
+
|
9
|
+
def create
|
10
|
+
@slide = @slideshow.slides.new(slide_params)
|
11
|
+
if @slide.save
|
12
|
+
redirect_to edit_slideshow_path(@slideshow), notice: 'Slide created'
|
13
|
+
else
|
14
|
+
render :new
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def update
|
19
|
+
if @slide.update(slide_params)
|
20
|
+
redirect_to edit_slideshow_path(@slideshow), notice: 'Slide updated'
|
21
|
+
else
|
22
|
+
render :edit
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def destroy
|
27
|
+
@slide.destroy
|
28
|
+
respond_to do |format|
|
29
|
+
format.js
|
30
|
+
format.html do
|
31
|
+
redirect_to @slideshow, notice: 'Slide deleted'
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def sort
|
37
|
+
@slides = C::Slideshow.find(params[:slideshow_id]).slides
|
38
|
+
@slides.update_order(params[:slideshow])
|
39
|
+
respond_to do |format|
|
40
|
+
format.js { head :ok, content_type: 'text/html' }
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
private
|
45
|
+
|
46
|
+
def slide_params
|
47
|
+
params.require(:slide).permit(:name, :body, :url, :image)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require_dependency 'c/admin_controller'
|
3
|
+
|
4
|
+
module C
|
5
|
+
class Admin::SlideshowsController < AdminController
|
6
|
+
load_and_authorize_resource class: C::Slideshow
|
7
|
+
|
8
|
+
def index
|
9
|
+
@slideshows = @slideshows.ordered
|
10
|
+
end
|
11
|
+
|
12
|
+
def create
|
13
|
+
if @slideshow.save
|
14
|
+
redirect_to [:edit, @slideshow], notice: 'Slideshow created'
|
15
|
+
else
|
16
|
+
render :new
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def update
|
21
|
+
if @slideshow.update(slideshow_params)
|
22
|
+
redirect_to [:edit, @slideshow], notice: 'Slideshow updated'
|
23
|
+
else
|
24
|
+
render :new
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def slideshow_params
|
31
|
+
params.require(:slideshow).permit(:id, :name, :body)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require_dependency 'c/admin_controller'
|
3
|
+
|
4
|
+
module C
|
5
|
+
class Admin::TeamMembersController < AdminController
|
6
|
+
before_action :load_from_url, only: [:destroy, :edit, :update]
|
7
|
+
load_and_authorize_resource class: C::TeamMember
|
8
|
+
|
9
|
+
def index
|
10
|
+
@team_members
|
11
|
+
end
|
12
|
+
|
13
|
+
def new; end
|
14
|
+
|
15
|
+
def edit; end
|
16
|
+
|
17
|
+
def create
|
18
|
+
if @team_member.save
|
19
|
+
redirect_to team_members_path, notice: 'Team Member created'
|
20
|
+
else
|
21
|
+
render :new
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def update
|
26
|
+
if @team_member.update(team_member_params)
|
27
|
+
redirect_to team_members_path, notice: 'Team Member updated'
|
28
|
+
else
|
29
|
+
render :edit
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def dashboard; end
|
34
|
+
|
35
|
+
def destroy
|
36
|
+
@team_member.destroy
|
37
|
+
respond_to do |format|
|
38
|
+
format.js
|
39
|
+
format.html { redirect_to team_members_path }
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def sort
|
44
|
+
@team_members = C::TeamMember.all
|
45
|
+
@team_members.update_order(params[:team_member])
|
46
|
+
respond_to do |format|
|
47
|
+
format.js { head :ok, content_type: 'text/html' }
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
private
|
52
|
+
|
53
|
+
def load_from_url
|
54
|
+
@team_member = C::TeamMember.find(params[:id])
|
55
|
+
end
|
56
|
+
|
57
|
+
def team_member_params
|
58
|
+
params.require(:team_member).permit(:id, :name, :role, :image, :body)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require_dependency 'c/admin_controller'
|
3
|
+
|
4
|
+
module C
|
5
|
+
class Admin::TestimonialsController < AdminController
|
6
|
+
load_and_authorize_resource class: C::Testimonial
|
7
|
+
|
8
|
+
def index
|
9
|
+
@testimonials = filter_and_paginate(@testimonials, 'created_at desc')
|
10
|
+
end
|
11
|
+
|
12
|
+
def create
|
13
|
+
@testimonial = C::Testimonial.new(testimonial_params)
|
14
|
+
if @testimonial.save
|
15
|
+
redirect_to testimonials_path, notice: 'Testimonial created'
|
16
|
+
else
|
17
|
+
render :new
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def update
|
22
|
+
if @testimonial.update(testimonial_params)
|
23
|
+
redirect_to testimonials_path, notice: 'Testimonial updated'
|
24
|
+
else
|
25
|
+
render :edit
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def destroy
|
30
|
+
@testimonial.destroy
|
31
|
+
respond_to do |format|
|
32
|
+
format.js
|
33
|
+
format.html { redirect_to testimonials_path }
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
private
|
38
|
+
|
39
|
+
def testimonial_params
|
40
|
+
params.require(:testimonial).permit(:author, :quote)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require_dependency 'c/admin_controller'
|
3
|
+
|
4
|
+
module C
|
5
|
+
class Admin::UsersController < AdminController
|
6
|
+
load_and_authorize_resource class: C::User
|
7
|
+
|
8
|
+
def index
|
9
|
+
@users = filter_and_paginate(@users, 'name asc')
|
10
|
+
end
|
11
|
+
|
12
|
+
def create
|
13
|
+
if @user.save
|
14
|
+
redirect_to users_path, notice: 'User created'
|
15
|
+
else
|
16
|
+
render :new
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def update
|
21
|
+
if @user.update(user_params)
|
22
|
+
redirect_to users_path, notice: 'User created'
|
23
|
+
else
|
24
|
+
render :edit
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def destroy
|
29
|
+
if @user != current_user && @user.destroy
|
30
|
+
respond_to do |format|
|
31
|
+
format.js
|
32
|
+
format.html { redirect_to [:redirect] }
|
33
|
+
end
|
34
|
+
else
|
35
|
+
redirect_to [:redirect]
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def confirm_destroy; end
|
40
|
+
|
41
|
+
private
|
42
|
+
|
43
|
+
def user_params
|
44
|
+
if params[:user][:password].blank?
|
45
|
+
params[:user].delete(:password)
|
46
|
+
params[:user].delete(:password_confirmation)
|
47
|
+
end
|
48
|
+
params.require(:user).permit(:name, :email, :password, role_ids: [])
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require_dependency 'c/application_controller'
|
3
|
+
|
4
|
+
module C
|
5
|
+
class AdminController < ApplicationController
|
6
|
+
check_authorization unless: :devise_controller?
|
7
|
+
|
8
|
+
before_action :authenticate_user!
|
9
|
+
before_action :current_user_id
|
10
|
+
|
11
|
+
def edit
|
12
|
+
ajax_form
|
13
|
+
end
|
14
|
+
|
15
|
+
def new
|
16
|
+
ajax_form
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def current_ability
|
22
|
+
@current_ability ||= ::C::Ability.new(current_user)
|
23
|
+
end
|
24
|
+
|
25
|
+
def ajax_form
|
26
|
+
respond_to do |format|
|
27
|
+
format.html
|
28
|
+
format.js { render 'quick_edit' }
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def current_user_id
|
33
|
+
# For the Authorable concern
|
34
|
+
$user_id = current_user.id
|
35
|
+
end
|
36
|
+
|
37
|
+
def filter_and_paginate(collection, default_sort='id asc', per_page=30)
|
38
|
+
@q = collection.ransack(params[:q])
|
39
|
+
@q.sorts = default_sort if @q.sorts.empty?
|
40
|
+
@q.result.paginate(page: params[:page], per_page: per_page)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module C
|
3
|
+
class ApplicationController < ActionController::Base
|
4
|
+
protect_from_forgery with: :exception
|
5
|
+
layout :layout
|
6
|
+
|
7
|
+
def layout
|
8
|
+
devise_controller? ? 'c/cms_login_layout' : 'c/application'
|
9
|
+
end
|
10
|
+
|
11
|
+
def current_ability
|
12
|
+
Ability.new(current_user)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module C
|
3
|
+
class Front::Devise::RegistrationsController < Devise::RegistrationsController
|
4
|
+
layout 'c/main_application'
|
5
|
+
|
6
|
+
def after_sign_up_path_for(resource)
|
7
|
+
if session[:cart_id].present?
|
8
|
+
begin
|
9
|
+
customer = current_front_customer_account.customer
|
10
|
+
cart = C::Cart.find(session[:cart_id])
|
11
|
+
cart.update(customer_id: customer.id)
|
12
|
+
cart.order.update(customer: customer) if cart.order.present?
|
13
|
+
rescue ActiveRecord::RecordNotFound
|
14
|
+
# Do nothing, as there is nothing to set
|
15
|
+
end
|
16
|
+
session.delete(:cart_id)
|
17
|
+
end
|
18
|
+
params['checkout'] ? new_checkout_path : super
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def sign_up_params
|
24
|
+
h = params.require(:front_customer_account).permit(
|
25
|
+
:email, :password, :password_confirmation,
|
26
|
+
customer_attributes: [:name]
|
27
|
+
)
|
28
|
+
h[:customer_attributes][:email] = h[:email]
|
29
|
+
h
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module C
|
3
|
+
class Front::Devise::SessionsController < Devise::SessionsController
|
4
|
+
layout 'c/main_application'
|
5
|
+
after_action :after_login, only: :create
|
6
|
+
|
7
|
+
def after_login
|
8
|
+
return unless session[:cart_id].present?
|
9
|
+
begin
|
10
|
+
customer = current_front_customer_account.customer
|
11
|
+
cart = C::Cart.find(session[:cart_id])
|
12
|
+
cart.update(customer_id: customer.id)
|
13
|
+
cart.order.update(customer: customer) if cart.order.present?
|
14
|
+
rescue ActiveRecord::RecordNotFound
|
15
|
+
# Do nothing, as there is nothing to set
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def after_sign_in_path_for(resource)
|
20
|
+
request[:checkout] ? new_checkout_path : super
|
21
|
+
end
|
22
|
+
|
23
|
+
def after_sign_out_path_for(_resource_or_scope)
|
24
|
+
'/'
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require_dependency 'c/application_controller'
|
3
|
+
|
4
|
+
module C
|
5
|
+
class Front::MailchimpController < ApplicationController
|
6
|
+
def subscribe
|
7
|
+
begin
|
8
|
+
@mc = Mailchimp::API.new(Setting.get('mailchimp_api_key'))
|
9
|
+
email = params['email']
|
10
|
+
begin
|
11
|
+
@mc.lists.subscribe(Setting.get('mailchimp_list_id'), 'email' => email)
|
12
|
+
flash[:success] = "#{email} subscribed successfully"
|
13
|
+
rescue Mailchimp::ListAlreadySubscribedError
|
14
|
+
flash[:error] = "#{email} is already subscribed to the list"
|
15
|
+
rescue Mailchimp::ListDoesNotExistError
|
16
|
+
flash[:error] = 'The list could not be found'
|
17
|
+
redirect_back(fallback_location: front_end_root_path)
|
18
|
+
return
|
19
|
+
rescue Mailchimp::Error => ex
|
20
|
+
flash[:error] = if ex.message
|
21
|
+
ex.message
|
22
|
+
else
|
23
|
+
'An unknown error occurred'
|
24
|
+
end
|
25
|
+
end
|
26
|
+
rescue Mailchimp::InvalidApiKeyError => ex
|
27
|
+
flash[:error] = ex.message
|
28
|
+
end
|
29
|
+
redirect_back(fallback_location: front_end_root_path)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require_dependency 'c/application_controller'
|
3
|
+
|
4
|
+
module C
|
5
|
+
class FrontEnd::BlogsController < MainApplicationController
|
6
|
+
include BlogsHelper
|
7
|
+
|
8
|
+
def index
|
9
|
+
get_page C::Page, 'blogs'
|
10
|
+
@blogs = C::Blog.order(created_at: 'DESC')
|
11
|
+
archive_blogs
|
12
|
+
end
|
13
|
+
|
14
|
+
def show
|
15
|
+
get_page C::Blog
|
16
|
+
@blog = @page
|
17
|
+
redirect_to root_url unless @blog.published || user_signed_in?
|
18
|
+
force_clean_url @blog
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require_dependency 'c/application_controller'
|
3
|
+
|
4
|
+
module C
|
5
|
+
class FrontEnd::EnquiriesController < MainApplicationController
|
6
|
+
def new
|
7
|
+
get_page C::Page, 'contact-us'
|
8
|
+
@enquiry = C::Enquiry.new
|
9
|
+
end
|
10
|
+
|
11
|
+
def create
|
12
|
+
get_page C::Page, 'contact-us'
|
13
|
+
@enquiry = C::Enquiry.new(enquiry_params)
|
14
|
+
if @enquiry.save
|
15
|
+
C::EnquiriesMailer.new_enquiry(@enquiry).deliver_now
|
16
|
+
redirect_to thanks_front_end_enquiries_path
|
17
|
+
else
|
18
|
+
render :new
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def thanks
|
23
|
+
@enquiry = C::Enquiry.new
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def enquiry_params
|
29
|
+
params.require(:enquiry).permit(:name, :email, :body)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require_dependency 'c/application_controller'
|
3
|
+
|
4
|
+
module C
|
5
|
+
class FrontEnd::PagesController < MainApplicationController
|
6
|
+
def show
|
7
|
+
get_page C::Page
|
8
|
+
render @render if @render
|
9
|
+
redirect_to root_url unless @page.published || user_signed_in?
|
10
|
+
end
|
11
|
+
|
12
|
+
def sitemap
|
13
|
+
@pages = C::Page.all
|
14
|
+
respond_to do |format|
|
15
|
+
format.xml
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require_dependency 'c/application_controller'
|
3
|
+
|
4
|
+
module C
|
5
|
+
class MainApplicationController < ApplicationController
|
6
|
+
layout 'c/main_application'
|
7
|
+
helper C::NavigationHelper
|
8
|
+
helper C::StorefrontHelper
|
9
|
+
helper C::PagesHelper
|
10
|
+
include C::PagesHelper
|
11
|
+
|
12
|
+
before_action :check_redirects
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def check_redirects
|
17
|
+
return unless (redirect = C::Redirect.find_by(old_url: request.path))
|
18
|
+
redirect.increment
|
19
|
+
redirect_to redirect.new_url
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|