[mezzanine-users] Re: Cartridge creating a product with a user defined price

2014-11-24 Thread henri
I have updated page_processors.py and the error doesn't appear anymore. See the 
updated Gist https://gist.github.com/henri-hulski/35554d2a6321547bc787.
I also see the Donate now form, but if I put an amount inside I get the 
error Please correct the errors below,
so he still cannot process the donation amount.

Thanks for your help, I think I'm getting closer,

Henri


Am Montag, 24. November 2014 11:01:30 UTC+1 schrieb henri:

 This is what I tried.
 But I get the error:
 TypeError: class 'cartridge.shop.models.Product' is not a valid argument 
 for page_processor, which should be a model subclass of Page in class or 
 string form (app.model), or a valid slug

 For now I have replaced the HTML form in a copy of 
 temlates/shop/product.html, but the goal is to have normal products and 
 products for donation beside each other as you described in your first post.
 So how Cartridge knows which products are for donation?

 I have put the 
 donation_product/page_processors.py, donation_product/utils.py 
 and donation_product/temlates/shop/product.html in a gist 
 https://gist.github.com/henri-hulski/35554d2a6321547bc787.

 Henri

 Am Montag, 24. November 2014 08:35:05 UTC+1 schrieb Josh B:

 Create a page_processor for Product (
 http://mezzanine.jupo.org/docs/content-architecture.html#page-processors
 ). 

 On Saturday, November 22, 2014 3:42:09 PM UTC-7, henri wrote:

 Hallo Josh,

 Thanks a lot.
 This is a good starting point.

 One more question.
 Where do you put your form?
 It seems to me, that it shut go in shop/product.html, but how to inject 
 it there?

 Henri


 Am Freitag, 21. November 2014 22:35:00 UTC+1 schrieb Josh B:

 Sorry, was traveling and missed your message. What you will need to do 
 is create either a view or a page processor (
 http://mezzanine.jupo.org/docs/content-architecture.html#page-processors) 
 to post your new form to. Code samples below.

 Here is my form:
 form method=post id=add-cart action={{ 
 item.product.get_absolute_url }}
   {% csrf_token %}
   input type=hidden id=product_id name=product_id value={{ 
 item.product.id }} /
   input type=hidden name=quantity id=id_quantity value=1
   input type=text  class=donation id=donation_amount 
 name=donation_amount /
   button type=submit class=button smallDonate Now/button
 /form

 Form processing code:
 from .utils import Donation

 if request.method == POST and form.is_valid():
   product = Product.objects.get(id=request.POST.get(product_id))
   item = Donation(product, 
 float(request.POST.get(donation_amount,0.0)) )
   request.cart.add_item(item, 1)

 Utils
 class Donation(object):
 def __init__(self, product, unit_price, buyers_group):
 product_variation = product.variations.all()
 self.description = product.title
 self.unit_price = unit_price
 self.url = product.get_absolute_url()
 self.sku = product_variation[0].sku
 self.product = product
 self.image = product_variation[0].image
 self.buyers_group = buyers_group

 def price(self):
   return self.unit_price 

 def __unicode__(self):
 return self.description

 On Friday, November 21, 2014 2:20:29 PM UTC-7, henri wrote:

 Hallo,

 I still don't know really how to start.
 Is the implementation similar to what Josh Cartmell describes in his 
 Blog Collecting additional information on a per product basis in 
 Cartridge 
 http://bitofpixels.com/blog/collecting-additional-information-on-a-per-product-basis-in-cartridge/
 ?

 Henri


 Am Dienstag, 18. November 2014 19:22:01 UTC+1 schrieb henri:

 Hallo Josh,

 I also need the Donation option for real products, so I think your 
 approach ist the right for my case.

 I must say, I'm not only new with Mezzanine/Cartrige but also with 
 Django/Python.
 Before I was mainly coding in PHP.

 So I tried to understand your code and find a way to implement it, 
 but I think I'm not able to.
 I think it is somehow connected with shop/views.py but I have no idea 
 how.

 Maybe you can give me some hints,

 Henri



 Am Dienstag, 18. November 2014 00:03:54 UTC+1 schrieb Josh B:

 This approach has been solid for me and currently using it in a 
 production environment. For my use I needed real Donation products as 
 they 
 needed to expire or only sell a limited number. If you don't need that 
 functionality then you can use what Josh C posted.

 Josh

 On Monday, November 17, 2014 4:56:44 AM UTC-7, henri wrote:

 Hey Josh,

 I also would like to implement donation driven products.
 Do you still stay with this approach or have you found a better 
 solution?

 Henri 



-- 
You received this message because you are subscribed to the Google Groups 
Mezzanine Users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to mezzanine-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[mezzanine-users] Re: Cartridge creating a product with a user defined price

2014-11-23 Thread Josh B
Create a page_processor for Product 
(http://mezzanine.jupo.org/docs/content-architecture.html#page-processors). 

On Saturday, November 22, 2014 3:42:09 PM UTC-7, henri wrote:

 Hallo Josh,

 Thanks a lot.
 This is a good starting point.

 One more question.
 Where do you put your form?
 It seems to me, that it shut go in shop/product.html, but how to inject it 
 there?

 Henri


 Am Freitag, 21. November 2014 22:35:00 UTC+1 schrieb Josh B:

 Sorry, was traveling and missed your message. What you will need to do is 
 create either a view or a page processor (
 http://mezzanine.jupo.org/docs/content-architecture.html#page-processors) 
 to post your new form to. Code samples below.

 Here is my form:
 form method=post id=add-cart action={{ 
 item.product.get_absolute_url }}
   {% csrf_token %}
   input type=hidden id=product_id name=product_id value={{ 
 item.product.id }} /
   input type=hidden name=quantity id=id_quantity value=1
   input type=text  class=donation id=donation_amount 
 name=donation_amount /
   button type=submit class=button smallDonate Now/button
 /form

 Form processing code:
 from .utils import Donation

 if request.method == POST and form.is_valid():
   product = Product.objects.get(id=request.POST.get(product_id))
   item = Donation(product, 
 float(request.POST.get(donation_amount,0.0)) )
   request.cart.add_item(item, 1)

 Utils
 class Donation(object):
 def __init__(self, product, unit_price, buyers_group):
 product_variation = product.variations.all()
 self.description = product.title
 self.unit_price = unit_price
 self.url = product.get_absolute_url()
 self.sku = product_variation[0].sku
 self.product = product
 self.image = product_variation[0].image
 self.buyers_group = buyers_group

 def price(self):
   return self.unit_price 

 def __unicode__(self):
 return self.description

 On Friday, November 21, 2014 2:20:29 PM UTC-7, henri wrote:

 Hallo,

 I still don't know really how to start.
 Is the implementation similar to what Josh Cartmell describes in his 
 Blog Collecting additional information on a per product basis in 
 Cartridge 
 http://bitofpixels.com/blog/collecting-additional-information-on-a-per-product-basis-in-cartridge/
 ?

 Henri


 Am Dienstag, 18. November 2014 19:22:01 UTC+1 schrieb henri:

 Hallo Josh,

 I also need the Donation option for real products, so I think your 
 approach ist the right for my case.

 I must say, I'm not only new with Mezzanine/Cartrige but also with 
 Django/Python.
 Before I was mainly coding in PHP.

 So I tried to understand your code and find a way to implement it, but 
 I think I'm not able to.
 I think it is somehow connected with shop/views.py but I have no idea 
 how.

 Maybe you can give me some hints,

 Henri



 Am Dienstag, 18. November 2014 00:03:54 UTC+1 schrieb Josh B:

 This approach has been solid for me and currently using it in a 
 production environment. For my use I needed real Donation products as 
 they 
 needed to expire or only sell a limited number. If you don't need that 
 functionality then you can use what Josh C posted.

 Josh

 On Monday, November 17, 2014 4:56:44 AM UTC-7, henri wrote:

 Hey Josh,

 I also would like to implement donation driven products.
 Do you still stay with this approach or have you found a better 
 solution?

 Henri 



-- 
You received this message because you are subscribed to the Google Groups 
Mezzanine Users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to mezzanine-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[mezzanine-users] Re: Cartridge creating a product with a user defined price

2014-11-17 Thread Josh B
This approach has been solid for me and currently using it in a production 
environment. For my use I needed real Donation products as they needed to 
expire or only sell a limited number. If you don't need that functionality 
then you can use what Josh C posted.

Josh

On Monday, November 17, 2014 4:56:44 AM UTC-7, henri wrote:

 Hey Josh,

 I also would like to implement donation driven products.
 Do you still stay with this approach or have you found a better solution?

 Henri 



-- 
You received this message because you are subscribed to the Google Groups 
Mezzanine Users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to mezzanine-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.