Giter VIP home page Giter VIP logo

angvp / django-changuito Goto Github PK

View Code? Open in Web Editor NEW
50.0 50.0 22.0 115 KB

This is a fork of the fork of django-cart .. It reminds me this quote... http://www.youtube.com/watch?v=VkpjiohfmQU ... but if you abbandon a project is normal that this happens, many thanks to Bruno and the ppl that contributed on django-cart

License: GNU Lesser General Public License v3.0

Python 100.00%
cart django django-cart django-changuito e-commerce python

django-changuito's Introduction

Hola! 👋, my name is Ángel (ˈānjəl) Velásquez and here are some facts about me

  • I'm a Former Arch Linux Developer and Trusted User.
  • Also I have been contributor of couple of django packages, some known, some not that known.
  • Venezuelan by birth 🇻🇪 Argentinian by heart 🇦🇷 Canadian by choice 🇨🇦 .
  • I currently live in Calgary, Alberta, Canada 🇨🇦 🍁.
  • I can speak fluently Spanish, English and Italian.

Top Langs GitHub stats

You can find here configs of my tools and projects that I have worked on or that piqued my interest, feel free to contact me if you like any of my projects and want to collaborate in any of them.

Github

django-changuito's People

Contributors

angvp avatar bitdeli-chef avatar bmentges avatar cristianprieto avatar dfalk avatar eduardomiravalls avatar kamartem avatar maguayo avatar mapeveri avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

django-changuito's Issues

Cart does not link with new user

def new(self, request):
cart = models.Cart(creation_date=timezone.now())
cart.save()
request.session[CART_ID] = cart.id
return cart

Creating a new cart does not tie cart to a logged in user.
Initialization of CartProxy provides the necessary checks to see if user exists but the actual cart creation as shown above does not accommodate those options. Was this intentional or does the user have to implement it?

Update changuito to use Django 3.0

There's a branch with initial work where tests pass feature/upgrade-django3.0 but need to be tested .. and more unit tests should be added

  • Upgrade Travis config
  • Upgrade tox config
  • Add more tests to proxy.py
  • Add more tests to the middleware
  • Add tests to signal actually 0% coverage
  • Doing some functional test of the app
  • Create a sample project and test it works

For checking coverage: https://coveralls.io/github/angvp/django-changuito?branch=feature/upgrade-django3.0

Custom cart item fields

Greetings!
Trying to use your cart module and have a question.
How it would be better if I want to add my custom fields (e.g. color, or type) for cart items?
Can I somehow correctly inherit Item model or maybe there another way of doing that?
Thank you!

For now, I've forked module and added new CharField into it - https://github.com/amureki/django-changuito
But maybe there is an easier way?

Django 1.4.4 support

Can I use this with Django 1.4.4 since the prereq said 1.5+?
Looking through the source code it seems compatible?

Possible pull request

Hi there!

We have developed an extension of changuito to avoid create your own cart inheriting from a BaseCart.
You can check it here.
If you are interested in merge it perfect!

Index Fields For Database Performance #enhancement

A good rule of thumb is to apply db_index=True to fields that would be filtered or ordered in some way. This may be limited by the database engine used; however, maybe this should be recommended in the readMe for users of django-changuito for those at least using postgres or mysql.

" Models aren't loaded yet" error issued when I try to run migrate or syncdb

Traceback (most recent call last):
      File "manage.py", line 10, in <module>
        execute_from_command_line(sys.argv)
      File "/home/sid/.virtualenvs/temp/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 338, in execute_from_command_line
        utility.execute()
      File "/home/sid/.virtualenvs/temp/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 312, in execute
        django.setup()
      File "/home/sid/.virtualenvs/temp/local/lib/python2.7/site-packages/django/__init__.py", line 18, in setup
        apps.populate(settings.INSTALLED_APPS)
      File "/home/sid/.virtualenvs/temp/local/lib/python2.7/site-packages/django/apps/registry.py", line 85, in populate
        app_config = AppConfig.create(entry)
      File "/home/sid/.virtualenvs/temp/local/lib/python2.7/site-packages/django/apps/config.py", line 86, in create
        module = import_module(entry)
      File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
        __import__(name)
      File "/home/sid/.virtualenvs/temp/local/lib/python2.7/site-packages/changuito/__init__.py", line 1, in <module>
        from proxy import CartProxy, ItemAlreadyExists, ItemDoesNotExist
      File "/home/sid/.virtualenvs/temp/local/lib/python2.7/site-packages/changuito/proxy.py", line 3, in <module>
        import models
      File "/home/sid/.virtualenvs/temp/local/lib/python2.7/site-packages/changuito/models.py", line 7, in <module>
        User = get_user_model()
      File "/home/sid/.virtualenvs/temp/local/lib/python2.7/site-packages/django/contrib/auth/__init__.py", line 150, in get_user_model
        return django_apps.get_model(settings.AUTH_USER_MODEL)
      File "/home/sid/.virtualenvs/temp/local/lib/python2.7/site-packages/django/apps/registry.py", line 199, in get_model
        self.check_models_ready()
      File "/home/sid/.virtualenvs/temp/local/lib/python2.7/site-packages/django/apps/registry.py", line 131, in check_models_ready
        raise AppRegistryNotReady("Models aren't loaded yet.")
    django.core.exceptions.AppRegistryNotReady: Models aren't loaded yet.

I've installed the app but unable go beyond this point. Any ideas on what could be going wrong here ?

Add modified date to items model #enhancement

I realize that changuito is covering generic cases and is supposed to be flexible; however, it still may be important to have a modified date for each item in the model by default.

Case Study:

I have been customizing changuito to drive bidding for a auction platform [a very complex system depending on the type of auction (ie. auction theory and its algorithms and special cases). ] and bidders may be allowed to lower or raise bids. However, ties may occur in bidding and knowing the modification date of the item can prove useful for updating the under bidder, for example.

Just a thought

Triggers django.core.exceptions.AppRegistryNotReady on Django 1.7

I'm getting the following stack trace when attempting to syncdb, migrate or runserver with changuito in the INSTALLED_APPS list.

python manage.py syncdb
Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/home/adamgriffiths/.anaconda/envs/bs_jobs/lib/python2.7/site-packages/django/core/management/__init__.py", line 385, in execute_from_command_line
    utility.execute()
  File "/home/adamgriffiths/.anaconda/envs/bs_jobs/lib/python2.7/site-packages/django/core/management/__init__.py", line 354, in execute
    django.setup()
  File "/home/adamgriffiths/.anaconda/envs/bs_jobs/lib/python2.7/site-packages/django/__init__.py", line 21, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/home/adamgriffiths/.anaconda/envs/bs_jobs/lib/python2.7/site-packages/django/apps/registry.py", line 85, in populate
    app_config = AppConfig.create(entry)
  File "/home/adamgriffiths/.anaconda/envs/bs_jobs/lib/python2.7/site-packages/django/apps/config.py", line 87, in create
    module = import_module(entry)
  File "/home/adamgriffiths/.anaconda/envs/bs_jobs/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
  File "/home/adamgriffiths/.anaconda/envs/bs_jobs/lib/python2.7/site-packages/changuito/__init__.py", line 1, in <module>
    from proxy import CartProxy, ItemAlreadyExists, ItemDoesNotExist
  File "/home/adamgriffiths/.anaconda/envs/bs_jobs/lib/python2.7/site-packages/changuito/proxy.py", line 3, in <module>
    import models
  File "/home/adamgriffiths/.anaconda/envs/bs_jobs/lib/python2.7/site-packages/changuito/models.py", line 7, in <module>
    User = get_user_model()
  File "/home/adamgriffiths/.anaconda/envs/bs_jobs/lib/python2.7/site-packages/django/contrib/auth/__init__.py", line 136, in get_user_model
    return django_apps.get_model(settings.AUTH_USER_MODEL)
  File "/home/adamgriffiths/.anaconda/envs/bs_jobs/lib/python2.7/site-packages/django/apps/registry.py", line 199, in get_model
    self.check_models_ready()
  File "/home/adamgriffiths/.anaconda/envs/bs_jobs/lib/python2.7/site-packages/django/apps/registry.py", line 131, in check_models_ready
    raise AppRegistryNotReady("Models aren't loaded yet.")
