Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a way for non-super-admin users to view orders that they cannot edit #750

Open
smellsblue opened this issue Dec 8, 2020 · 0 comments · May be fixed by #777
Open

Add a way for non-super-admin users to view orders that they cannot edit #750

smellsblue opened this issue Dec 8, 2020 · 0 comments · May be fixed by #777

Comments

@smellsblue
Copy link
Contributor

Currently, if a user cannot edit it, clicking the order redirects them back to the orders page. Perhaps the controller should look something like this:

  def edit
    @order = Order.includes(order_details: :item).find(params[:id])

    if current_user.can_edit_order?(@order)
      if Rails.root.join("app/views/orders/status/#{@order.status}.html.erb").exist?
        render "orders/status/#{@order.status}"
      end
    elsif current_user.can_view_order?(@order)
      render "orders/show"
    else
      redirect_to orders_path
    end
  end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants