Git Product home page Git Product logo

django-lfs's Introduction

  • 👋 Hi, I’m @diefenbach
  • 👀 I’m interested in Python and Django
  • 🌱 I’m currently learning more English
  • 💞️ I’m looking to collaborate on cool stuff
  • 📫 How to reach me: @diefenbach on Twitter

django-lfs's People

Contributors

a8 avatar baffolobill avatar barttc avatar diefenbach avatar dnx avatar mindflayer avatar misaelnieto avatar mthornhill avatar naro avatar olimpiurob avatar pigletto avatar potar avatar prinzdezibel avatar restless avatar simahawk avatar suvit avatar vincic avatar voronind avatar wjarym avatar xentry avatar zagrebelin 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  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  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

django-lfs's Issues

bug in the save method in `lfs.addresses.utils`

#https://github.com/diefenbach/django-lfs/blob/master/lfs/addresses/utils.py#L134
...
self.address.country.code = self.data.get("%s-country" % self.type)
...

The address' country will not be changed. You need to assign new Country's instance for the purpose.

It's better to use `ugettext_` or even `pgettext_` instead of `gettext_`

.. and will replace it AFAP.

Sometimes I'm too lazy to make a translation 'by the rules' or need different meaning of a word in the context, so I insert the desired values directly in the code. In this case, I needed to make replacement of the Order States (https://github.com/diefenbach/django-lfs/blob/master/lfs/order/settings.py) and faced with UnicodeEncodeError Exception when I did it.

This is not quite a bug, but just in case.

when python bootstrap.py;AttributeError: 'NoneType' object has no attribute 'location'

ubuntu 12.10
guoff@guoff-SR18P:/下载/lfs-installer$ python bootstrap.py
Traceback (most recent call last):
File "bootstrap.py", line 69, in
ws.find(pkg_resources.Requirement.parse('setuptools')).location
AttributeError: 'NoneType' object has no attribute 'location'
guoff@guoff-SR18P:
/下载/lfs-installer$ python bootstrap.py
Traceback (most recent call last):
File "bootstrap.py", line 69, in
ws.find(pkg_resources.Requirement.parse('setuptools')).location
AttributeError: 'NoneType' object has no attribute 'location'

Decimal vs. Float Fields for Currency

I think it would be a better idea to change from FloatField to DecimalField for model price fields. Is this something that is planned or at least on the roadmap somewhere?

Live search shows non-active products/variants

The following should heal the problem:

diff --git a/lfs/search/views.py b/lfs/search/views.py
index 0934a39..5c64c81 100644
--- a/lfs/search/views.py
+++ b/lfs/search/views.py
@@ -31,7 +31,7 @@ def livesearch(request, template_name="lfs/search/livesearch_results.html"):
Q(sku_manufacturer__icontains=q) &
Q(sub_type__in=(STANDARD_PRODUCT, PRODUCT_WITH_VARIANTS, VARIANT))

'- temp = Product.objects.filter(query)
'+ temp = Product.objects.filter(query).filter(active=True)
total = len(temp)
products = temp[0:5]

VAT of Vouchers forgotten in total TAX

LFS 07.6 cart doesn't take into account VAT of Vouchers in total TAX.
I added in django_lfs-0.7.6-py2.7.egg/lfs/cart/views.py, a line 102, and Idem in django_lfs-0.7.6-py2.7.egg/lfs/checkout/views.py, a line 167 :
cart_tax = cart_tax - voucher_tax.

Circular import during migration to 0.8

Migrate from 0.7.7 to 0.8

python manage.py lfs_migrate

