Manual merge of ungleich/master into opennebula-integration
This commit is contained in:
parent
d10285e23d
commit
d537fcb118
227 changed files with 25686 additions and 482 deletions
|
|
@ -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()
|
||||
|
|
|
|||
20
utils/migrations/0005_auto_20170322_1443.py
Normal file
20
utils/migrations/0005_auto_20170322_1443.py
Normal 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),
|
||||
),
|
||||
]
|
||||
|
|
@ -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)
|
||||
|
||||
|
|
|
|||
|
|
@ -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):
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue