Kaynağa Gözat

Fixed encoding issue with address hashing

master
David Winterbottom 14 yıl önce
ebeveyn
işleme
83102f9289

+ 1
- 1
oscar/apps/address/abstract_models.py Dosyayı Görüntüle

@@ -86,7 +86,7 @@ class AbstractAddress(models.Model):
86 86
         
87 87
     def salutation(self):
88 88
         u"""Returns the salutation"""
89
-        return " ".join([part for part in [self.title, self.first_name, self.last_name] if part])
89
+        return u" ".join([part for part in [self.title, self.first_name, self.last_name] if part])
90 90
         
91 91
     def __unicode__(self):
92 92
         return self.summary

+ 7
- 0
oscar/apps/address/tests.py Dosyayı Görüntüle

@@ -1,3 +1,5 @@
1
+# -*- coding: utf-8 -*-
2
+
1 3
 from django.contrib.auth.models import User
2 4
 from django.test import TestCase
3 5
 
@@ -60,4 +62,9 @@ class UserAddressTest(TestCase):
60 62
         a2 = UserAddress(first_name=" Terry", last_name='   Barrington', line1="  75 Smith Road  ", postcode="N4 8ty", 
61 63
                          country=self.country, user=self.user)
62 64
         self.assertEquals(a1.generate_hash(), a2.generate_hash())
65
+        
66
+    def test_hashing_with_utf8(self):
67
+        a = UserAddress(first_name=u"\u0141ukasz Smith", last_name=u'Smith', line1=u"75 Smith Road", postcode=u"n4 8ty", 
68
+                        country=self.country, user=self.user)
69
+        hash = a.active_address_fields()
63 70
            

+ 5
- 3
oscar/apps/basket/factory.py Dosyayı Görüntüle

@@ -27,9 +27,9 @@ class BasketFactory(object):
27 27
         return self._get_or_create_cookie_basket(request, response, 
28 28
                                                  COOKIE_KEY_SAVED_BASKET, Basket.saved)
29 29
     
30
-    def get_open_basket(self, request, response):
30
+    def get_open_basket(self, request):
31 31
         u"""Returns the basket for the current user"""
32
-        return self._get_basket(request, response, COOKIE_KEY_OPEN_BASKET, Basket.open)
32
+        return self._get_basket(request, None, COOKIE_KEY_OPEN_BASKET, Basket.open)
33 33
     
34 34
     def get_saved_basket(self, request, response):
35 35
         u"""Returns the saved basket for the current user"""
@@ -92,7 +92,9 @@ class BasketFactory(object):
92 92
                     b = manager.get(pk=basket_id, owner=None)
93 93
                 except Basket.DoesNotExist:
94 94
                     b = None
95
-            else:
95
+            elif response:
96
+                # Not all methods are able to pass the response so this doesn't
97
+                # always happen.
96 98
                 response.delete_cookie(cookie_key)
97 99
         return b      
98 100
     

+ 1
- 1
oscar/apps/customer/templatetags/history_tags.py Dosyayı Görüntüle

@@ -17,5 +17,5 @@ def recently_viewed_products(context):
17 17
     
18 18
     # Reordering as the id order gets messed up in the query
19 19
     product_ids.reverse()
20
-    products = [product_dict[id] for id in product_ids]
20
+    products = [product_dict[id] for id in product_ids if id in product_dict]
21 21
     return {'products': products}

Loading…
İptal
Kaydet