File "manage.py", line 11, in
execute_manager(settings)
File "/home/dimka/Dropbox/Work/dice64/env/local/lib/python2.7/site-packages/django/core/management/init.py", line 438, in execute_manager
utility.execute()
File "/home/dimka/Dropbox/Work/dice64/env/local/lib/python2.7/site-packages/django/core/management/init.py", line 379, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/dimka/Dropbox/Work/dice64/env/local/lib/python2.7/site-packages/django/core/management/init.py", line 261, in fetch_command
klass = load_command_class(app_name, subcommand)
File "/home/dimka/Dropbox/Work/dice64/env/local/lib/python2.7/site-packages/django/core/management/init.py", line 67, in load_command_class
module = import_module('%s.management.commands.%s' % (app_name, name))
File "/home/dimka/Dropbox/Work/dice64/env/local/lib/python2.7/site-packages/django/utils/importlib.py", line 35, in import_module
import(name)
File "/home/dimka/Dropbox/Repos/django-lfs/lfs/core/management/commands/lfs_migrate.py", line 16, in
from lfs.order.models import Order
File "/home/dimka/Dropbox/Repos/django-lfs/lfs/order/models.py", line 12, in
import lfs.payment.utils
File "/home/dimka/Dropbox/Repos/django-lfs/lfs/payment/utils.py", line 5, in
import lfs.core.utils
File "/home/dimka/Dropbox/Repos/django-lfs/lfs/core/utils.py", line 21, in
from lfs.core.models import Shop
File "/home/dimka/Dropbox/Repos/django-lfs/lfs/core/models.py", line 256, in
from monkeys import *
File "/home/dimka/Dropbox/Repos/django-lfs/lfs/core/monkeys.py", line 7, in
from lfs.cart import utils as cart_utils
File "/home/dimka/Dropbox/Repos/django-lfs/lfs/cart/utils.py", line 10, in
from lfs.payment import utils as payment_utils
ImportError: cannot import name utils

ls.cart.views.delete_cart_item security issue

There is a small security hole in ls.cart.views.delete_cart_item which allows any user to delete any user's cart items.
As of v.0.7.6, this view contains:

# begin issue
lfs_get_object_or_404(CartItem, pk=cart_item_id).delete()

cart = cart_utils.get_cart(request)
# end issue
cart_changed.send(cart, request=request)
return ...

So, no check is done to confirm that the item really belongs to the user who requested the view. A little rewrite will solve the issue:

# begin issue
cart = cart_utils.get_cart(request)
if not cart:
    raise Http404

item = lfs_get_object_or_404(CartItem, pk=cart_item_id)
if item.cart.id != cart.id:
    raise Http404
item.delete()
# end issue

cart_changed.send(cart, request=request)
return ...

As one may note, this will not affect speed.

Restock after cancelling an order

Hi,

when cancelling an order there should be a way to increase the stock_amount.
For some reasons (e.g. broken returns) this is not always wanted.

So maybe when cancelling the user should be given an opportunity to allow restocking the stock_amounts or not.

Also maybe changing the state from cancel to something else should be not allowed to keep the stock consistent.

Any input on this?

Rethinking the design decision on ordering custom address form fields?

Is there any specific reason that LFS chose "values_before_postal" and "values_after_postal" instead of a way to order the fields? For example, there could be a field attached to the class that orders the fields:

class MyAddress(BaseAddress):
field_order = ("firstname", "lastname", "email", "mobile")

Also the "+" system seems a bit odd. All of that should be handled by a templatetag to display the form fields rather than doing it through the form definition.

What are your thoughts on these design decisions?

Paypal integration can be broken due to bad user input

The function lfs.payment.utils.get_paypal_link_for_order() takes data directly from the order form that user filled in without proper URL encoding. If the user inputs characters like "#" or "&", this will potentially break the HTTP GET request to paypal.

Test case:

  • Configure LFS, Paypal and add products.
  • Add one product to cart and proceed to pay/checkout.
  • In the shipping address1 field write something "Calle 14 #2244".
  • Hit the "pay now" button.
  • Browser gets redirected to paypal, but it never gets to the payment page, instead is redirected to some other paypal page because the "#" character got in the middle of the GET URL and is being interpreted by the browser as an anchor.

Reason for cancellation

Hi again,

a way to store the reason of an order cancellation would be very nice.
So when changing the state of an order to cancel, maybe ask for a reason.

Thanks

Portlets templatetag throws AttributeError

Line 37 of lfs/portlet/templatetags/lfs_portlets_tags.py will throw an AttributeError if another app passes a 'category', 'product' or 'page' to context that does not have an 'id' attribute.

In our case, django-photologue is passing an int object as 'page' via the url /photos/gallery/page/1/.

We have applied a workaround to test for the id attribute...

    if instance is None or not hasattr(instance, 'id'):
        instance = lfs.core.utils.get_default_shop(request)

CSRF problem

Sometimes customers get CSRF error when adding a product to the cart or switching ordering on categories listing page.

