From 82e872dfd31d82e795442372c3e316558cf3d3ce Mon Sep 17 00:00:00 2001 From: Albert O'Connor Date: Thu, 31 Jul 2014 06:42:27 -0400 Subject: [PATCH 1/5] Allow css classes to come from self.attrs without being overwritten. --- zebra/widgets.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/zebra/widgets.py b/zebra/widgets.py index d3eaa98..7953063 100644 --- a/zebra/widgets.py +++ b/zebra/widgets.py @@ -5,14 +5,23 @@ class NoNameWidget(object): def _update_to_noname_class_name(self, name, kwargs_dict): + name_class = name.replace("_", "-") + + current_classes = '' + if "class" in self.attrs: + current_classes = self.attrs["class"] + if "attrs" in kwargs_dict: if "class" in kwargs_dict["attrs"]: - kwargs_dict["attrs"]["class"] += " %s" % (name.replace("_", "-"), ) + kwargs_dict["attrs"]["class"] += (" %s" % name.replace("_", "-")) else: kwargs_dict["attrs"].update({'class': name.replace("_", "-")}) else: kwargs_dict["attrs"] = {'class': name.replace("_", "-")} + if current_classes != '': + kwargs_dict["attrs"]["class"] += ' %s' % current_classes + return kwargs_dict def _strip_name_attr(self, widget_string, name): From cf3907cca7dd138acb03a9caf37e582aace0c091 Mon Sep 17 00:00:00 2001 From: albertoconnor Date: Wed, 20 Jul 2016 22:44:18 -0400 Subject: [PATCH 2/5] Update forms.py --- zebra/forms.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/zebra/forms.py b/zebra/forms.py index 0041320..ff3057a 100644 --- a/zebra/forms.py +++ b/zebra/forms.py @@ -2,6 +2,8 @@ from django.core.exceptions import NON_FIELD_ERRORS from django.utils.dates import MONTHS +from six import iteritems + from zebra.conf import options from zebra.widgets import NoNameSelect, NoNameTextInput @@ -23,7 +25,7 @@ def __init__(self, *args, **kwargs): self.fields['card_cvv'].label = "Card CVC" self.fields['card_cvv'].help_text = "Card Verification Code; see rear of card." months = [ (m[0], u'%02d - %s' % (m[0], unicode(m[1]))) - for m in sorted(MONTHS.iteritems()) ] + for m in sorted(iteritems(MONTHS)) ] self.fields['card_expiry_month'].choices = months card_number = forms.CharField(required=False, max_length=20, @@ -31,6 +33,6 @@ def __init__(self, *args, **kwargs): card_cvv = forms.CharField(required=False, max_length=4, widget=NoNameTextInput()) card_expiry_month = forms.ChoiceField(required=False, widget=NoNameSelect(), - choices=MONTHS.iteritems()) + choices=iteritems(MONTHS)) card_expiry_year = forms.ChoiceField(required=False, widget=NoNameSelect(), choices=options.ZEBRA_CARD_YEARS_CHOICES) From 09f68975bd4a86aa76cfb7d8abede54ba1e0aa38 Mon Sep 17 00:00:00 2001 From: amjoconn Date: Wed, 20 Jul 2016 23:40:50 -0400 Subject: [PATCH 3/5] Update zebra_tags.py --- zebra/templatetags/zebra_tags.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zebra/templatetags/zebra_tags.py b/zebra/templatetags/zebra_tags.py index 60db3d7..1f9d3f6 100644 --- a/zebra/templatetags/zebra_tags.py +++ b/zebra/templatetags/zebra_tags.py @@ -15,7 +15,7 @@ def _set_up_zebra_form(context): if "form" in context: context["zebra_form"] = context["form"] else: - raise Exception, "Missing stripe form." + raise Exception("Missing stripe form.") context["STRIPE_PUBLISHABLE"] = options.STRIPE_PUBLISHABLE return context From 9fc8542072927a0e9ae1f706f4c0864e49202de3 Mon Sep 17 00:00:00 2001 From: albertoconnor Date: Wed, 20 Jul 2016 23:42:08 -0400 Subject: [PATCH 4/5] Update zebra_tags.py --- zebra/templatetags/zebra_tags.py | 1 - 1 file changed, 1 deletion(-) diff --git a/zebra/templatetags/zebra_tags.py b/zebra/templatetags/zebra_tags.py index 1f9d3f6..e09cb25 100644 --- a/zebra/templatetags/zebra_tags.py +++ b/zebra/templatetags/zebra_tags.py @@ -1,7 +1,6 @@ from django.core.urlresolvers import reverse from django import template from django.template.loader import render_to_string -from django.utils.encoding import force_unicode from django.utils.safestring import mark_safe from django.utils.translation import ugettext as _ From c1454e2a104183662a3b0c7fc4d295bf273970d5 Mon Sep 17 00:00:00 2001 From: Albert O'Connor Date: Thu, 21 Jul 2016 09:23:03 -0400 Subject: [PATCH 5/5] Remove unicode --- zebra/forms.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zebra/forms.py b/zebra/forms.py index ff3057a..b49a87d 100644 --- a/zebra/forms.py +++ b/zebra/forms.py @@ -24,7 +24,7 @@ def __init__(self, *args, **kwargs): super(StripePaymentForm, self).__init__(*args, **kwargs) self.fields['card_cvv'].label = "Card CVC" self.fields['card_cvv'].help_text = "Card Verification Code; see rear of card." - months = [ (m[0], u'%02d - %s' % (m[0], unicode(m[1]))) + months = [ (m[0], u'%02d - %s' % (m[0], str(m[1]))) for m in sorted(iteritems(MONTHS)) ] self.fields['card_expiry_month'].choices = months