Manual merge of ungleich/master into opennebula-integration

This commit is contained in:
M.Ravi 2017-04-24 03:01:05 +05:30
commit d537fcb118
227 changed files with 25686 additions and 482 deletions

View file

@ -95,6 +95,10 @@ class SetPasswordForm(forms.Form):
return password2
class EditCreditCardForm(forms.Form):
token = forms.CharField(widget=forms.HiddenInput())
class BillingAddressForm(forms.ModelForm):
token = forms.CharField(widget=forms.HiddenInput())
@ -141,10 +145,10 @@ class ContactUsForm(forms.ModelForm):
'message': _('Message'),
}
def send_email(self):
def send_email(self, email_to='info@digitalglarus.ch'):
text_content = render_to_string('emails/contact.txt', {'data': self.cleaned_data})
html_content = render_to_string('emails/contact.html', {'data': self.cleaned_data})
email = EmailMultiAlternatives('Subject', text_content)
email.attach_alternative(html_content, "text/html")
email.to = ['info@digitalglarus.ch']
email.to = [email_to]
email.send()

View file

@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.4 on 2017-03-22 14:43
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('utils', '0004_auto_20161013_0253'),
]
operations = [
migrations.AlterField(
model_name='contactmessage',
name='phone_number',
field=models.CharField(blank=True, max_length=200),
),
]

View file

@ -43,7 +43,7 @@ class UserBillingAddress(BaseBillingAddress):
class ContactMessage(models.Model):
name = models.CharField(max_length=200)
email = models.EmailField()
phone_number = models.CharField(max_length=200)
phone_number = models.CharField(max_length=200, blank=True)
message = models.TextField()
received_date = models.DateTimeField(auto_now_add=True)

View file

@ -59,11 +59,23 @@ class StripeUtils(object):
self.stripe = stripe
def update_customer_token(self, customer, token):
# customer = stripe.Customer.retrieve(id)
customer.source = token
customer.save()
@handleStripeError
def update_customer_card(self, customer_id, token):
customer = stripe.Customer.retrieve(customer_id)
current_card_token = customer.default_source
customer.sources.retrieve(current_card_token).delete()
customer.source = token
customer.save()
credit_card_raw_data = customer.sources.data.pop()
new_card_data = {
'last4': credit_card_raw_data.last4,
'brand': credit_card_raw_data.brand
}
return new_card_data
def check_customer(self, id, user, token):
customers = self.stripe.Customer.all()
if not customers.get('data'):
@ -77,6 +89,12 @@ class StripeUtils(object):
user.stripecustomer.save()
return customer
@handleStripeError
def get_customer(self, id):
customer = stripe.Customer.retrieve(id)
# data = customer.get('response_object')
return customer
@handleStripeError
def create_customer(self, token, email):