diff --git a/datacenterlight/locale/de/LC_MESSAGES/django.po b/datacenterlight/locale/de/LC_MESSAGES/django.po index 8b191bab..e430980c 100644 --- a/datacenterlight/locale/de/LC_MESSAGES/django.po +++ b/datacenterlight/locale/de/LC_MESSAGES/django.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2017-09-07 19:54+0530\n" +"POT-Creation-Date: 2017-09-08 20:44+0530\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -262,7 +262,7 @@ msgid "" msgstr "" msgid "Log in" -msgstr "" +msgstr "Anmelden" msgid "" "Already signed up?
By logging in you can retrieve saved billing " @@ -270,16 +270,16 @@ msgid "" msgstr "" msgid "LOGIN" -msgstr "" +msgstr "ANMELDEN" msgid "Don't have an account yet?" -msgstr "" +msgstr "Besitzt du kein Benutzerkonto?" msgid "You can sign up by filling in the information below." msgstr "" msgid "Forgot password?" -msgstr "" +msgstr "Passwort vergessen?" msgid "Your Order" msgstr "Deine Bestellung" @@ -306,38 +306,22 @@ msgid "Month" msgstr "Monat" msgid "Sign up" -msgstr "" +msgstr "Registrieren" -#, fuzzy -#| msgid "Billing Address" msgid "Billing Address" msgstr "Rechnungsadresse" -#, fuzzy -#| msgid "Billing Address" msgid "Email Address" -msgstr "Rechnungsadresse" +msgstr "E-Mail-Adresse" msgid "Credit Card" msgstr "Kreditkarte" -#, fuzzy -#| msgid "" -#| "\n" -#| " Please fill in your credit card " -#| "information below. We are using Stripe for payment and do not store\n" -#| " your information in our database.\n" -#| " " msgid "" -"\n" -" Please fill in your credit card information below. " -"We are using Stripe for " -"payment and do not store your information in our database.\n" -" " +"Please fill in your credit card information below. We are using Stripe for payment and do not " +"store your information in our database." msgstr "" -"\n" "Bitte füll Deine Kreditkarteninformationen unten aus. Wir nutzen Stripe für die Bezahlung und " "speichern keine Informationen in unserer Datenbank." @@ -364,10 +348,6 @@ msgstr "" msgid "Card Type" msgstr "Kartentyp" -#, fuzzy -#| msgid "" -#| "You are not making any payment yet. After submitting your card " -#| "information, you will be taken to the Confirm Order Page." msgid "" "You are not making any payment yet. After placing your order, you will be " "taken to the Submit Payment Page." diff --git a/datacenterlight/templates/datacenterlight/landing_payment.html b/datacenterlight/templates/datacenterlight/landing_payment.html index afb797b8..3f0231f1 100644 --- a/datacenterlight/templates/datacenterlight/landing_payment.html +++ b/datacenterlight/templates/datacenterlight/landing_payment.html @@ -48,15 +48,15 @@

{%trans "Your Order" %}


-

{% trans "Cores"%} {{vm.cores}}1

+

{% trans "Cores"%} {{vm.cores}}


-

{% trans "Memory"%} {{vm.memory}}2 GB

+

{% trans "Memory"%} {{vm.memory}} GB


-

{% trans "Disk space"%} {{vm.disk_size}}2 GB

+

{% trans "Disk space"%} {{vm.disk_size}} GB


-

{% trans "Configuration"%} {{request.session.template.name}}CentOS 7

+

{% trans "Configuration"%} {{request.session.template.name}}


-

{%trans "Total" %}  ({%trans "including VAT" %}) {{request.session.specs.price}}15 CHF/{% trans "Month" %}

+

{%trans "Total" %}  ({%trans "including VAT" %}) {{request.session.specs.price}} CHF/{% trans "Month" %}

@@ -69,18 +69,8 @@ {% endif %}
- {% if not request.user.is_authenticated %} -
- - -
-
- - -
- {% endif %} - {% for field in form %} {% csrf_token %} + {% for field in form %} {% bootstrap_field field show_label=False type='fields'%} {% endfor %}
@@ -91,9 +81,7 @@

{%trans "Credit Card"%}


- {% blocktrans %} - Please fill in your credit card information below. We are using Stripe for payment and do not store your information in our database. - {% endblocktrans %} + {% blocktrans %}Please fill in your credit card information below. We are using Stripe for payment and do not store your information in our database.{% endblocktrans %}

