From a4c5d481591f09fd6f7558e2d76ef471e339b36a Mon Sep 17 00:00:00 2001 From: Skia Date: Thu, 1 Sep 2016 10:00:31 +0200 Subject: [PATCH] Some bug fixes --- counter/models.py | 2 +- counter/views.py | 2 +- subscription/models.py | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/counter/models.py b/counter/models.py index c9b23392..a08783b1 100644 --- a/counter/models.py +++ b/counter/models.py @@ -97,7 +97,7 @@ class Product(models.Model): """ Method to see if that object can be edited by the given user """ - if user.is_in_group(settings.SITH_GROUPS['accounting-admin']['name']): + if user.is_in_group(settings.SITH_GROUPS['accounting-admin']['name']) or user.is_in_group(settings.SITH_GROUPS['counter-admin']['name']): return True return False diff --git a/counter/views.py b/counter/views.py index dab11b89..e356bed3 100644 --- a/counter/views.py +++ b/counter/views.py @@ -42,7 +42,7 @@ class GetUserForm(forms.Form): cleaned_data = super(GetUserForm, self).clean() cus = None if cleaned_data['code'] != "": - cus = Customer.objects.filter(account_id=cleaned_data['code']).first() + cus = Customer.objects.filter(account_id__iexact=cleaned_data['code']).first() elif cleaned_data['id'] is not None: cus = Customer.objects.filter(user=cleaned_data['id']).first() sub = get_subscriber(cus.user) if cus is not None else None diff --git a/subscription/models.py b/subscription/models.py index bac0a929..5d85aa7e 100644 --- a/subscription/models.py +++ b/subscription/models.py @@ -38,8 +38,8 @@ class Subscriber(User): db.commit() except Exception as e: with open(settings.BASE_DIR+"/user_fail.log", "a") as f: - print("FAIL to add user %s (%s %s - %s) to old site" % (self.id, self.first_name, self.last_name, - self.email), file=f) + print("FAIL to add user %s (%s %s - %s) to old site" % (self.id, self.first_name.encode('utf-8'), + self.last_name.encode('utf-8'), self.email), file=f) print("Reason: %s" % (repr(e)), file=f) db.rollback()