django.core.exceptions.AppRegistryNotReady: Models aren't loaded yet.

This is reproducible using 1.7 and running runtests.py

This stackoverflow question suggests that the method of importing the User model needs to be different for 1.7
https://stackoverflow.com/questions/25537905/django-1-7-throws-django-core-exceptions-appregistrynotready-models-arent-load

The following fork has a fix for this issue. I've run the tests and they are working:
https://github.com/bender314/django-changuito

Timezone support

Hi,

I'm migrating from django-cart to django-changuito. It works really well! =)

I've noticed that during my tests i get lots of warnings because of the lack of timezone support. The same happened to django-cart. It seems a pull request was made to address that, but it was not merged yet. Here: bmentges/django-cart#5

Would be nice to see it fixed in changuito.

Thanks!

checkout()

What does the function checkout() do? What is it supposed to be used for?

CartProxy instance has no attribute 'remove'

When calling your removal example:

def remove_from_cart(request, product_id):
product = Product.objects.get(id=product_id)
cart = request.cart 
cart.remove(product)

I will get a CartProxy instance has no attribute 'remove' error.

Looking through your code, I've found cart.remove_item(item) where item is the pk of your internal element. The only way I can see so for to obtain this pk is to iterate over all cart objects and to compare with the object in request:

article = Artikel.objects.get(id=article_id)
for e in request.cart:
    if e.product == article:
        request.cart.remove_item(e.pk)

Firstly, this doesn't follow your example at all, hence this bug addresses a documentation bug. Secondly, this is a feature request to implement the remove method described in this example.

Checked out cart can be returned for non Anonymous users

I have found that CartProxy can return an already checked out cart for a non Anonymous user, and I believe it's a bug.

This is how I would solve it:

diff --git a/changuito/proxy.py b/changuito/proxy.py
index 90f45f5..ca86bee 100644
--- a/changuito/proxy.py
+++ b/changuito/proxy.py
@@ -38,7 +38,7 @@ class CartProxy:
         #First search by user
         if not user.is_anonymous():
             try:
-                cart = models.Cart.objects.get(user=user)
+                cart = models.Cart.objects.get(user=user, checked_out=False)
             except models.Cart.DoesNotExist:
                 cart = self.new(request, user=user)
             self.cart = cart

If that is the intended behavior, would you kindly explain it?


On the other hand, I would refactor the whole __init__ method:

diff --git a/changuito/proxy.py b/changuito/proxy.py
index 90f45f5..055514a 100644
--- a/changuito/proxy.py
+++ b/changuito/proxy.py
@@ -35,24 +35,19 @@ class UserDoesNotExist(Exception):
 class CartProxy:
     def __init__(self, request):
         user = request.user
-        #First search by user
-        if not user.is_anonymous():
-            try:
-                cart = models.Cart.objects.get(user=user)
-            except models.Cart.DoesNotExist:
-                cart = self.new(request, user=user)
-            self.cart = cart
-        #If not, search by request id
-        else:
-            cart_id = request.session.get(CART_ID)
-            if cart_id:
-                try:
-                    cart = models.Cart.objects.get(id=cart_id, checked_out=Fals
-                except models.Cart.DoesNotExist:
-                    cart = self.new(request)
+        try:
+            #First search by user
+            if not user.is_anonymous():
+                cart = models.Cart.objects.get(user=user, checked_out=False)
+            #If not, search by request id
             else:
-                cart = self.new(request)
-            self.cart = cart
+                user = None
+                cart_id = request.session.get(CART_ID)
+                cart = models.Cart.objects.get(id=cart_id, checked_out=False)
+        except:
+            cart = self.new(request, user=user)
+
+        self.cart = cart

     def __iter__(self):
         for item in self.cart.item_set.all():

Thoughts?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.