Satchmo donations - python

Can anyone share some pointers on building a Donations module for Satchmo? I'm comfortable customizing Satchmo's product models etc but unable to find anything related to Donations
I realize it's possible to create a Donations virtual product but as far as I can tell this still requires setting the amount beforehand ($5, $10 etc). I want users to be able to donate arbitrary amounts

It looks like the satchmo_cart_details_query signal is the way to go about doing this. It allows you to add a price change value (in my case, donation amount) to a cart item
I'll post the full solution if anyone is interested

Related

Best way to grant access to users after they purchase something

I am building an e-learning platform using Django and as part of the platform one can buy online courses.
For each course I have a manytomany field of users and every time a user purchases a course I add them to the field.
Is this a good approach to give users access to the course? What would your approach be in this case?
Yes, it's the way I would go for it.
With such solution you can extend your manytomany table with fields like expiration date (so the users buy temporary access to the course), something like scope (so limit the user to just a part of a course) and you can e.g. group courses into packets and allow users to buy all of them.

How to declare New or Hot tag in E-Commerce product and after 15 days these tags will remove automatically

I am learning Django and creating an e-commerce site. I want to add a tag as ** new ** to my newly arrived products. This tag will be removed automatically after 5/7/15 or 30 days.
Also if any product has a big amount of discounts such as 30%, 40%, or more, these products will have a HOT tag automatically. The tag will be automatically removed when the offer expires.
Please let me know, how can I do these.
Thank you.
django by itself doesn't change the fields as you desire.
I think you should define task, which is responsible for checking the tag field of the model (that is boolean), and change it to False if it's for more than 30 days.
At first, you need to add tag and hot to your product model.
Then for creating a periodic task, you can use celery. It helps you to create a periodic task and easy to work with.
I think a daily task is suitable for your goal.
Then you can define another task for checking the hot field too.
maybe the following instruction will help you:
https://medium.com/#ksarthak4ever/django-handling-periodic-tasks-with-celery-daaa2a146f14

Sorted/searchable StackedInline options

I have three classes:
Person
Publication
AuthorOrder
Publication has a m2m field to Person through AuthorOrder. This is done to enable making it possible to set the order of authors, which matters for academic publications.
However, the list of Persons is getting long, and it would therefore be nice if it was searchable or at least sorted. However, if I use the obvious method of setting a Meta class to Person, this causes the Persons to be sorted everywhere, including where I don't want them to be.
Is there a way to make it searchable (best) or at least sorted without ruining the order elsewhere (ok)?
Looks like this:
There you go. This works well for us on several projects. https://github.com/and3rson/django-searchable-select

Django Oscar. How to add product?

I'm a beginner in Python and Django.
I have installed django-oscar. Then I Configured it and started the server, it works.
Now, I don't understand how to add a product?
At the dashboard there is a button Create new product. But in order to add new product it asks to select product class and I can not find any product class in the given dropdown options.
Provide me a demo example of how to add product in django-oscar.
You need to be logged in as a superuser and go to the store/dashboard URL
DO NOT ADMINISTER THIS FROM THE NORMAL DJANGO ADMIN CONSOLE (even though that answer was accepted?)
Here is an example of what this looks like in the included sandbox app
You need to add a category, product type, and partner and only then can you begin adding real products
Check out this commit - it hasn't been merged to the Oscar's master yet, but should give you an idea on how you can create products programmatically, for instance when importing data.
https://github.com/ArtS/django-oscar/blob/3f9abaf8d5c179c385b90dfa463a35ff9f92f73c/docs/source/recipes/importing_a_catalogue.rst
There is a separate page to administer product types, complete with a "Create new product type" button.
Using django-admin is not a good solution, you may be able to add product types and products through it, but you'll be missing out on any dashboard hooks into the normal process.
A look at the source code shows that whilst you may be able to add a product without a type (the FK is nullable), you may then experience other problems down the line as oscar expects only child products to have a null product_class.
#: None for child products, they inherit their parent's product class
product_class = models.ForeignKey(
'catalogue.ProductClass', null=True, on_delete=models.PROTECT,
verbose_name=_('Product Type'), related_name="products",
help_text=_("Choose what type of product this is"))
Definitely best to try to work with the system rather than around.
You have to add atleast one product class /admin/catalogue/productclass/

django admin - adding fields on the fly

Basically I am writing a simple shopping cart. Each item can have multiple prices. (i.e. shirts where each size is priced differently). I would like to have a single price field in my admin panel, where when the first price is entered, an additional price field pops up. However I am kind of at a loss as to how to do this. What would be the best way to do this?
Sounds like you want two related models - Item and Option. Item would contain the name of the item, and Option would contain the option - eg size - and the price of that option. You would then set up your admin to use an inline form for Option.
You probably want inlines and some javascript.
You might try checking out the Satchmo codebase. It has something similar that may provide some inspiration. http://satchmoproject.com

Categories

Resources