The problem is caused by cached version of product_inline and other templates. product_inline caches generated HTML including csrf_token and if the token is changed on server for any reason, the cached HTML is not updated.

Related code: https://github.com/diefenbach/django-lfs/blob/master/lfs/catalog/views.py#L486
or https://github.com/diefenbach/django-lfs/blob/master/lfs/catalog/views.py#L365

The problem can appear everywhere full HTML including csrf_token is cached.

multi-product paypal invoice

multi-product paypal invoice is very useful : say you want to refund 1 product in a multi-product order

in /lfs-installer/eggs/django_lfs-0.7.7-py2.7.egg/lfs/payment/utils.py :

def get_paypal_link_for_order(order):
"""
Creates paypal link for given order.
"""
shop = lfs_get_object_or_404(Shop, pk=1)
current_site = Site.objects.get(id=settings.SITE_ID)
conv = locale.localeconv()
default_currency = conv['int_curr_symbol']

initial paypal dictionary

info = {
    "cmd": "_cart",
    "upload": "1",
    "business": settings.PAYPAL_RECEIVER_EMAIL,
    "currency_code": default_currency,
    "first_name": order.invoice_firstname,
    "last_name": order.invoice_lastname,
    "address_street": order.invoice_line1,
    "address_city": order.invoice_city,
    "address_state": order.invoice_state,
    "address_zip": order.invoice_code,
    "custom": order.uuid,
    "invoice": "w-%i" % order.number,
"ipn_notification_url": "http://boutique.belleetrebelle.ca/paypal/ipn/",#change to fit all
"return": "http://boutique.belleetrebelle.ca/thank-you",#change to fit all
"address_country": order.invoice_country,
    "shipping_1": order.shipping_price,
    "shipping_method": "postes canada",#change to fit all
}

add products to dictionary

index_item=0
for order_item in order.items.all():
    item = order.items.all().order_by('id')[index_item]
    index_item+=1
    info["item_name_%i" % index_item] = "%s" % item.product_name
    info["amount_%i" % index_item] = "%.2f" % item.product_price_net
    info["quantity_%i" % index_item] = "%i" % item.product_amount
    info["tax_%i" % index_item] = "%.2f" % item.product_tax
variant_index=0
    properties = item.product.get_variant_properties()
for d in properties:
    info["on%i_%i" % (variant_index, index_item)] = "%s" % d['name']
    info["os%i_%i" % (variant_index, index_item)] = "%s" % d['value']
    variant_index+=1

format dictionary for paypal

parameters = "&".join(["%s=%s" % (k, v) for (k, v) in info.items()])
if getattr(settings, 'PAYPAL_DEBUG', settings.DEBUG):
    url = SANDBOX_POSTBACK_ENDPOINT + "?" + parameters
else:
    url = POSTBACK_ENDPOINT + "?" + parameters

return url

it works for me, would need some adjusting to fit all ; test it on your side, make it better and available for everyone to make lfs better

thanks
Guillaume

sitemap.py and multi variant products

Sitemap which include multi_variant product lead to weakness SEO for the main product. In the best case (but not all cases) google robot will not index your multi variant products. can be check in tools for webmasters.
So I advice to change in sitemaps.py, line 19 : return Product.objects.filter(sub_type__in=[0,1], active='TRUE')
OR for having priority different for sub_type=0 and 1 :
class ProductSitemap0(Sitemap): with filter(sub_type=0, active='TRUE')
class ProductSitemap1(Sitemap): with filter(sub_type=1, active='TRUE')
and in urls.py : import both classes and : url(r'^sitemap.xml$', 'sitemap', {'sitemaps': {"products0": ProductSitemap0,"products1": ProductSitemap1, "categories": CategorySitemap, "pages": PageSitemap, "shop": ShopSitemap}})

Pierre

Minor bug in views in dropdown menu of multivariant product

Suppose you select "dropdown or select" menu for the type view of a multivariant product (instead of "List") in the /manage. In the front, when you select the first property, the second property is not set to "none" by default, and you can't select both property in the same time.
Example a T-shirt with two variants :
size L and only Red color
size X and only Green color.
You can not jump from one to another in the front LFS.

"tinyMCE is not defined" at 'Add Page' page

