Add section elements
This commit is contained in:
@@ -1,8 +1,16 @@
|
||||
module Admin
|
||||
class ApplicationController < ::ApplicationController
|
||||
before_filter :authenticate_administrator!
|
||||
layout 'administrator'
|
||||
private
|
||||
before_action :setup_administrator!
|
||||
load_and_authorize_resource
|
||||
layout 'cmtool/application'
|
||||
private
|
||||
|
||||
def setup_administrator!
|
||||
authenticate_administrator!
|
||||
@current_ability = Admin::Ability.new current_administrator
|
||||
run_after_authentication_hooks!
|
||||
end
|
||||
|
||||
def set_locale
|
||||
I18n.locale = :en
|
||||
end
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# encoding: UTF-8
|
||||
module Admin
|
||||
module Admin
|
||||
class ProductsController < Admin::ApplicationController
|
||||
before_filter :set_relation_options, only: [:new, :edit, :create, :update]
|
||||
# GET /products
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
# encoding: UTF-8
|
||||
module Admin
|
||||
class SvgElementsController < Admin::ApplicationController
|
||||
def index
|
||||
@svg_elements = SvgElement.all
|
||||
end
|
||||
|
||||
def new
|
||||
|
||||
end
|
||||
|
||||
def create
|
||||
if @svg_element.save
|
||||
redirect_to [:edit, :admin, @svg_element]
|
||||
else
|
||||
render 'new'
|
||||
end
|
||||
end
|
||||
|
||||
def update
|
||||
if @svg_element.update_attributes svg_element_params
|
||||
redirect_to [:edit, :admin, @svg_element]
|
||||
else
|
||||
render 'edit'
|
||||
end
|
||||
end
|
||||
|
||||
def show
|
||||
|
||||
end
|
||||
|
||||
def edit
|
||||
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def svg_element_params
|
||||
params.require(:svg_element).permit!
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,31 @@
|
||||
module Suppliers
|
||||
class SectionElementsController < Suppliers::ApplicationController
|
||||
def index
|
||||
@section_elements = SectionElement.for_supplier(current_supplier)
|
||||
render json: @section_elements, each_serializer: Suppliers::SectionElementSerializer
|
||||
end
|
||||
|
||||
def create
|
||||
@section_element.supplier = current_supplier
|
||||
if @section_element.save
|
||||
render json: @section_element, serializer: Suppliers::SectionElementSerializer
|
||||
else
|
||||
render json: {errors: @section.errors}, status: :unprocessable_entity
|
||||
end
|
||||
end
|
||||
|
||||
def update
|
||||
if @section_element.update_attributes section_element_params
|
||||
render json: @section_element, serializer: Suppliers::SectionElementSerializer
|
||||
else
|
||||
render json: {errors: @section.errors}, status: :unprocessable_entity
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def section_element_params
|
||||
params.require(:section_element).permit %i[name svg dpm box_width box_height position_x position_y rotation svg_element_id section_id]
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,8 @@
|
||||
module Suppliers
|
||||
class SvgElementsController < Suppliers::ApplicationController
|
||||
def index
|
||||
@svg_elements = SvgElement.all
|
||||
render json: @svg_elements, each_serializer: Suppliers::SvgElementSerializer
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,7 @@
|
||||
module Tests
|
||||
class ApplicationController < ::ApplicationController
|
||||
def f
|
||||
FactoryGirl
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,7 @@
|
||||
module Tests
|
||||
class ListsController < Tests::ApplicationController
|
||||
def index
|
||||
render json: []
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,8 @@
|
||||
module Tests
|
||||
class SuppliersController < Tests::ApplicationController
|
||||
def show
|
||||
@supplier = f.build :supplier, id: params[:id]
|
||||
render json: @supplier, serializer: Suppliers::SupplierSerializer
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user