{% if credit_card_data.last4 %} diff --git a/datacenterlight/views.py b/datacenterlight/views.py index 24f8cd74..98eac0c8 100644 --- a/datacenterlight/views.py +++ b/datacenterlight/views.py @@ -17,7 +17,7 @@ from membership.models import CustomUser, StripeCustomer from opennebula_api.models import OpenNebulaManager from opennebula_api.serializers import VirtualMachineTemplateSerializer, \ VMTemplateSerializer -from utils.forms import BillingAddressForm +from utils.forms import BillingAddressForm, BillingAddressFormSignup from utils.mailer import BaseEmail from utils.stripe_utils import StripeUtils from utils.tasks import send_plain_email_task @@ -281,10 +281,10 @@ class IndexView(CreateView): opennebula_vm_template_id=template_id).first() template_data = VMTemplateSerializer(template).data - name = request.POST.get('name') - email = request.POST.get('email') - name_field = forms.CharField() - email_field = forms.EmailField() + # name = request.POST.get('name') + # email = request.POST.get('email') + # name_field = forms.CharField() + # email_field = forms.EmailField() try: cores = cores_field.clean(cores) @@ -313,23 +313,23 @@ class IndexView(CreateView): return HttpResponseRedirect( reverse('datacenterlight:index') + "#order_form") - try: - name = name_field.clean(name) - except ValidationError as err: - msg = '{} {}.'.format(name, _('is not a proper name')) - messages.add_message(self.request, messages.ERROR, msg, - extra_tags='name') - return HttpResponseRedirect( - reverse('datacenterlight:index') + "#order_form") + # try: + # name = name_field.clean(name) + # except ValidationError as err: + # msg = '{} {}.'.format(name, _('is not a proper name')) + # messages.add_message(self.request, messages.ERROR, msg, + # extra_tags='name') + # return HttpResponseRedirect( + # reverse('datacenterlight:index') + "#order_form") - try: - email = email_field.clean(email) - except ValidationError as err: - msg = '{} {}.'.format(email, _('is not a proper email')) - messages.add_message(self.request, messages.ERROR, msg, - extra_tags='email') - return HttpResponseRedirect( - reverse('datacenterlight:index') + "#order_form") + # try: + # email = email_field.clean(email) + # except ValidationError as err: + # msg = '{} {}.'.format(email, _('is not a proper email')) + # messages.add_message(self.request, messages.ERROR, msg, + # extra_tags='email') + # return HttpResponseRedirect( + # reverse('datacenterlight:index') + "#order_form") specs = { 'cpu': cores, @@ -338,14 +338,14 @@ class IndexView(CreateView): 'price': price } - this_user = { - 'name': name, - 'email': email - } + # this_user = { + # 'name': name, + # 'email': email + # } request.session['specs'] = specs request.session['template'] = template_data - request.session['user'] = this_user + # request.session['user'] = this_user return HttpResponseRedirect(reverse('datacenterlight:payment')) def get_success_url(self): @@ -408,21 +408,34 @@ class WhyDataCenterLightView(IndexView): class PaymentOrderView(FormView): template_name = 'datacenterlight/landing_payment.html' - form_class = BillingAddressForm + + def get_form_class(self): + if self.request.user.is_authenticated(): + return BillingAddressForm + else: + return BillingAddressFormSignup def get_form_kwargs(self): form_kwargs = super(PaymentOrderView, self).get_form_kwargs() - billing_address_data = self.request.session.get('billing_address_data') - if billing_address_data: + # if user is signed in, get billing address + if self.request.user.is_authenticated(): form_kwargs.update({ - 'initial': { - 'cardholder_name': billing_address_data['cardholder_name'], - 'street_address': billing_address_data['street_address'], - 'city': billing_address_data['city'], - 'postal_code': billing_address_data['postal_code'], - 'country': billing_address_data['country'], - } + 'instance': self.request.user.billing_addresses.first() }) + else: + # if billing address in session, get data + billing_address_data = self.request.session.get( + 'billing_address_data') + if billing_address_data: + form_kwargs.update({ + 'initial': { + 'cardholder_name': billing_address_data['cardholder_name'], + 'street_address': billing_address_data['street_address'], + 'city': billing_address_data['city'], + 'postal_code': billing_address_data['postal_code'], + 'country': billing_address_data['country'], + } + }) return form_kwargs def get_context_data(self, **kwargs): @@ -436,31 +449,55 @@ class PaymentOrderView(FormView): @cache_control(no_cache=True, must_revalidate=True, no_store=True) def get(self, request, *args, **kwargs): + # user is no longer added to session in the index page # if 'specs' not in request.session or 'user' not in request.session: - # return HttpResponseRedirect(reverse('datacenterlight:index')) + if 'specs' not in request.session: + return HttpResponseRedirect(reverse('datacenterlight:index')) return self.render_to_response(self.get_context_data()) def post(self, request, *args, **kwargs): form = self.get_form() if form.is_valid(): + # name = request.POST.get('name') + # email = request.POST.get('email') + # name_field = forms.CharField() + # email_field = forms.EmailField() + # try: + # name = name_field.clean(name) + # except ValidationError as err: + # msg = '{} {}.'.format(name, _('is not a proper name')) + # messages.add_message(self.request, messages.ERROR, msg, + # extra_tags='name') + # return HttpResponseRedirect( + # reverse('datacenterlight:payment')) + + # try: + # email = email_field.clean(email) + # except ValidationError as err: + # msg = '{} {}.'.format(email, _('is not a proper email')) + # messages.add_message(self.request, messages.ERROR, msg, + # extra_tags='email') + # return HttpResponseRedirect( + # reverse('datacenterlight:payment')) # Get billing address data + # user = request.session.get('user') billing_address_data = form.cleaned_data token = form.cleaned_data.get('token') - user = request.session.get('user') try: - CustomUser.objects.get(email=user.get('email')) + CustomUser.objects.get(email=form.cleaned_data.get('email')) except CustomUser.DoesNotExist: password = CustomUser.get_random_password() # Register the user, and do not send emails - CustomUser.register(user.get('name'), + CustomUser.register(form.cleaned_data.get('name'), password, - user.get('email'), + form.cleaned_data.get('email'), app='dcl', base_url=None, send_email=False) # Get or create stripe customer - customer = StripeCustomer.get_or_create(email=user.get('email'), - token=token) + customer = StripeCustomer.get_or_create( + email=form.cleaned_data.get('email'), + token=token) if not customer: form.add_error("__all__", "Invalid credit card") return self.render_to_response( diff --git a/hosting/locale/de/LC_MESSAGES/django.po b/hosting/locale/de/LC_MESSAGES/django.po index 8c9b4caf..b633d91a 100644 --- a/hosting/locale/de/LC_MESSAGES/django.po +++ b/hosting/locale/de/LC_MESSAGES/django.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2017-09-07 19:54+0530\n" +"POT-Creation-Date: 2017-09-08 20:44+0530\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -365,12 +365,6 @@ msgstr "" msgid "Type" msgstr "Kartentyp" -msgid "REMOVE CARD" -msgstr "KARTE ENTFERNEN" - -msgid "EDIT CARD" -msgstr "BEARBEITEN" - msgid "No Credit Cards Added" msgstr "Es wurde keine Kreditkarte hinzugefügt" @@ -378,9 +372,8 @@ msgid "" "We are using Stripe for payment and do " "not store your information in our database." msgstr "" -"Wir nutzen Stripe für die Bezahlung und " -"speichern keine Informationen in unserer Datenbank." +"Wir nutzen Stripe für " +"die Bezahlung und speichern keine Informationen in unserer Datenbank." msgid "Add your public SSH key" msgstr "Füge deinen öffentlichen SSH-Key hinzu" @@ -502,7 +495,7 @@ msgid "View Detail" msgstr "Details anzeigen" msgid "login" -msgstr "Einloggen" +msgstr "Anmelden" msgid "" "Thank you for signing up. We have sent an email to you. Please follow the " @@ -539,6 +532,12 @@ msgid "" "contact Data Center Light Support." msgstr "Kontaktiere den Data Center Light Support." +#~ msgid "REMOVE CARD" +#~ msgstr "KARTE ENTFERNEN" + +#~ msgid "EDIT CARD" +#~ msgstr "BEARBEITEN" + #~ msgid "Add a new Card." #~ msgstr "Neue Kreditkarte hinzufügen." diff --git a/utils/forms.py b/utils/forms.py index c3f3b6db..9ed695c0 100644 --- a/utils/forms.py +++ b/utils/forms.py @@ -113,6 +113,12 @@ class BillingAddressForm(forms.ModelForm): } +class BillingAddressFormSignup(BillingAddressForm): + name = forms.CharField(label=_('Name')) + email = forms.EmailField(label=_('Email Address')) + field_order = ['name', 'email'] + + class UserBillingAddressForm(forms.ModelForm): user = forms.ModelChoiceField(queryset=CustomUser.objects.all(), widget=forms.HiddenInput())