In the template: lfs/templates/manage/pages/add_page.html there is unnecessary statement:

tinyMCE.execCommand('mceAddControl', true, 'id_body');

that causes JavaScript error (visible at console).

Product with variants: Product-Property-Values can't be updated

Reproduct:

  • Create a product with variants
  • Create properties (local or global), does not matter
  • Change the property values of a specific variant and hit save

Expected:

  • The changed property value should be saved and displayed when page is reloaded

Result:

  • The original property value is displayed in select box, not the changed value.

serious bug in lfs_get_object_or_404 and lfs_get_object (cache related)

Lets assume I have next model:

class MyModel(...):
    slug = SlugField()
    active = BooleanField()

and I will do next:

def my_view(request, slug):
    obj = lfs_get_object_or_404(MyModel, slug=slug, active=True)

If a cache is disabled, nothing bad, or if only the slug is used to filter, otherwise, regardless of the value slug, lfs_get_object_or_404 will return the same value - the object to which the first time has been accessed, because the cache_key in this case always will be prefix-mymodel-True.

Sorry, but I'm too lazy to do a pull request, but here is my solution:

# lfs/caching/utils.py
def lfs_get_object_or_404(klass, *args, **kwargs):
    ...
    ck_kwargs = '-'.join(['%s|%s'%kw for kw in kwargs.items()]).lower()
    cache_key = "%s-%s-%s" % (settings.CACHE_MIDDLEWARE_KEY_PREFIX, klass.__name__.lower(), ck_kwargs)
    ...

Filtering customers in control panel by first and last name is broken

It looks like filtering customers is broken. The master branch shows that the filter code was commented out in lfs/manage/views/customers.py file on line ~350:

# Filter
name = customer_filters.get("name", "")
#if name != "":
#    f = Q(sa_object_id__lastname__icontains=name)
#    f |= Q(sa_object_id__firstname__icontains=name)
#    customers = customers.filter(f)

The issue here is that you cannot filter based on the sa_object_id.

My solution is to store the first and last name values in the Customer model in addition to storing that information in the generic address model. The first and last name values in the address should only be used when printing the invoice / packing slip because it is possible that the recipient has a different name than the customer account (for example, when sending a gift to a different person).

What are your thoughts on this solution?

cart and customer must be linked with session and be unique

Cart.session and Customer.session must be links to Session object.

  1. When sessions expired, delete Cart and Customer was deleted by default (make setting for this).
  2. ForeignKey created a db index on this field. Good for query optimization.
  3. And this field must be unique to disable situation with multiple cart and customer for one session.

'NoneType' object has no attribute 'get_absolute_url' Error

How to reproduce:

  • open an IE browser <=IE8
  • visit a product page
  • focus on the quantity field
  • click on "Enter" on your keyword

Certain explorer versions omits the u'add-to-cart' value from the request.
All fine with IE9 and Firefox.

Traceback:
AttributeError
'NoneType' object has no attribute 'get_absolute_url'
TRACEBACK:
File ".../eggs/Django-1.3.1-py2.6.egg/django/core/handlers/base.py", line 111, in get_response
response = callback(request, _callback_args, *_callback_kwargs)

File ".../django_lfs/lfs/catalog/views.py", line 608, in product_form_dispatcher
variant.get_absolute_url(),

re-assign customer.selected_shipping_method in one_page_checkout view

Let's assume a shipping method depends on some criteria (country, city, etc.). On the cart page customer has selected "method1", but on the checkout page some criteria has been changed (for example, country) and updated list of the shipping methods was loaded. The updated list doesn't contain the "method1" and none of the methods is selected. The customer doesn't select the new one method and press "submit order" button. There are two major bugs in this case:

  1. incorrect order total (order.price), because the old shipping method and shipping cost will be used for calculations;
  2. incorrect shipping method will be assigned to the order.

README in "rst" format

Hi all,
Since you have followed the markdown style, why still using README.txt rather than README.rst or README.md ?? Is there any technical reason that I'm missing?
This is also applied for other ".txt" files.

It looks more professional catches more attention..

evaluations but ("," or ".")

Hi,
I love the kit, but had a bug with evaluations giving me a incorect value because of a "," instead of a "." ; could it be a locale issue?

removed it for now...

Problem with user registration (long emails)

If customer registers using long e-mail (longer than 30) characters then his username and e-mail are truncated. This causes that user's login works (although is truncated) but e-mail addres is invalid.

why 'lfs.tagging.views.tag_products' is a public?

This method is too dangerous, it may be the cause of 503 error due to high server load.

def tag_products(request, source="description"):
    ...
        for product in Product.objects.all():
            parser.feed(product.description)
            Tag.objects.update_tags(product, "")

            data, amount = re.subn(r"[\W]*", "", parser.data)
            tags = re.split("\s*", data)
            for tag in tags:
                if tag:
                    Tag.objects.add_tag(product, tag)
    ...

I have 3500+ products with 50+ words in description. The above method hits db about 175'000 times per request. That's definitely must not be a public view.

update_cart_after_login fails if there are more than 1 product in the customer's cart

Exception:
MultipleObjectsReturned at /login
get() returned more than one CartItem -- it returned 6! Lookup parameters were {'product': <Product: Test1 (test1)>, 'cart': <Cart: admin, 40ab21c151c6084c5f6ed5ec102e9907>}

To reproduce:
0. create a configurable product X, eg one with different colors: blue, red, green

  1. log in to the shop
  2. add few versions of the X product to the cart (1 with blue, 1 with green, etc.)
  3. log out
  4. as anonymous user add product X to the cart
  5. try to log in

update_cart_after_login doesn't take into account that with configurable products it is possible that there are few instances of same 'Product' assigned to the cart

Wrong German translation

: templates/lfs/customer/base.html:23

msgid "Change addresses"
msgstr "Addressen ändern"

-> Should be: "Adressdaten ändern" or "Adresse ändern"

: templates/lfs/customer/base.html:17 templates/lfs/customer/password.html:50

msgid "Change password"
msgstr "Password ändern"

-> Should be: "Passwort ändern"

git cloning fails during buildout

hari@hariT410:/projects/lfs-buildout-development$ bin/buildout -v
Installing 'mr.developer'.
We have the best distribution that satisfies 'mr.developer'.
Picked: mr.developer = 1.21
mr.developer: Queued 'lfs' for checkout.
mr.developer: Queued 'lfs_bench' for checkout.
mr.developer: Queued 'lfs_contact' for checkout.
mr.developer: Queued 'lfs_order_numbers' for checkout.
mr.developer: Queued 'lfs_paypal' for checkout.
mr.developer: Queued 'lfs_rest' for checkout.
mr.developer: Queued 'lfs_theme' for checkout.
mr.developer: Queued 'portlets' for checkout.
mr.developer: Queued 'reviews' for checkout.
mr.developer: Cloned 'lfs' with git.
mr.developer: git cloning of 'lfs' failed.
mr.developer: Permission denied (publickey).
mr.developer: fatal: The remote end hung up unexpectedly
mr.developer:
mr.developer: Cloned 'lfs_bench' with git.
mr.developer: git cloning of 'lfs_bench' failed.
mr.developer: Permission denied (publickey).
mr.developer: fatal: The remote end hung up unexpectedly
mr.developer:
mr.developer: Cloned 'lfs_paypal' with git.
mr.developer: git cloning of 'lfs_paypal' failed.
mr.developer: Permission denied (publickey).
mr.developer: fatal: The remote end hung up unexpectedly
mr.developer:
mr.developer: Cloned 'lfs_contact' with git.
mr.developer: git cloning of 'lfs_contact' failed.
mr.developer: Permission denied (publickey).
mr.developer: fatal: The remote end hung up unexpectedly
mr.developer:
mr.developer: Cloned 'lfs_order_numbers' with git.
mr.developer: git cloning of 'lfs_order_numbers' failed.
mr.developer: Permission denied (publickey).
mr.developer: fatal: The remote end hung up unexpectedly
mr.developer:
mr.developer: There have been errors, see messages above.
hari@hariT410:/projects/lfs-buildout-development$

Circular import when loading module lfs.catalog

I was working on the last commit and there is a problem when i try to run "runserver", the error is "ImportError: no module named Product". The error is from commit 6f238ec from February 5th 2013. There where some changes at the caching module.

From catalog, caching.utils is imported and from caching.utils at listener.py lfs.catalog is imported but lfs.catalog was not loaded.

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.