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

Market maker can associate product with supplier and suppliers only see their own products #37

Merged
merged 1 commit into from
Oct 11, 2017

Conversation

kenton
Copy link
Contributor

@kenton kenton commented Oct 3, 2017

This should take care of issues #20 and #21.

End results is that, as of this PR,

  • a MarketMaker can edit a product and map it to one or more suppliers
  • when a supplier logs in, they only see their products
  • MarketMakers still see all products
  • MarketMakers can add/remove one or many suppliers to/from a product, then update the product to save those changes

Implemented and lightly tested in the browser, but needs specs updated.

Pushing PR now to get some early eyes on it, but still need to work on those specs.

if params[:ids]
@suppliers = Spree::Supplier.accessible_by(current_ability, :read).where(id: params[:ids].split(',')).order(:name)
else
@suppliers = Spree::Supplier.accessible_by(current_ability, :read).order(:name).ransack(params[:q]).result
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ooh! TIL: ransack!

</div>
</div>

<div class="clear"></div>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/clear/clearfix?

@pmn4
Copy link

pmn4 commented Oct 4, 2017

despite being a lot of code, this is pretty straightforward.
I have a few style comments, but keeping the focus on the behavior: lgtm

updates to lock down admin based on user role
  * ensures default supplier_admin role is added to the db when extension is
    installed and db:seed is run
  * reimplements user management to define marketmaker and
    supplier_admin based on existing spree_roles vs. checking whether
    a user has a supplier and an admin role.
      * allows us to create cancan abilities based on spree_roles for
        supplier_admin without those users getting abilities that are
        defined for the admin role
  * only displays supplier field on product edit page when user is a marketmaker
  * updates cancan abilities for supplier_admin
@kenton kenton force-pushed the kn/market-maker-can-associate-product-with-supplier branch from bf54de2 to b197dc3 Compare October 11, 2017 16:13
@kenton kenton merged commit b197dc3 into master Oct 11, 2017
@kenton kenton deleted the kn/market-maker-can-associate-product-with-supplier branch October 17, 2017 15:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants