ref: master
plugins/orders/controllers/profile/orders_plugin_order_controller.rb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
class OrdersPluginOrderController < ProfileController include OrdersPlugin::TranslationHelper before_filter :login_required, except: [:index, :edit] before_filter :load_order, except: [:new] before_filter :check_access, only: [:confirm, :remove, :cancel] before_filter :set_actor_name before_filter :disable_purechat helper OrdersPlugin::TranslationHelper helper OrdersPlugin::DisplayHelper def repeat end protected def load_order @order = hmvc_context::Sale.find_by id: params[:id] render_access_denied if @order.present? and not @user_is_admin and not @order.may_view? user end def check_access access = 'view' unless @order.send "may_#{access}?", user session[:notice] = if user.blank? then t('orders_plugin.controllers.profile.consumer.login_first') else session[:notice] = t('orders_plugin.controllers.profile.consumer.you_are_not_the_owner') end redirect_to action: :index false else true end end # default value, may be overwriten def set_actor_name @actor_name = :consumer end extend HMVC::ClassMethods hmvc OrdersPlugin def disable_purechat @disable_purechat = true end end |