Re: [mezzanine-users] [Cartridge] - Admin links to custom product type no longer work

2017-04-08 Thread Ryne Everett
I can reproduce with both the OP's project and a fresh project following
the docs on both current master and right after the patch landed.

A quick look at django-debug-toolbar suggests that the `{% if
content_models.count > 1 %}` condition in the
`admin/shop/product/change_list.html` template isn't being triggered,
even though I can see more than one item in the `content_models` context
variable.

-- 
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.


Re: [mezzanine-users] [Cartridge] - Admin links to custom product type no longer work

2017-04-06 Thread Pete Dermott
Thank you for the reply Stephen. I don't know if I'm missing something but 
I'm still having some problems with this. 

You say: 

> You'll see an "Add product" dropdown list (presumably with only one item 
> in it in your case, namely BaseProduct), which is how you choose which type 
> of product you're adding. 
>

But no matter what I do I don't see any such dropdown, I've created an 
example project based on the guide from 
https://github.com/stephenmcd/cartridge/blob/master/docs/components.rst and 
have pushed this up to a simple github repo at 
https://github.com/petedermott/cartridge-example.

In short, my models.py look like this:

from django.db import models

from cartridge.shop.models import Product

# Create your models here.
class SubclassedProduct(Product):
test = models.CharField(blank=True, null=True, max_length=255)


and my admin.py looks like this:

from django.contrib import admin

from cartridge.shop.admin import ProductAdmin
from test_products.models import SubclassedProduct

# Register your models here.
admin.site.register(SubclassedProduct, ProductAdmin)


Is there something obvious I'm missing?

