Merge remote-tracking branch 'mainRepo/master'
This commit is contained in:
commit
7d22086677
8 changed files with 239 additions and 72 deletions
|
@ -31,9 +31,10 @@ class ContactView(FormView):
|
||||||
return context
|
return context
|
||||||
|
|
||||||
def form_valid(self, form):
|
def form_valid(self, form):
|
||||||
form.save()
|
print("alplora contactusform")
|
||||||
form.send_email(email_to='info@alplora.ch')
|
#form.save()
|
||||||
messages.add_message(self.request, messages.SUCCESS, self.success_message)
|
#form.send_email(email_to='info@alplora.ch')
|
||||||
|
#messages.add_message(self.request, messages.SUCCESS, self.success_message)
|
||||||
return render(self.request, 'alplora/contact_success.html', {})
|
return render(self.request, 'alplora/contact_success.html', {})
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -63,23 +63,23 @@ class ContactUsView(FormView):
|
||||||
)
|
)
|
||||||
|
|
||||||
def form_valid(self, form):
|
def form_valid(self, form):
|
||||||
form.save()
|
#form.save()
|
||||||
from_emails = {
|
#from_emails = {
|
||||||
'glasfaser': 'glasfaser@ungleich.ch'
|
# 'glasfaser': 'glasfaser@ungleich.ch'
|
||||||
}
|
#}
|
||||||
from_page = self.request.POST.get('from_page')
|
#from_page = self.request.POST.get('from_page')
|
||||||
email_data = {
|
#email_data = {
|
||||||
'subject': "{dcl_text} Message from {sender}".format(
|
# 'subject': "{dcl_text} Message from {sender}".format(
|
||||||
dcl_text=settings.DCL_TEXT,
|
# dcl_text=settings.DCL_TEXT,
|
||||||
sender=form.cleaned_data.get('email')
|
# sender=form.cleaned_data.get('email')
|
||||||
),
|
# ),
|
||||||
'from_email': settings.DCL_SUPPORT_FROM_ADDRESS,
|
# 'from_email': settings.DCL_SUPPORT_FROM_ADDRESS,
|
||||||
'to': [from_emails.get(from_page, 'support@ungleich.ch')],
|
# 'to': [from_emails.get(from_page, 'support@ungleich.ch')],
|
||||||
'body': "\n".join(
|
# 'body': "\n".join(
|
||||||
["%s=%s" % (k, v) for (k, v) in form.cleaned_data.items()]),
|
# ["%s=%s" % (k, v) for (k, v) in form.cleaned_data.items()]),
|
||||||
'reply_to': [form.cleaned_data.get('email')],
|
# 'reply_to': [form.cleaned_data.get('email')],
|
||||||
}
|
#}
|
||||||
send_plain_email_task.delay(email_data)
|
#send_plain_email_task.delay(email_data)
|
||||||
if self.request.is_ajax():
|
if self.request.is_ajax():
|
||||||
return self.render_to_response(
|
return self.render_to_response(
|
||||||
self.get_context_data(success=True, contact_form=form))
|
self.get_context_data(success=True, contact_form=form))
|
||||||
|
|
|
@ -835,9 +835,10 @@ class ContactView(FormView):
|
||||||
success_message = _('Message Successfully Sent')
|
success_message = _('Message Successfully Sent')
|
||||||
|
|
||||||
def form_valid(self, form):
|
def form_valid(self, form):
|
||||||
form.save()
|
print("digital glarus contactusform")
|
||||||
form.send_email()
|
#form.save()
|
||||||
messages.add_message(self.request, messages.SUCCESS, self.success_message)
|
#form.send_email()
|
||||||
|
#messages.add_message(self.request, messages.SUCCESS, self.success_message)
|
||||||
return super(ContactView, self).form_valid(form)
|
return super(ContactView, self).form_valid(form)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -56,6 +56,9 @@ dotenv.load_dotenv("{0}/.env".format(PROJECT_DIR))
|
||||||
|
|
||||||
from multisite import SiteID
|
from multisite import SiteID
|
||||||
|
|
||||||
|
RECAPTCHA_PUBLIC_KEY = env('RECAPTCHA_PUBLIC_KEY')
|
||||||
|
RECAPTCHA_PRIVATE_KEY = env('RECAPTCHA_PRIVATE_KEY')
|
||||||
|
|
||||||
UNGLEICH_BLOG_SITE_ID = int_env("UNGLEICH_BLOG_SITE_ID")
|
UNGLEICH_BLOG_SITE_ID = int_env("UNGLEICH_BLOG_SITE_ID")
|
||||||
SITE_ID = SiteID(default=(UNGLEICH_BLOG_SITE_ID if
|
SITE_ID = SiteID(default=(UNGLEICH_BLOG_SITE_ID if
|
||||||
UNGLEICH_BLOG_SITE_ID > 0 else 1))
|
UNGLEICH_BLOG_SITE_ID > 0 else 1))
|
||||||
|
@ -125,6 +128,7 @@ INSTALLED_APPS = (
|
||||||
'djangocms_file',
|
'djangocms_file',
|
||||||
'djangocms_picture',
|
'djangocms_picture',
|
||||||
'djangocms_video',
|
'djangocms_video',
|
||||||
|
'django_recaptcha',
|
||||||
# 'djangocms_flash',
|
# 'djangocms_flash',
|
||||||
# 'djangocms_googlemap',
|
# 'djangocms_googlemap',
|
||||||
# 'djangocms_inherit',
|
# 'djangocms_inherit',
|
||||||
|
|
144
hosting/management/commands/change_ch_vatrate_2023.py
Normal file
144
hosting/management/commands/change_ch_vatrate_2023.py
Normal file
|
@ -0,0 +1,144 @@
|
||||||
|
from django.core.management.base import BaseCommand
|
||||||
|
import datetime
|
||||||
|
import csv
|
||||||
|
import logging
|
||||||
|
import stripe
|
||||||
|
from hosting.models import VATRates
|
||||||
|
from utils.hosting_utils import get_vat_rate_for_country
|
||||||
|
from django.conf import settings
|
||||||
|
from membership.models import CustomUser, StripeCustomer
|
||||||
|
|
||||||
|
stripe.api_key = settings.STRIPE_API_PRIVATE_KEY
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
class Command(BaseCommand):
|
||||||
|
help = '''CH vat rate changes on 2024-01-01 from 7.7% to 8.1%. This commands makes the necessary changes'''
|
||||||
|
|
||||||
|
def handle(self, *args, **options):
|
||||||
|
MAKE_MODIFS=False
|
||||||
|
try:
|
||||||
|
country_to_change = 'CH'
|
||||||
|
currency_to_change = 'CHF'
|
||||||
|
new_rate = 0.081
|
||||||
|
user_country_vat_rate = get_vat_rate_for_country(country_to_change)
|
||||||
|
logger.debug("Existing VATRate for %s %s " % (country_to_change, user_country_vat_rate))
|
||||||
|
vat_rate = VATRates.objects.get(
|
||||||
|
territory_codes=country_to_change, start_date__isnull=False, stop_date=None
|
||||||
|
)
|
||||||
|
logger.debug("VAT rate for %s is %s" % (country_to_change, vat_rate.rate))
|
||||||
|
logger.debug("vat_rate object = %s" % vat_rate)
|
||||||
|
logger.debug("Create end date for the VATRate %s" % vat_rate.id)
|
||||||
|
if MAKE_MODIFS:
|
||||||
|
vat_rate.stop_date = datetime.date(2023, 12, 31)
|
||||||
|
vat_rate.save()
|
||||||
|
print("Creating a new VATRate for CH")
|
||||||
|
obj, created = VATRates.objects.get_or_create(
|
||||||
|
start_date=datetime.date(2024, 1, 1),
|
||||||
|
stop_date=None,
|
||||||
|
territory_codes=country_to_change,
|
||||||
|
currency_code=currency_to_change,
|
||||||
|
rate=new_rate,
|
||||||
|
rate_type="standard",
|
||||||
|
description="Switzerland standard VAT (added manually on %s)" % datetime.datetime.now()
|
||||||
|
)
|
||||||
|
if created:
|
||||||
|
logger.debug("Created new VAT Rate for %s with the new rate %s" % (country_to_change, new_rate))
|
||||||
|
logger.debug(obj)
|
||||||
|
else:
|
||||||
|
logger.debug("VAT Rate for %s already exists with the rate %s" % (country_to_change, new_rate))
|
||||||
|
|
||||||
|
logger.debug("Getting all subscriptions of %s that need a VAT Rate change")
|
||||||
|
subscriptions = stripe.Subscription.list(limit=100) # Increase the limit to 100 per page (maximum)
|
||||||
|
ch_subs = []
|
||||||
|
|
||||||
|
while subscriptions:
|
||||||
|
for subscription in subscriptions:
|
||||||
|
if len(subscription.default_tax_rates) > 0 and subscription.default_tax_rates[0].jurisdiction and subscription.default_tax_rates[0].jurisdiction.lower() == 'ch':
|
||||||
|
ch_subs.append(subscription)
|
||||||
|
elif len(subscription.default_tax_rates) > 0:
|
||||||
|
print("subscription %s belongs to %s" % (subscription.id, subscription.default_tax_rates[0].jurisdiction))
|
||||||
|
else:
|
||||||
|
print("subscription %s does not have a tax rate" % subscription.id)
|
||||||
|
if subscriptions.has_more:
|
||||||
|
print("FETCHING MORE")
|
||||||
|
subscriptions = stripe.Subscription.list(limit=100, starting_after=subscriptions.data[-1])
|
||||||
|
else:
|
||||||
|
break
|
||||||
|
logger.debug("There are %s ch subscription that need VAT rate update" % len(ch_subs))
|
||||||
|
|
||||||
|
# CSV column headers
|
||||||
|
csv_headers = [
|
||||||
|
"customer_name",
|
||||||
|
"customer_email",
|
||||||
|
"stripe_customer_id",
|
||||||
|
"subscription_id",
|
||||||
|
"subscription_name",
|
||||||
|
"amount",
|
||||||
|
"vat_rate"
|
||||||
|
]
|
||||||
|
# CSV file name
|
||||||
|
csv_filename = "ch_subscriptions_change_2024.csv"
|
||||||
|
# Write subscription data to CSV file
|
||||||
|
with open(csv_filename, mode='w', newline='') as csv_file:
|
||||||
|
writer = csv.DictWriter(csv_file, fieldnames=csv_headers)
|
||||||
|
writer.writeheader()
|
||||||
|
|
||||||
|
for subscription in ch_subs:
|
||||||
|
subscription_id = subscription["id"]
|
||||||
|
stripe_customer_id = subscription.get("customer", "")
|
||||||
|
vat_rate = subscription.get("tax_percent", "")
|
||||||
|
c_user = CustomUser.objects.get(
|
||||||
|
id=StripeCustomer.objects.filter(stripe_id=stripe_customer_id)[0].user.id)
|
||||||
|
if c_user:
|
||||||
|
customer_name = c_user.name.encode('utf-8')
|
||||||
|
customer_email = c_user.email
|
||||||
|
items = subscription.get("items", {}).get("data", [])
|
||||||
|
for item in items:
|
||||||
|
subscription_name = item.get("plan", {}).get("id", "")
|
||||||
|
amount = item.get("plan", {}).get("amount", "")
|
||||||
|
|
||||||
|
# Convert amount to a proper format (e.g., cents to dollars)
|
||||||
|
amount_in_chf = amount / 100 # Adjust this conversion as needed
|
||||||
|
|
||||||
|
# Writing to CSV
|
||||||
|
writer.writerow({
|
||||||
|
"customer_name": customer_name,
|
||||||
|
"customer_email": customer_email,
|
||||||
|
"stripe_customer_id": stripe_customer_id,
|
||||||
|
"subscription_id": subscription_id,
|
||||||
|
"subscription_name": subscription_name,
|
||||||
|
"amount": amount_in_chf,
|
||||||
|
"vat_rate": vat_rate # Fill in VAT rate if available
|
||||||
|
})
|
||||||
|
else:
|
||||||
|
print("No customuser for %s %s" % (stripe_customer_id, subscription_id))
|
||||||
|
|
||||||
|
|
||||||
|
if MAKE_MODIFS:
|
||||||
|
print("Making modifications now")
|
||||||
|
tax_rate_obj = stripe.TaxRate.create(
|
||||||
|
display_name="VAT",
|
||||||
|
description="VAT for %s" % country_to_change,
|
||||||
|
jurisdiction=country_to_change,
|
||||||
|
percentage=new_rate,
|
||||||
|
inclusive=False,
|
||||||
|
)
|
||||||
|
stripe_tax_rate = StripeTaxRate.objects.create(
|
||||||
|
display_name=tax_rate_obj.display_name,
|
||||||
|
description=tax_rate_obj.description,
|
||||||
|
jurisdiction=tax_rate_obj.jurisdiction,
|
||||||
|
percentage=tax_rate_obj.percentage,
|
||||||
|
inclusive=False,
|
||||||
|
tax_rate_id=tax_rate_obj.id
|
||||||
|
)
|
||||||
|
|
||||||
|
for ch_sub in ch_subs:
|
||||||
|
ch_sub.default_tax_rates = [stripe_tax_rate.tax_rate_id]
|
||||||
|
ch_sub.save()
|
||||||
|
logger.debug("Default tax rate updated for %s" % ch_sub.id)
|
||||||
|
else:
|
||||||
|
print("Not making any modifications because MAKE_MODIFS=False")
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
print(" *** Error occurred. Details {}".format(str(e)))
|
|
@ -25,9 +25,10 @@ class ContactView(FormView):
|
||||||
success_message = _('Message Successfully Sent')
|
success_message = _('Message Successfully Sent')
|
||||||
|
|
||||||
def form_valid(self, form):
|
def form_valid(self, form):
|
||||||
form.save()
|
print("ungleich_page contactusform")
|
||||||
form.send_email()
|
#form.save()
|
||||||
messages.add_message(self.request, messages.SUCCESS, self.success_message)
|
#form.send_email()
|
||||||
|
#messages.add_message(self.request, messages.SUCCESS, self.success_message)
|
||||||
return super(ContactView, self).form_valid(form)
|
return super(ContactView, self).form_valid(form)
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
from django.utils.translation import ugettext as _
|
from django.utils.translation import ugettext as _
|
||||||
from django.db import models
|
from django.db import models
|
||||||
|
|
||||||
# http://xml.coverpages.org/country3166.html
|
# Old: http://xml.coverpages.org/country3166.html
|
||||||
|
# 2023-12-29: Updated list of countries from https://en.wikipedia.org/wiki/List_of_ISO_3166_country_codes
|
||||||
COUNTRIES = (
|
COUNTRIES = (
|
||||||
('AD', _('Andorra')),
|
('AD', _('Andorra')),
|
||||||
('AE', _('United Arab Emirates')),
|
('AE', _('United Arab Emirates')),
|
||||||
|
@ -10,7 +11,6 @@ COUNTRIES = (
|
||||||
('AI', _('Anguilla')),
|
('AI', _('Anguilla')),
|
||||||
('AL', _('Albania')),
|
('AL', _('Albania')),
|
||||||
('AM', _('Armenia')),
|
('AM', _('Armenia')),
|
||||||
('AN', _('Netherlands Antilles')),
|
|
||||||
('AO', _('Angola')),
|
('AO', _('Angola')),
|
||||||
('AQ', _('Antarctica')),
|
('AQ', _('Antarctica')),
|
||||||
('AR', _('Argentina')),
|
('AR', _('Argentina')),
|
||||||
|
@ -18,6 +18,7 @@ COUNTRIES = (
|
||||||
('AT', _('Austria')),
|
('AT', _('Austria')),
|
||||||
('AU', _('Australia')),
|
('AU', _('Australia')),
|
||||||
('AW', _('Aruba')),
|
('AW', _('Aruba')),
|
||||||
|
('AX', _('Aland Islands')),
|
||||||
('AZ', _('Azerbaijan')),
|
('AZ', _('Azerbaijan')),
|
||||||
('BA', _('Bosnia and Herzegovina')),
|
('BA', _('Bosnia and Herzegovina')),
|
||||||
('BB', _('Barbados')),
|
('BB', _('Barbados')),
|
||||||
|
@ -28,11 +29,13 @@ COUNTRIES = (
|
||||||
('BH', _('Bahrain')),
|
('BH', _('Bahrain')),
|
||||||
('BI', _('Burundi')),
|
('BI', _('Burundi')),
|
||||||
('BJ', _('Benin')),
|
('BJ', _('Benin')),
|
||||||
|
('BL', _('St. Barts')),
|
||||||
('BM', _('Bermuda')),
|
('BM', _('Bermuda')),
|
||||||
('BN', _('Brunei Darussalam')),
|
('BN', _('Brunei')),
|
||||||
('BO', _('Bolivia')),
|
('BO', _('Bolivia')),
|
||||||
|
('BQ', _('Caribbean Netherlands')),
|
||||||
('BR', _('Brazil')),
|
('BR', _('Brazil')),
|
||||||
('BS', _('Bahama')),
|
('BS', _('Bahamas')),
|
||||||
('BT', _('Bhutan')),
|
('BT', _('Bhutan')),
|
||||||
('BV', _('Bouvet Island')),
|
('BV', _('Bouvet Island')),
|
||||||
('BW', _('Botswana')),
|
('BW', _('Botswana')),
|
||||||
|
@ -40,11 +43,12 @@ COUNTRIES = (
|
||||||
('BZ', _('Belize')),
|
('BZ', _('Belize')),
|
||||||
('CA', _('Canada')),
|
('CA', _('Canada')),
|
||||||
('CC', _('Cocos (Keeling) Islands')),
|
('CC', _('Cocos (Keeling) Islands')),
|
||||||
|
('CD', _('Congo - Kinshasa')),
|
||||||
('CF', _('Central African Republic')),
|
('CF', _('Central African Republic')),
|
||||||
('CG', _('Congo')),
|
('CG', _('Congo - Brazzaville')),
|
||||||
('CH', _('Switzerland')),
|
('CH', _('Switzerland')),
|
||||||
('CI', _('Ivory Coast')),
|
('CI', _('Ivory Coast')),
|
||||||
('CK', _('Cook Iislands')),
|
('CK', _('Cook Islands')),
|
||||||
('CL', _('Chile')),
|
('CL', _('Chile')),
|
||||||
('CM', _('Cameroon')),
|
('CM', _('Cameroon')),
|
||||||
('CN', _('China')),
|
('CN', _('China')),
|
||||||
|
@ -52,9 +56,10 @@ COUNTRIES = (
|
||||||
('CR', _('Costa Rica')),
|
('CR', _('Costa Rica')),
|
||||||
('CU', _('Cuba')),
|
('CU', _('Cuba')),
|
||||||
('CV', _('Cape Verde')),
|
('CV', _('Cape Verde')),
|
||||||
|
('CW', _('Curacao')),
|
||||||
('CX', _('Christmas Island')),
|
('CX', _('Christmas Island')),
|
||||||
('CY', _('Cyprus')),
|
('CY', _('Cyprus')),
|
||||||
('CZ', _('Czech Republic')),
|
('CZ', _('Czechia')),
|
||||||
('DE', _('Germany')),
|
('DE', _('Germany')),
|
||||||
('DJ', _('Djibouti')),
|
('DJ', _('Djibouti')),
|
||||||
('DK', _('Denmark')),
|
('DK', _('Denmark')),
|
||||||
|
@ -70,16 +75,16 @@ COUNTRIES = (
|
||||||
('ET', _('Ethiopia')),
|
('ET', _('Ethiopia')),
|
||||||
('FI', _('Finland')),
|
('FI', _('Finland')),
|
||||||
('FJ', _('Fiji')),
|
('FJ', _('Fiji')),
|
||||||
('FK', _('Falkland Islands (Malvinas)')),
|
('FK', _('Falkland Islands')),
|
||||||
('FM', _('Micronesia')),
|
('FM', _('Micronesia')),
|
||||||
('FO', _('Faroe Islands')),
|
('FO', _('Faroe Islands')),
|
||||||
('FR', _('France')),
|
('FR', _('France')),
|
||||||
('FX', _('France, Metropolitan')),
|
|
||||||
('GA', _('Gabon')),
|
('GA', _('Gabon')),
|
||||||
('GB', _('United Kingdom (Great Britain)')),
|
('GB', _('United Kingdom')),
|
||||||
('GD', _('Grenada')),
|
('GD', _('Grenada')),
|
||||||
('GE', _('Georgia')),
|
('GE', _('Georgia')),
|
||||||
('GF', _('French Guiana')),
|
('GF', _('French Guiana')),
|
||||||
|
('GG', _('Guernsey')),
|
||||||
('GH', _('Ghana')),
|
('GH', _('Ghana')),
|
||||||
('GI', _('Gibraltar')),
|
('GI', _('Gibraltar')),
|
||||||
('GL', _('Greenland')),
|
('GL', _('Greenland')),
|
||||||
|
@ -93,7 +98,7 @@ COUNTRIES = (
|
||||||
('GU', _('Guam')),
|
('GU', _('Guam')),
|
||||||
('GW', _('Guinea-Bissau')),
|
('GW', _('Guinea-Bissau')),
|
||||||
('GY', _('Guyana')),
|
('GY', _('Guyana')),
|
||||||
('HK', _('Hong Kong')),
|
('HK', _('Hong Kong SAR China')),
|
||||||
('HM', _('Heard & McDonald Islands')),
|
('HM', _('Heard & McDonald Islands')),
|
||||||
('HN', _('Honduras')),
|
('HN', _('Honduras')),
|
||||||
('HR', _('Croatia')),
|
('HR', _('Croatia')),
|
||||||
|
@ -102,12 +107,14 @@ COUNTRIES = (
|
||||||
('ID', _('Indonesia')),
|
('ID', _('Indonesia')),
|
||||||
('IE', _('Ireland')),
|
('IE', _('Ireland')),
|
||||||
('IL', _('Israel')),
|
('IL', _('Israel')),
|
||||||
|
('IM', _('Isle of Man')),
|
||||||
('IN', _('India')),
|
('IN', _('India')),
|
||||||
('IO', _('British Indian Ocean Territory')),
|
('IO', _('British Indian Ocean Territory')),
|
||||||
('IQ', _('Iraq')),
|
('IQ', _('Iraq')),
|
||||||
('IR', _('Islamic Republic of Iran')),
|
('IR', _('Iran')),
|
||||||
('IS', _('Iceland')),
|
('IS', _('Iceland')),
|
||||||
('IT', _('Italy')),
|
('IT', _('Italy')),
|
||||||
|
('JE', _('Jersey')),
|
||||||
('JM', _('Jamaica')),
|
('JM', _('Jamaica')),
|
||||||
('JO', _('Jordan')),
|
('JO', _('Jordan')),
|
||||||
('JP', _('Japan')),
|
('JP', _('Japan')),
|
||||||
|
@ -117,14 +124,14 @@ COUNTRIES = (
|
||||||
('KI', _('Kiribati')),
|
('KI', _('Kiribati')),
|
||||||
('KM', _('Comoros')),
|
('KM', _('Comoros')),
|
||||||
('KN', _('St. Kitts and Nevis')),
|
('KN', _('St. Kitts and Nevis')),
|
||||||
('KP', _('Korea, Democratic People\'s Republic of')),
|
('KP', _('North Korea')),
|
||||||
('KR', _('Korea, Republic of')),
|
('KR', _('South Korea')),
|
||||||
('KW', _('Kuwait')),
|
('KW', _('Kuwait')),
|
||||||
('KY', _('Cayman Islands')),
|
('KY', _('Cayman Islands')),
|
||||||
('KZ', _('Kazakhstan')),
|
('KZ', _('Kazakhstan')),
|
||||||
('LA', _('Lao People\'s Democratic Republic')),
|
('LA', _('Laos')),
|
||||||
('LB', _('Lebanon')),
|
('LB', _('Lebanon')),
|
||||||
('LC', _('Saint Lucia')),
|
('LC', _('St. Lucia')),
|
||||||
('LI', _('Liechtenstein')),
|
('LI', _('Liechtenstein')),
|
||||||
('LK', _('Sri Lanka')),
|
('LK', _('Sri Lanka')),
|
||||||
('LR', _('Liberia')),
|
('LR', _('Liberia')),
|
||||||
|
@ -132,20 +139,23 @@ COUNTRIES = (
|
||||||
('LT', _('Lithuania')),
|
('LT', _('Lithuania')),
|
||||||
('LU', _('Luxembourg')),
|
('LU', _('Luxembourg')),
|
||||||
('LV', _('Latvia')),
|
('LV', _('Latvia')),
|
||||||
('LY', _('Libyan Arab Jamahiriya')),
|
('LY', _('Libya')),
|
||||||
('MA', _('Morocco')),
|
('MA', _('Morocco')),
|
||||||
('MC', _('Monaco')),
|
('MC', _('Monaco')),
|
||||||
('MD', _('Moldova, Republic of')),
|
('MD', _('Moldova')),
|
||||||
|
('ME', _('Montenegro')),
|
||||||
|
('MF', _('St. Martin')),
|
||||||
('MG', _('Madagascar')),
|
('MG', _('Madagascar')),
|
||||||
('MH', _('Marshall Islands')),
|
('MH', _('Marshall Islands')),
|
||||||
|
('MK', _('North Macedonia')),
|
||||||
('ML', _('Mali')),
|
('ML', _('Mali')),
|
||||||
|
('MM', _('Myanmar (Burma)')),
|
||||||
('MN', _('Mongolia')),
|
('MN', _('Mongolia')),
|
||||||
('MM', _('Myanmar')),
|
('MO', _('Macao SAR China')),
|
||||||
('MO', _('Macau')),
|
|
||||||
('MP', _('Northern Mariana Islands')),
|
('MP', _('Northern Mariana Islands')),
|
||||||
('MQ', _('Martinique')),
|
('MQ', _('Martinique')),
|
||||||
('MR', _('Mauritania')),
|
('MR', _('Mauritania')),
|
||||||
('MS', _('Monserrat')),
|
('MS', _('Montserrat')),
|
||||||
('MT', _('Malta')),
|
('MT', _('Malta')),
|
||||||
('MU', _('Mauritius')),
|
('MU', _('Mauritius')),
|
||||||
('MV', _('Maldives')),
|
('MV', _('Maldives')),
|
||||||
|
@ -174,15 +184,17 @@ COUNTRIES = (
|
||||||
('PK', _('Pakistan')),
|
('PK', _('Pakistan')),
|
||||||
('PL', _('Poland')),
|
('PL', _('Poland')),
|
||||||
('PM', _('St. Pierre & Miquelon')),
|
('PM', _('St. Pierre & Miquelon')),
|
||||||
('PN', _('Pitcairn')),
|
('PN', _('Pitcairn Islands')),
|
||||||
('PR', _('Puerto Rico')),
|
('PR', _('Puerto Rico')),
|
||||||
|
('PS', _('Palestinian Territories')),
|
||||||
('PT', _('Portugal')),
|
('PT', _('Portugal')),
|
||||||
('PW', _('Palau')),
|
('PW', _('Palau')),
|
||||||
('PY', _('Paraguay')),
|
('PY', _('Paraguay')),
|
||||||
('QA', _('Qatar')),
|
('QA', _('Qatar')),
|
||||||
('RE', _('Reunion')),
|
('RE', _('Reunion')),
|
||||||
('RO', _('Romania')),
|
('RO', _('Romania')),
|
||||||
('RU', _('Russian Federation')),
|
('RS', _('Serbia')),
|
||||||
|
('RU', _('Russia')),
|
||||||
('RW', _('Rwanda')),
|
('RW', _('Rwanda')),
|
||||||
('SA', _('Saudi Arabia')),
|
('SA', _('Saudi Arabia')),
|
||||||
('SB', _('Solomon Islands')),
|
('SB', _('Solomon Islands')),
|
||||||
|
@ -192,17 +204,19 @@ COUNTRIES = (
|
||||||
('SG', _('Singapore')),
|
('SG', _('Singapore')),
|
||||||
('SH', _('St. Helena')),
|
('SH', _('St. Helena')),
|
||||||
('SI', _('Slovenia')),
|
('SI', _('Slovenia')),
|
||||||
('SJ', _('Svalbard & Jan Mayen Islands')),
|
('SJ', _('Svalbard and Jan Mayen')),
|
||||||
('SK', _('Slovakia')),
|
('SK', _('Slovakia')),
|
||||||
('SL', _('Sierra Leone')),
|
('SL', _('Sierra Leone')),
|
||||||
('SM', _('San Marino')),
|
('SM', _('San Marino')),
|
||||||
('SN', _('Senegal')),
|
('SN', _('Senegal')),
|
||||||
('SO', _('Somalia')),
|
('SO', _('Somalia')),
|
||||||
('SR', _('Suriname')),
|
('SR', _('Suriname')),
|
||||||
|
('SS', _('South Sudan')),
|
||||||
('ST', _('Sao Tome & Principe')),
|
('ST', _('Sao Tome & Principe')),
|
||||||
('SV', _('El Salvador')),
|
('SV', _('El Salvador')),
|
||||||
('SY', _('Syrian Arab Republic')),
|
('SX', _('Sint Maarten')),
|
||||||
('SZ', _('Swaziland')),
|
('SY', _('Syria')),
|
||||||
|
('SZ', _('Eswatini')),
|
||||||
('TC', _('Turks & Caicos Islands')),
|
('TC', _('Turks & Caicos Islands')),
|
||||||
('TD', _('Chad')),
|
('TD', _('Chad')),
|
||||||
('TF', _('French Southern Territories')),
|
('TF', _('French Southern Territories')),
|
||||||
|
@ -210,36 +224,34 @@ COUNTRIES = (
|
||||||
('TH', _('Thailand')),
|
('TH', _('Thailand')),
|
||||||
('TJ', _('Tajikistan')),
|
('TJ', _('Tajikistan')),
|
||||||
('TK', _('Tokelau')),
|
('TK', _('Tokelau')),
|
||||||
|
('TL', _('Timor-Leste')),
|
||||||
('TM', _('Turkmenistan')),
|
('TM', _('Turkmenistan')),
|
||||||
('TN', _('Tunisia')),
|
('TN', _('Tunisia')),
|
||||||
('TO', _('Tonga')),
|
('TO', _('Tonga')),
|
||||||
('TP', _('East Timor')),
|
|
||||||
('TR', _('Turkey')),
|
('TR', _('Turkey')),
|
||||||
('TT', _('Trinidad & Tobago')),
|
('TT', _('Trinidad & Tobago')),
|
||||||
('TV', _('Tuvalu')),
|
('TV', _('Tuvalu')),
|
||||||
('TW', _('Taiwan, Province of China')),
|
('TW', _('Taiwan')),
|
||||||
('TZ', _('Tanzania, United Republic of')),
|
('TZ', _('Tanzania')),
|
||||||
('UA', _('Ukraine')),
|
('UA', _('Ukraine')),
|
||||||
('UG', _('Uganda')),
|
('UG', _('Uganda')),
|
||||||
('UM', _('United States Minor Outlying Islands')),
|
('UM', _('U.S. Outlying Islands')),
|
||||||
('US', _('United States of America')),
|
('US', _('United States')),
|
||||||
('UY', _('Uruguay')),
|
('UY', _('Uruguay')),
|
||||||
('UZ', _('Uzbekistan')),
|
('UZ', _('Uzbekistan')),
|
||||||
('VA', _('Vatican City State (Holy See)')),
|
('VA', _('Vatican City')),
|
||||||
('VC', _('St. Vincent & the Grenadines')),
|
('VC', _('St. Vincent & Grenadines')),
|
||||||
('VE', _('Venezuela')),
|
('VE', _('Venezuela')),
|
||||||
('VG', _('British Virgin Islands')),
|
('VG', _('British Virgin Islands')),
|
||||||
('VI', _('United States Virgin Islands')),
|
('VI', _('U.S. Virgin Islands')),
|
||||||
('VN', _('Viet Nam')),
|
('VN', _('Vietnam')),
|
||||||
('VU', _('Vanuatu')),
|
('VU', _('Vanuatu')),
|
||||||
('WF', _('Wallis & Futuna Islands')),
|
('WF', _('Wallis & Futuna')),
|
||||||
('WS', _('Samoa')),
|
('WS', _('Samoa')),
|
||||||
('YE', _('Yemen')),
|
('YE', _('Yemen')),
|
||||||
('YT', _('Mayotte')),
|
('YT', _('Mayotte')),
|
||||||
('YU', _('Yugoslavia')),
|
|
||||||
('ZA', _('South Africa')),
|
('ZA', _('South Africa')),
|
||||||
('ZM', _('Zambia')),
|
('ZM', _('Zambia')),
|
||||||
('ZR', _('Zaire')),
|
|
||||||
('ZW', _('Zimbabwe')),
|
('ZW', _('Zimbabwe')),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,8 @@ from django.core.mail import EmailMultiAlternatives
|
||||||
from django.template.loader import render_to_string
|
from django.template.loader import render_to_string
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
|
||||||
|
from django_recaptcha.fields import ReCaptchaField
|
||||||
|
|
||||||
from membership.models import CustomUser
|
from membership.models import CustomUser
|
||||||
from .models import ContactMessage, BillingAddress, UserBillingAddress
|
from .models import ContactMessage, BillingAddress, UserBillingAddress
|
||||||
|
|
||||||
|
@ -188,6 +190,7 @@ class UserBillingAddressForm(forms.ModelForm):
|
||||||
|
|
||||||
class ContactUsForm(forms.ModelForm):
|
class ContactUsForm(forms.ModelForm):
|
||||||
error_css_class = 'autofocus'
|
error_css_class = 'autofocus'
|
||||||
|
captcha = ReCaptchaField()
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = ContactMessage
|
model = ContactMessage
|
||||||
|
@ -206,11 +209,12 @@ class ContactUsForm(forms.ModelForm):
|
||||||
}
|
}
|
||||||
|
|
||||||
def send_email(self, email_to='info@digitalglarus.ch'):
|
def send_email(self, email_to='info@digitalglarus.ch'):
|
||||||
text_content = render_to_string(
|
pass
|
||||||
'emails/contact.txt', {'data': self.cleaned_data})
|
#text_content = render_to_string(
|
||||||
html_content = render_to_string(
|
# 'emails/contact.txt', {'data': self.cleaned_data})
|
||||||
'emails/contact.html', {'data': self.cleaned_data})
|
#html_content = render_to_string(
|
||||||
email = EmailMultiAlternatives('Subject', text_content)
|
# 'emails/contact.html', {'data': self.cleaned_data})
|
||||||
email.attach_alternative(html_content, "text/html")
|
#email = EmailMultiAlternatives('Subject', text_content)
|
||||||
email.to = [email_to]
|
#email.attach_alternative(html_content, "text/html")
|
||||||
email.send()
|
#email.to = [email_to]
|
||||||
|
#email.send()
|
||||||
|
|
Loading…
Reference in a new issue