diff --git a/digitalglarus/urls.py b/digitalglarus/urls.py index da9f5926..7f08190c 100644 --- a/digitalglarus/urls.py +++ b/digitalglarus/urls.py @@ -5,9 +5,6 @@ from . import views from .views import ContactView, IndexView, AboutView urlpatterns = [ - # url(r'^$', IndexView.as_view(), name='home'), - # url(_(r'home/?$'), IndexView.as_view(), name='home'), - # url(_(r'about/?$'), AboutView.as_view(), name='about'), url(_(r'contact/?$'), ContactView.as_view(), name='contact'), url(_(r'supporters/?$'), views.supporters, name='supporters'), url(r'calendar_api/(?P\d+)/(?P\d+)?$', views.CalendarApi.as_view(),name='calendar_api_1'), diff --git a/hosting/mixins.py b/hosting/mixins.py index 7104e157..1f6366ab 100644 --- a/hosting/mixins.py +++ b/hosting/mixins.py @@ -16,5 +16,6 @@ class ProcessVMSelectionMixin(object): request.session['vm_specs'] = vm_specs if not request.user.is_authenticated(): request.session['vm_specs'] = vm_specs + request.session['next'] = reverse('hosting:payment') return redirect(reverse('hosting:login')) return redirect(reverse('hosting:payment')) diff --git a/hosting/static/hosting/css/pricing.css b/hosting/static/hosting/css/pricing.css index 870b3cf9..7fb6f51f 100644 --- a/hosting/static/hosting/css/pricing.css +++ b/hosting/static/hosting/css/pricing.css @@ -1,3 +1,7 @@ +.pricing-container{ + margin-left: 5%; +} + .pricing { text-align: center; border: 1px solid #f0f0f0; @@ -7,6 +11,8 @@ margin-bottom: 30px; font-family: 'Lato'; } + + .pricing img { display: block; margin: auto; @@ -23,6 +29,13 @@ .pricing li + li { border-top: 1px solid #f0f0f0; } + +.pricing li.type { + list-style: none; + padding: 13px; + height: 200px; +} + .pricing big { font-size: 32px; } @@ -81,6 +94,7 @@ .pricing .short-input{ min-width: 0; width: 90px; + display: inline; } .p-red button { diff --git a/hosting/templates/hosting/base_short.html b/hosting/templates/hosting/base_short.html index 3ffca138..fabfa030 100644 --- a/hosting/templates/hosting/base_short.html +++ b/hosting/templates/hosting/base_short.html @@ -55,20 +55,25 @@ @@ -93,20 +98,20 @@
  • - How it works
  • + How it works
  • - Your infrastructure
  • + Your infrastructure
  • - Our infrastructure
  • + Our infrastructure
  • - Pricing + Pricing
  • - Contact + Contact
  • diff --git a/hosting/templates/hosting/checkout.html b/hosting/templates/hosting/checkout.html deleted file mode 100644 index 90ff2bc7..00000000 --- a/hosting/templates/hosting/checkout.html +++ /dev/null @@ -1,158 +0,0 @@ - - - - - - - - - - - - Rails Hosting.ch - Ruby on Rails as easy as possible - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    -
     
    -
    -

    Check Out

    -
    - -
      -
    • -

      OS : Ubuntu 14.04

      -
    • -
    • -

      RAM : 1GiB

    • -
    • CPU Cores : 4

    • -
    • Additional Disk: 20 GB -

    - -
    -
    -

     

    -
    - -

    -
      - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - diff --git a/hosting/templates/hosting/includes/_header.html b/hosting/templates/hosting/includes/_header.html index a75e797c..9e609816 100644 --- a/hosting/templates/hosting/includes/_header.html +++ b/hosting/templates/hosting/includes/_header.html @@ -13,7 +13,7 @@
    - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/hosting/templates/hosting/invoice.html b/hosting/templates/hosting/invoice.html new file mode 100644 index 00000000..302028fe --- /dev/null +++ b/hosting/templates/hosting/invoice.html @@ -0,0 +1,79 @@ +{% extends "hosting/base_short.html" %} +{% load staticfiles bootstrap3 %} +{% block content %} + + + +
    +
    +
    +
    +

    Invoice

    Order # {{order.id}}

    +
    +
    +
    +
    +
    +

    Billed To:

    + John Smith
    + 1234 Main
    + Apt. 4B
    + Springfield, ST 54321 +
    +
    +
    +
    + Order Date:
    + {{order.created_at}}

    +
    +
    +
    +
    +
    +
    + Payment Method:
    + {{brand}} ending **** {{last4}}
    + {{user.email}} +
    +
    +
    +
    +
    + +
    +
    +

    Order summary

    +
    +
    +

    Type {{request.session.vm_specs.hosting_company_name}}

    +
    +

    Cores {{request.session.vm_specs.cores}}

    +
    +

    Memory {{request.session.vm_specs.memory}} GiB

    +
    +

    Disk space {{request.session.vm_specs.disk_size}} GiB

    +
    +

    Total

    {{request.session.vm_specs.final_price}} CHF

    +
    +
    +
    +
    +{%endblock%} diff --git a/hosting/templates/hosting/orders.html b/hosting/templates/hosting/orders.html new file mode 100644 index 00000000..df5e6216 --- /dev/null +++ b/hosting/templates/hosting/orders.html @@ -0,0 +1,36 @@ +{% extends "hosting/base_short.html" %} +{% load staticfiles bootstrap3 %} +{% block content %} +
    +
    +
    +
    + + + + + + + + + + + + {% for order in orders %} + + + + + + + {% endfor %} + +
    My orders.
    #DateAmountStatus
    {{order.id}}{{order.created_at}}{{order.VMPlan.price}}{{order.approved}}
    +
    + +
    +
    + +
    + +{%endblock%} \ No newline at end of file diff --git a/hosting/templates/hosting/payment.html b/hosting/templates/hosting/payment.html index 1ebb1770..ec942131 100644 --- a/hosting/templates/hosting/payment.html +++ b/hosting/templates/hosting/payment.html @@ -1,6 +1,6 @@ {% extends "hosting/base_short.html" %} {% load staticfiles bootstrap3 %} -{%block content %} +{% block content %}
    @@ -64,6 +64,17 @@

    + {% if paymentError %} +
    +
    +

    + {% bootstrap_alert paymentError alert_type='danger' %} +

    +
    +
    + {% endif %} + + @@ -88,6 +99,7 @@ + diff --git a/hosting/urls.py b/hosting/urls.py index 0cff09ec..3b40dff8 100644 --- a/hosting/urls.py +++ b/hosting/urls.py @@ -1,7 +1,8 @@ from django.conf.urls import url from .views import DjangoHostingView, RailsHostingView, PaymentVMView, \ - NodeJSHostingView, LoginView, SignupView, IndexView + NodeJSHostingView, LoginView, SignupView, IndexView, \ + InvoiceVMView, OrdersHostingView urlpatterns = [ # url(r'pricing/?$', VMPricingView.as_view(), name='pricing'), @@ -9,7 +10,11 @@ urlpatterns = [ url(r'django/?$', DjangoHostingView.as_view(), name='djangohosting'), url(r'nodejs/?$', NodeJSHostingView.as_view(), name='nodejshosting'), url(r'rails/?$', RailsHostingView.as_view(), name='railshosting'), + url(r'payment/?$', PaymentVMView.as_view(), name='payment'), + url(r'invoice/?$', InvoiceVMView.as_view(), name='invoice'), + url(r'orders/?$', OrdersHostingView.as_view(), name='orders'), url(r'login/?$', LoginView.as_view(), name='login'), url(r'signup/?$', SignupView.as_view(), name='signup'), - url(r'payment/?$', PaymentVMView.as_view(), name='payment'), + url(r'^logout/?$', 'django.contrib.auth.views.logout', + {'next_page': '/ungleich_page'}, name='logout') ] diff --git a/hosting/views.py b/hosting/views.py index 16556bc1..65bbbcf3 100644 --- a/hosting/views.py +++ b/hosting/views.py @@ -1,6 +1,9 @@ from django.shortcuts import get_object_or_404, render from django.core.urlresolvers import reverse_lazy, reverse +from django.contrib.auth.mixins import LoginRequiredMixin +from django.contrib.auth.decorators import login_required +from django.utils.decorators import method_decorator from django.views.generic import View, CreateView, FormView from django.shortcuts import redirect @@ -12,6 +15,7 @@ from membership.forms import PaymentForm from membership.models import CustomUser, StripeCustomer from utils.stripe_utils import StripeUtils from utils.forms import BillingAddressForm +from utils.models import BillingAddress from .models import VirtualMachineType, VirtualMachinePlan, HostingOrder from .forms import HostingUserSignupForm, HostingUserLoginForm from .mixins import ProcessVMSelectionMixin @@ -106,13 +110,16 @@ class LoginView(FormView): form_class = HostingUserLoginForm moodel = CustomUser + def get_success_url(self): + next_url = self.request.session.get('next', self.success_url) + return next_url + def form_valid(self, form): email = form.cleaned_data.get('email') password = form.cleaned_data.get('password') auth_user = authenticate(email=email, password=password) if auth_user: - login(self.request, auth_user) return HttpResponseRedirect(self.get_success_url()) @@ -125,7 +132,8 @@ class SignupView(CreateView): moodel = CustomUser def get_success_url(self): - return reverse_lazy('hosting:signup') + next_url = self.request.session.get('next', reverse_lazy('hosting:signup')) + return next_url def form_valid(self, form): @@ -155,7 +163,7 @@ class PaymentVMView(FormView): form = self.get_form() if form.is_valid(): - + context = self.get_context_data() specifications = request.session.get('vm_specs') vm_type = specifications.get('hosting_company') vm = VirtualMachineType.objects.get(hosting_company=vm_type) @@ -185,20 +193,84 @@ class PaymentVMView(FormView): # Make stripe charge to a customer stripe_utils = StripeUtils() - charge = stripe_utils.make_charge(amount=final_price, - customer=customer.stripe_id) - order.set_stripe_charge(charge) + charge_response = stripe_utils.make_charge(amount=final_price, + customer=customer.stripe_id) + charge = charge_response.get('response_object') - if not charge.paid: - # raise an error - pass + # Check if the payment was approved + if not charge: + context.update({ + 'paymentError': charge_response.get('error'), + 'form': form + }) + return render(request, self.template_name, context) + + charge = charge_response.get('response_object') + + # Associate an order with a stripe payment + order.set_stripe_charge(charge) # If the Stripe payment was successed, set order status approved order.set_approved() - # order.charge = - - # Billing Address should be store here - - return HttpResponseRedirect(reverse('hosting:payment')) + request.session.update({ + 'charge': charge, + 'order': order.id, + 'billing_address': billing_address.id + }) + return HttpResponseRedirect(reverse('hosting:invoice')) else: return self.form_invalid(form) + + +class InvoiceVMView(LoginRequiredMixin, View): + template_name = "hosting/invoice.html" + login_url = reverse_lazy('hosting:login') + + def get_context_data(self, **kwargs): + charge = self.request.session.get('charge') + order_id = self.request.session.get('order') + billing_address_id = self.request.session.get('billing_address') + last4 = charge.get('source').get('last4') + brand = charge.get('source').get('brand') + + order = get_object_or_404(HostingOrder, pk=order_id) + billing_address = get_object_or_404(BillingAddress, pk=billing_address_id) + + if not charge: + return + + context = { + 'last4': last4, + 'brand': brand, + 'order': order, + 'billing_address': billing_address, + } + return context + + def get(self, request, *args, **kwargs): + + context = self.get_context_data() + + return render(request, self.template_name, context) + + +class OrdersHostingView(LoginRequiredMixin, View): + template_name = "hosting/orders.html" + login_url = reverse_lazy('hosting:login') + + def get_context_data(self, **kwargs): + user = self.request.user + orders = HostingOrder.objects.filter(customer__user=user) + context = { + 'orders':orders + } + + return context + + def get(self, request, *args, **kwargs): + + context = self.get_context_data() + + return render(request, self.template_name, context) + + diff --git a/membership/models.py b/membership/models.py index a494fdec..a607906c 100644 --- a/membership/models.py +++ b/membership/models.py @@ -144,9 +144,10 @@ class StripeCustomer(models.Model): stripe_utils = StripeUtils() stripe_data = stripe_utils.create_customer(token, email) + stripe_cus_id = stripe_data.get('response_object').get('id') - stripe_customer = StripeCustomer.objects. \ - create(user=user, stripe_id=stripe_data.get('id')) + stripe_customer = StripeCustomer.objects.\ + create(user=user, stripe_id=stripe_cus_id) return stripe_customer diff --git a/requirements.txt b/requirements.txt index e70df3fa..f3f2836c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,18 +1,6 @@ Django==1.9.4 aldryn-newsblog wheel -======= -# lib -psycopg2>=2.6 -Pillow>=2 -html5lib==0.999 -six==1.3.0 #compat -python-memcached - -# django -django==1.7.10 - -#django-assets django-bootstrap3 django-cms django-compressor @@ -56,40 +44,6 @@ Pillow>=2 django-filer cmsplugin-filer django-reversion -======= - -# django-cms-plugins -djangocms-admin-style==0.2.5 -djangocms-text-ckeditor>=2.4 -django-select2>=4.3.1 -djangocms-blog>=0.4.0 - -djangocms-flash -djangocms-googlemap -djangocms-inherit -djangocms-teaser - -djangocms-link -djangocms-snippet -djangocms-style -djangocms-column -djangocms-grid -djangocms-oembed -djangocms-table - -cmsplugin-filer==0.10.1 - -# production -# circus-web -# chaussette -# meinheld - -# python3 support -gevent>=1.1a2 - -# djangocms-page-meta -djangocms-page-meta -# memcache pylibmc django_extensions -django-debug-toolbar +django-debug-toolbar \ No newline at end of file diff --git a/ungleich_page/locale/de/LC_MESSAGES/django.mo b/ungleich_page/locale/de/LC_MESSAGES/django.mo index 0b16e963..ef04e0da 100644 Binary files a/ungleich_page/locale/de/LC_MESSAGES/django.mo and b/ungleich_page/locale/de/LC_MESSAGES/django.mo differ diff --git a/ungleich_page/locale/de/LC_MESSAGES/django.po b/ungleich_page/locale/de/LC_MESSAGES/django.po index 3d564b18..a5cb93c7 100644 --- a/ungleich_page/locale/de/LC_MESSAGES/django.po +++ b/ungleich_page/locale/de/LC_MESSAGES/django.po @@ -20,105 +20,105 @@ msgstr "" #: templates/ungleich_page/includes/_about.html:8 msgid "ABOUT" -msgstr "" +msgstr "Über ungleich" #: templates/ungleich_page/includes/_about.html:9 msgid "The timeline of ungleich" -msgstr "" +msgstr "Die Chronik von ungleich" #: templates/ungleich_page/includes/_about.html:24 msgid "The first incarnation of ungleich" -msgstr "" +msgstr "Die erste Inkarnation von ungleich" #: templates/ungleich_page/includes/_about.html:25 msgid "in Germany" -msgstr "" +msgstr "in Deutschland" #: templates/ungleich_page/includes/_about.html:37 msgid "ungleich founded" -msgstr "" +msgstr "ungleich gegründet" #: templates/ungleich_page/includes/_about.html:38 msgid "in Switzerland" -msgstr "" +msgstr "in der Schweiz" #: templates/ungleich_page/includes/_about.html:51 msgid "ungleich present at various conferences" -msgstr "" +msgstr "ungleich präsent an mehreren Konferenzen" #: templates/ungleich_page/includes/_about.html:65 msgid "ungleich introduces HA-Hosting" -msgstr "" +msgstr "ungleich führt HA-Hosting ein" #: templates/ungleich_page/includes/_about.html:66 msgid "and introduces affordable 24X7 support." -msgstr "" +msgstr "und führt kostengünstigen 24X7 Support ein." #: templates/ungleich_page/includes/_about.html:67 msgid "ungleich launches" -msgstr "" +msgstr "ungleich lanciert" #: templates/ungleich_page/includes/_about.html:68 msgid "Digital Glarus project" -msgstr "" +msgstr "Digital Glarus Projekt" #: templates/ungleich_page/includes/_about.html:74 msgid "and" -msgstr "" +msgstr "und" #: templates/ungleich_page/includes/_about.html:74 msgid "the story continues!" -msgstr "" +msgstr "Die Geschichte geht weiter!" #: templates/ungleich_page/includes/_contact_us.html:14 #: templates/ungleich_page/includes/_contact_us.html:21 views.py:35 msgid "Contact Us" -msgstr "Kontaktiere Uns" +msgstr "Kontaktieren Sie uns" #: templates/ungleich_page/includes/_contact_us.html:16 msgid "Join us at" -msgstr "" +msgstr "Schliessen Sie sich uns an" #: templates/ungleich_page/includes/_contact_us.html:16 msgid "Digital Glarus" -msgstr "" +msgstr "Digital Glarus" #: templates/ungleich_page/includes/_contact_us.html:17 msgid "a great co-working space in the middle of Alps!" -msgstr "" +msgstr "ein wunderschöner Co-Working Space mitten in den Alpen" #: templates/ungleich_page/includes/_contact_us.html:17 msgid "You can contact us at" -msgstr "" +msgstr "Sie können uns kontaktieren unter" #: templates/ungleich_page/includes/_contact_us.html:20 msgid "or" -msgstr "" +msgstr "oder" #: templates/ungleich_page/includes/_contact_us.html:50 msgid "Submit" -msgstr "" +msgstr "Absenden" #: templates/ungleich_page/includes/_footer.html:8 msgid "Copyright © ungleich GmbH " -msgstr "" +msgstr "Copyright © ungleich GmbH" #: templates/ungleich_page/includes/_footer.html:22 msgid "ungleich Home" -msgstr "" +msgstr "ungleich Home" #: templates/ungleich_page/includes/_header.html:11 msgid "We Design, Configure & Maintain
    Your Linux Infrastructure " -msgstr "" +msgstr "Wir designen, erstellen und warten Ihre Linux-Infrastruktur" #: templates/ungleich_page/includes/_portfolio.html:8 #: templates/ungleich_page/includes/_portfolio.html:9 msgid "Hosting Products " -msgstr "" +msgstr "Hosting Produkte" #: templates/ungleich_page/includes/_portfolio.html:16 msgid "HA Hosting" -msgstr "" +msgstr "HA Hosting" #: templates/ungleich_page/includes/_portfolio.html:18 msgid "" @@ -151,11 +151,11 @@ msgstr "" #: templates/ungleich_page/includes/_services.html:8 msgid "our services" -msgstr "" +msgstr "Unsere Dienstleistungen" #: templates/ungleich_page/includes/_services.html:18 msgid "Hosting" -msgstr "" +msgstr "Hosting" #: templates/ungleich_page/includes/_services.html:20 msgid "" @@ -165,7 +165,7 @@ msgstr "" #: templates/ungleich_page/includes/_services.html:28 msgid "Configuration as a Service" -msgstr "" +msgstr "Konfiguration als Service" #: templates/ungleich_page/includes/_services.html:30 msgid "" @@ -186,7 +186,7 @@ msgstr "" #: templates/ungleich_page/includes/_team.html:8 msgid "Why ungleich?*" -msgstr "" +msgstr "Warum ungleich?" #: templates/ungleich_page/includes/_team.html:9 msgid "What our customers say" @@ -257,9 +257,8 @@ msgstr "" #: views.py:25 msgid "Message Successfully Sent" -msgstr "" +msgstr "Nachricht erfolgreich versendet" #: views.py:36 msgid "If you have any question, just send us an email." -msgstr "" -"Wenn Sie irgendwelche Fragen haben, schicken Sie uns einfach eine E-Mail." +msgstr "Wenn Sie irgendwelche Fragen haben, schicken Sie uns einfach eine E-Mail." diff --git a/ungleich_page/templates/ungleich_page/base_ungleich.html b/ungleich_page/templates/ungleich_page/base_ungleich.html deleted file mode 100644 index 49ceefe9..00000000 --- a/ungleich_page/templates/ungleich_page/base_ungleich.html +++ /dev/null @@ -1,78 +0,0 @@ -{% load cms_tags menu_tags sekizai_tags staticfiles bootstrap3 %} - - - - - {% block title %} - {% page_attribute "page_title" %} - {% endblock %} - - {% addtoblock "external-css" %} - {% bootstrap_css %} - - - - - - - - - {% endaddtoblock %} - - {% addtoblock "css" %} - - {% endaddtoblock %} - {% block meta %} - - - {% include 'meta.html' %} - {% endblock %} - {% render_block "external-css" %} - {% render_block "css" postprocessor "compressor.contrib.sekizai.compress" %} - - - {% cms_toolbar %} - {% show_menu 0 0 0 1 "cms/ungleichch/_menu.html" %} - - - {% block base_header %} - {% include "ungleich_page/_header_base.html" %} - {% endblock %} -
    -
    -
    - {% block base_content %} - {% placeholder "default" %} - {% endblock %} -
    -
    -
    - - {% include "cms/ungleichch/_footer.html" %} - {% addtoblock "external-js" %} - {% bootstrap_javascript %} - {% endaddtoblock %} - {% addtoblock "js" %} - - -