Commits

Ian George committed 795a47e

Added NOTIFY option in settings, configured same as ADMINS for notification emails (contact, order etc.)
Added international config option to shop and used option in shop.forms.order to add the country field if required

  • Participants
  • Parent commits d831018

Comments (0)

Files changed (3)

quiet/common/emails.py

     subject = context['subject']
     del context['subject']
     body = render_to_string(template, context)
+    if hasattr(settings, "NOTIFY"):
+        recip = [admin[1] for admin in settings.NOTIFY]
+    else:
+        recip = [admin[1] for admin in settings.ADMINS]
+        
     send_mail(
         subject,
         body,
         settings.PUBLIC_FROM_EMAIL,
-        [admin[1] for admin in settings.ADMINS],
+        recip,
         fail_silently=True)
     #put things back as we found them
     context['subject'] = subject

quiet/shop/config.py

     vat_rate = conf.ConfigDecimal(0.2, description='Current UK VAT Rate')
     vat_include = conf.ConfigBoolean(False, description='Prices include VAT')
     vat_show = conf.ConfigBoolean(True, description='Show VAT in basket and checkout')
+    international = conf.ConfigBoolean(False, description='Allow international orders')

quiet/shop/forms/order.py

 from form_utils.forms import BetterForm
 from quiet.common.countries import COUNTRIES
 
+from quiet.common.conf import config
+
 class OrderForm(BetterForm):
 #    def __init__(self, gift_certificate=False, *args, **kwargs):
 #        super(OrderForm, self).__init__(*args, **kwargs)
     address3 = forms.CharField(required=False, label="Address 3")
     city = forms.CharField(label="City")
     county = forms.CharField(required=False, label="County")
-    country = forms.ChoiceField(label="Country", choices=COUNTRIES, initial="GBR")
+    if config.shop.international:
+        country = forms.ChoiceField(label="Country", choices=COUNTRIES, initial="GBR")
     postcode = forms.RegexField(label="Postcode", regex=r'^(([Gg][Ii][Rr] 0[Aa]{2})|((([A-Za-z][0-9]{1,2})|(([A-Za-z][A-Ha-hJ-Yj-y][0-9]{1,2})|(([A-Za-z][0-9][A-Za-z])|([A-Za-z][A-Ha-hJ-Yj-y][0-9]?[A-Za-z])))) [0-9][A-Za-z]{2}))$', max_length=10, error_message=("Please enter a valid UK postcode")) 
 
     delivery_telephone = forms.CharField(required=False, label="Telephone")
     delivery_address3 = forms.CharField(required=False, label="Address 3")
     delivery_city = forms.CharField(required=False, label="City")
     delivery_county = forms.CharField(required=False, label="County")
-    delivery_country = forms.ChoiceField(label="Country", choices=COUNTRIES, initial="GBR")
+    if config.shop.international:
+        delivery_country = forms.ChoiceField(label="Country", choices=COUNTRIES, initial="GBR")
     delivery_postcode = forms.RegexField(required=False, label="Postcode", regex=r'^(([Gg][Ii][Rr] 0[Aa]{2})|((([A-Za-z][0-9]{1,2})|(([A-Za-z][A-Ha-hJ-Yj-y][0-9]{1,2})|(([A-Za-z][0-9][A-Za-z])|([A-Za-z][A-Ha-hJ-Yj-y][0-9]?[A-Za-z])))) [0-9][A-Za-z]{2}))$', max_length=10, error_message=("Please enter a valid UK postcode")) 
 
     #def clean(self):