Refactor for mobile deployment

This commit is contained in:
2014-08-19 12:44:15 +02:00
parent 268c5aabb9
commit 0e46633c73
27 changed files with 848 additions and 41 deletions
@@ -14,6 +14,12 @@ class ApplicationController < ActionController::Base
private
def allow_all_origins
headers['Access-Control-Allow-Origin'] = '*'
headers['Access-Control-Request-Method'] = '*'
headers['Access-Control-Allow-Headers'] = '*'
end
def authorize_cmtool
redirect_to '/', alert: t('general.unauthorized') unless current_user.present? && current_user.admin?
end
+1 -7
View File
@@ -1,16 +1,10 @@
class UserController < Users::ApplicationController
before_filter :allow_mobile
before_action :allow_all_origins
layout 'user/foundation'
#layout 'phone'
alias :list :active_list
def allow_mobile
headers['Access-Control-Allow-Origin'] = '*'
headers['Access-Control-Request-Method'] = '*'
headers['Access-Control-Allow-Headers'] = '*'
end
def index
handle_message_params
end
@@ -1,5 +1,6 @@
module Users
class ApplicationController < ::ApplicationController
before_action :allow_all_origins
before_action :user_authentication, :unless => ->(c){ %w(obtain_token).include?(c.action_name) || c.request.format.symbol == :html } # , except: [:obtain_token, :index]
private
+2 -2
View File
@@ -3,9 +3,9 @@ module Users
def index
#lists = current_user.lists.include_relation(:supplier, :table)
lists = List.for_user(current_user, page: params[:page], per_page: params[:per_page].presence || 25).include_relation(:supplier, :table)
lists = List.for_user(current_user, page: params[:page], per_page: params[:per_page].presence || 25)
#lists.include_relation(:supplier)
lists.include_relation(:users, :orders)
lists.include_relation(:users, :orders, :supplier, :table)
render json: lists, each_serializer: UserListSerializer, meta: {total_pages: lists.total_pages, page: lists.current_page} #, root: :lists
end