On Monday, February 6, 2017 at 12:34:37 AM UTC, Stephen McDonald wrote:
>
> Hi there,
>
> Subclassing the product model was previously not a supported feature - I 
> imagine you had to do some extensive hacking to get that working in the 
> actual site. 
>
> It now is a supported feature however, much like the Page model in 
> Mezzanine can be subclasses to create custom page types, custom products 
> now work the same in the development version of Cartridge.
>
> The good news is that what you've done should mostly work now - it's just 
> that your existing products are missing a value that identifies them as 
> your BaseProduct custom product type - if you inspect the DB somehow, 
> you'll see the table for the Product model has a "content_type" field (if I 
> recall correctly), and it stores a string name for the type of product it's 
> related to, in your case I think the value would be "baseproduct", but the 
> best way to know for sure would be to add a new product of "BaseProduct" 
> type, and see what value gets stored for that. 
>
> BTW the redirection is occurring because with this new version, *all* 
> product subclasses in the admin will redirect to one listing page where 
> they all get managed. You'll see an "Add product" dropdown list (presumably 
> with only one item in it in your case, namely BaseProduct), which is how 
> you choose which type of product you're adding. You'll need to use that to 
> perform the check I just mentioned. Given the way the admin works now, 
> you'll also be able to remove BaseProduct from the ADMIN_MENU_ORDER setting 
> you have, since that's redundant.
>
>
>
>
>
> On Thu, Jan 26, 2017 at 1:22 AM, Pete Dermott  > wrote:
>
>> Apologies if this this an existing issue or I'm missing something but I 
>> am having a little trouble with my cartridge installation and my custom 
>> product types, I am running on the current versions of Mezzanine and 
>> Cartridge from the GitHub repos.
>>
>> Previously I have declared my custom product type in the settings.py file 
>> as follows:
>>
>> ADMIN_MENU_ORDER = (
>> ...
>> ("My Shop", (
>> "my_shop.BaseProduct",
>> )),
>>
>> ...
>>
>>
>> .. in my models as:
>>
>> from cartridge.shop.models import Product, Category, ProductVariation, 
>> ProductImage
>>
>>
>> ...
>>
>>
>> class BaseProduct(Product):
>> cadfile = fields.FileField(upload_to="product/cadfile", 
>> extensions=(".dwg",), blank=True, null=True, help_text="Format: Files should 
>> be named in all lower case with leading zeros and ONLY product codes e.g 
>> rg09.dwg")
>> pdffile = fields.FileField(upload_to="product/pdffile", blank=True, 
>> null=True, help_text="Format: Files should be named in all lower case with 
>> leading zeros and ONLY product codes e.g pm01.pdf")
>> product_code = models.CharField(max_length=8, help_text="Format: All 
>> caps, no spaces, include leading zero's, e.g DC01B")
>>
>> ...
>>
>>
>>
>> ... and in the admin as:
>>
>> from cartridge.shop.admin import CategoryAdmin, ProductAdmin, 
>> ProductVariation, ProductOption, Order
>>
>>
>> ...
>>
>>
>> class BaseProductAdmin(ProductAdmin):
>> fieldsets = product_fieldsets
>>
>> additional_fieldsets = ("product_height", "product_width", 
>> "product_projection", "product_diameter", "product_length",
>> "cornice_picture", "cornice_profile_picture", 
>> "cornice_wall_height",  "cornice_ceiling_projection",
>> "cornice_pattern_repeat", "internal_height", 
>> "internal_width", "priority",)
>>
>> fieldsets.append(
>> (_("Additional"), {
>> "fields": tuple(additional_fieldsets),
>> }))
>>
>> list_display = product_list_display
>> list_filter = ("status", "available", "categories", "product_type", 
>> "updated")
>>
>> 

Re: [mezzanine-users] [Cartridge] - Admin links to custom product type no longer work

2017-02-05 Thread Stephen McDonald
Hi there,

Subclassing the product model was previously not a supported feature - I
imagine you had to do some extensive hacking to get that working in the
actual site.

It now is a supported feature however, much like the Page model in
Mezzanine can be subclasses to create custom page types, custom products
now work the same in the development version of Cartridge.

The good news is that what you've done should mostly work now - it's just
that your existing products are missing a value that identifies them as
your BaseProduct custom product type - if you inspect the DB somehow,
you'll see the table for the Product model has a "content_type" field (if I
recall correctly), and it stores a string name for the type of product it's
related to, in your case I think the value would be "baseproduct", but the
best way to know for sure would be to add a new product of "BaseProduct"
type, and see what value gets stored for that.

BTW the redirection is occurring because with this new version, *all*
product subclasses in the admin will redirect to one listing page where
they all get managed. You'll see an "Add product" dropdown list (presumably
with only one item in it in your case, namely BaseProduct), which is how
you choose which type of product you're adding. You'll need to use that to
perform the check I just mentioned. Given the way the admin works now,
you'll also be able to remove BaseProduct from the ADMIN_MENU_ORDER setting
you have, since that's redundant.





On Thu, Jan 26, 2017 at 1:22 AM, Pete Dermott 
wrote:

> Apologies if this this an existing issue or I'm missing something but I am
> having a little trouble with my cartridge installation and my custom
> product types, I am running on the current versions of Mezzanine and
> Cartridge from the GitHub repos.
>
> Previously I have declared my custom product type in the settings.py file
> as follows:
>
> ADMIN_MENU_ORDER = (
> ...
> ("My Shop", (
> "my_shop.BaseProduct",
> )),
>
> ...
>
>
> .. in my models as:
>
> from cartridge.shop.models import Product, Category, ProductVariation, 
> ProductImage
>
>
> ...
>
>
> class BaseProduct(Product):
> cadfile = fields.FileField(upload_to="product/cadfile", 
> extensions=(".dwg",), blank=True, null=True, help_text="Format: Files should 
> be named in all lower case with leading zeros and ONLY product codes e.g 
> rg09.dwg")
> pdffile = fields.FileField(upload_to="product/pdffile", blank=True, 
> null=True, help_text="Format: Files should be named in all lower case with 
> leading zeros and ONLY product codes e.g pm01.pdf")
> product_code = models.CharField(max_length=8, help_text="Format: All 
> caps, no spaces, include leading zero's, e.g DC01B")
>
> ...
>
>
>
> ... and in the admin as:
>
> from cartridge.shop.admin import CategoryAdmin, ProductAdmin, 
> ProductVariation, ProductOption, Order
>
>
> ...
>
>
> class BaseProductAdmin(ProductAdmin):
> fieldsets = product_fieldsets
>
> additional_fieldsets = ("product_height", "product_width", 
> "product_projection", "product_diameter", "product_length",
> "cornice_picture", "cornice_profile_picture", 
> "cornice_wall_height",  "cornice_ceiling_projection",
> "cornice_pattern_repeat", "internal_height", 
> "internal_width", "priority",)
>
> fieldsets.append(
> (_("Additional"), {
> "fields": tuple(additional_fieldsets),
> }))
>
> list_display = product_list_display
> list_filter = ("status", "available", "categories", "product_type", 
> "updated")
>
> def has_module_permission(self, request):
> for (name, items) in settings.ADMIN_MENU_ORDER:
> if "stevensons_shop.BaseProduct" in items:
> return True
> return False
>
>
> admin.site.register(BaseProduct, BaseProductAdmin)
>
>
>
> This used to work fine in previous versions of the system (those installed
> directly from pip), however I wanted to take advantage of some of the fixes
> in newer versions.
>
> However this has had the adverse affect of breaking my admin area. Whereas
> before I could simply click on the "Base product" sidebar link and get
> taken to my admin view I now am immediately redirected to the generic
> /admin/shop/product view that only contains the basic information for my
> product and none of my extended fields, I'm aware that there have been some
> pretty major changes that happened in commit #8d3ac6b
> 
>  however
> I am currently at a loss trying to figure out what I need to do to get this
> working again.
>
> Any suggestions are greatly appreciated.
>
> --
> 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] [Cartridge] - Admin links to custom product type no longer work

2017-01-25 Thread Pete Dermott
Apologies if this this an existing issue or I'm missing something but I am 
having a little trouble with my cartridge installation and my custom 
product types, I am running on the current versions of Mezzanine and 
Cartridge from the GitHub repos.

Previously I have declared my custom product type in the settings.py file 
as follows:

ADMIN_MENU_ORDER = (
...
("My Shop", (
"my_shop.BaseProduct",
)),

...


.. in my models as:

from cartridge.shop.models import Product, Category, ProductVariation, 
ProductImage


...


class BaseProduct(Product):
cadfile = fields.FileField(upload_to="product/cadfile", 
extensions=(".dwg",), blank=True, null=True, help_text="Format: Files should be 
named in all lower case with leading zeros and ONLY product codes e.g rg09.dwg")
pdffile = fields.FileField(upload_to="product/pdffile", blank=True, 
null=True, help_text="Format: Files should be named in all lower case with 
leading zeros and ONLY product codes e.g pm01.pdf")
product_code = models.CharField(max_length=8, help_text="Format: All caps, 
no spaces, include leading zero's, e.g DC01B")

...



... and in the admin as:

from cartridge.shop.admin import CategoryAdmin, ProductAdmin, ProductVariation, 
ProductOption, Order


...


class BaseProductAdmin(ProductAdmin):
fieldsets = product_fieldsets

additional_fieldsets = ("product_height", "product_width", 
"product_projection", "product_diameter", "product_length",
"cornice_picture", "cornice_profile_picture", 
"cornice_wall_height",  "cornice_ceiling_projection",
"cornice_pattern_repeat", "internal_height", 
"internal_width", "priority",)

fieldsets.append(
(_("Additional"), {
"fields": tuple(additional_fieldsets),
}))

list_display = product_list_display
list_filter = ("status", "available", "categories", "product_type", 
"updated")

def has_module_permission(self, request):
for (name, items) in settings.ADMIN_MENU_ORDER:
if "stevensons_shop.BaseProduct" in items:
return True
return False


admin.site.register(BaseProduct, BaseProductAdmin)



This used to work fine in previous versions of the system (those installed 
directly from pip), however I wanted to take advantage of some of the fixes 
in newer versions.

However this has had the adverse affect of breaking my admin area. Whereas 
before I could simply click on the "Base product" sidebar link and get 
taken to my admin view I now am immediately redirected to the generic 
/admin/shop/product view that only contains the basic information for my 
product and none of my extended fields, I'm aware that there have been some 
pretty major changes that happened in commit #8d3ac6b 

 however 
I am currently at a loss trying to figure out what I need to do to get this 
working again.

Any suggestions are greatly appreciated.

-- 
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.