This commit is contained in:
Levi 2016-12-04 19:44:26 -05:00
parent b588dcf741
commit 16522cae1b
10 changed files with 384 additions and 17 deletions

View File

@ -1,15 +1,29 @@
from django.contrib import admin from django.contrib import admin
from .models import Supporter, DGGallery, DGPicture, Booking, BookingPrice,\ from .models import Supporter, DGGallery, DGPicture, Booking, BookingPrice,\
MembershipOrder, Membership, MembershipType, BookingOrder MembershipOrder, Membership, MembershipType, BookingOrder, BookingCancellation
from django.core.urlresolvers import reverse
from utils.models import ContactMessage from utils.models import ContactMessage
# from django.utils.html import format_html
class DGPictureInline(admin.StackedInline): class DGPictureInline(admin.StackedInline):
model = DGPicture model = DGPicture
class DGGalleryAdmin(admin.ModelAdmin): class DGGalleryAdmin(admin.ModelAdmin):
inlines = [DGPictureInline] inlines = [DGPictureInline]
class BookingCancellationAdmin(admin.ModelAdmin):
list_display = ('id', 'get_order', 'created_at', 'required_refund', 'refund')
def get_order(self, obj):
order = obj.order
order_url = reverse("admin:digitalglarus_bookingorder_change", args=[order.id])
return format_html("<a href='{url}'>{order_id}</a>", url=order_url, order_id=order.id)
admin.site.register(DGGallery, DGGalleryAdmin) admin.site.register(DGGallery, DGGalleryAdmin)
admin.site.register(ContactMessage) admin.site.register(ContactMessage)
admin.site.register(Booking) admin.site.register(Booking)
@ -18,3 +32,4 @@ admin.site.register(MembershipOrder)
admin.site.register(Membership) admin.site.register(Membership)
admin.site.register(MembershipType) admin.site.register(MembershipType)
admin.site.register(BookingOrder) admin.site.register(BookingOrder)
admin.site.register(BookingCancellation, BookingCancellationAdmin)

View File

@ -81,12 +81,12 @@ class CancelBookingForm(forms.ModelForm):
model = BookingOrder model = BookingOrder
fields = ['status'] fields = ['status']
def clean(self): # def clean(self):
booking = self.instance.booking # booking = self.instance.booking
days_to_start = (booking.start_date - datetime.today().date()).days # days_to_start = (booking.start_date - datetime.today().date()).days
if days_to_start < 7: # if days_to_start < 7:
raise forms.ValidationError("You can't cancel your booking") # raise forms.ValidationError("You can't cancel your booking")
return self.cleaned_data # return self.cleaned_data
class BookingDateForm(forms.Form): class BookingDateForm(forms.Form):

View File

@ -0,0 +1,26 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.4 on 2016-12-02 02:22
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('digitalglarus', '0023_bookingorder_status'),
]
operations = [
migrations.CreateModel(
name='BookingCancellation',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('created_at', models.DateTimeField(auto_now=True)),
('required_refund', models.BooleanField(default=True)),
('refund', models.BooleanField(default=False)),
('order', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='digitalglarus.BookingOrder')),
],
),
]

View File

@ -264,16 +264,31 @@ class BookingOrder(Ordereable, models.Model):
def booking_days(self): def booking_days(self):
return (self.booking.end_date - self.booking.start_date).days + 1 return (self.booking.end_date - self.booking.start_date).days + 1
def cancellation_available(self): def refund_required(self):
days_to_start = (booking.start_date - datetime.today()).days days_to_start = (self.booking.start_date - datetime.today().date()).days
return False if days_to_start < 7 else True return True if days_to_start < 7 else False
def cancel(self): def cancel(self):
self.status = self.CANCELLED self.status = self.CANCELLED
self.save() self.save()
class BookingCancellation(models.Model):
order = models.ForeignKey(BookingOrder)
created_at = models.DateTimeField(auto_now=True)
required_refund = models.BooleanField(default=True)
refund = models.BooleanField(default=False)
def __str__(self):
return "Order: {} - Required Refund: {}".format(self.order.id, self.refund)
@classmethod
def create(cls, booking_order):
required_refund = booking_order.refund_required()
cls.objects.create(order=booking_order, required_refund=required_refund)
class Supporter(models.Model): class Supporter(models.Model):
name = models.CharField(max_length=200) name = models.CharField(max_length=200)
description = models.TextField(null=True, blank=True) description = models.TextField(null=True, blank=True)

View File

@ -87,6 +87,9 @@
</div> </div>
<div class="modal-body"> <div class="modal-body">
<p>Do you want to cancel your booking?</p> <p>Do you want to cancel your booking?</p>
<p>
Your booking is within 7 days. You may cancel your booking but the fees will not be refunded. Your booking can be only cancelled freely until 7 days before the booked date.
</p>
</div> </div>
<div class="modal-footer text-center"> <div class="modal-footer text-center">
<button type="button" class="btn btn-primary btn-grey" data-dismiss="modal">No</button> <button type="button" class="btn btn-primary btn-grey" data-dismiss="modal">No</button>

View File

@ -0,0 +1,136 @@
{% load static from staticfiles %}
<!-- Inliner Build Version 4380b7741bb759d6cb997545f3add21ad48f010b -->
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" style="font-family: 'Raleway', 'Helvetica Neue', 'Arial', 'sans-serif' !important;">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Oxygen Invoice</title>
</head>
<body bgcolor="#f7f7f7" style="font-family: 'Raleway', 'Helvetica Neue', 'Arial', 'sans-serif' !important; -webkit-font-smoothing: antialiased; -webkit-text-size-adjust: none; width: 100% !important; height: 100%; color: white; margin: 0;">
<style type="text/css">
@media only screen and (max-width: 480px) {
table[class*="container-for-gmail-android"] {
min-width: 290px !important; width: 100% !important;
}
img[class="force-width-gmail"] {
display: none !important; width: 0 !important; height: 0 !important;
}
table[class="w320"] {
width: 320px !important;
}
td[class*="mobile-header-padding-left"] {
width: 160px !important; padding-left: 0 !important;
}
td[class*="mobile-header-padding-right"] {
width: 160px !important; padding-right: 0 !important;
}
td[class="header-lg"] {
font-size: 24px !important; padding-bottom: 5px !important;
}
td[class="content-padding"] {
padding: 5px 0 5px !important;
}
td[class="button"] {
padding: 5px 5px 30px !important;
}
td[class*="free-text"] {
padding: 10px 18px 30px !important;
}
td[class~="mobile-hide-img"] {
display: none !important; height: 0 !important; width: 0 !important; line-height: 0 !important;
}
td[class~="item"] {
width: 140px !important; vertical-align: top !important;
}
td[class~="quantity"] {
width: 50px !important;
}
td[class~="price"] {
width: 90px !important;
}
td[class="item-table"] {
padding: 30px 20px !important;
}
td[class="mini-container-left"] {
padding: 0 15px 15px !important; display: block !important; width: 290px !important;
}
td[class="mini-container-right"] {
padding: 0 15px 15px !important; display: block !important; width: 290px !important;
}
}
</style>
<table align="center" cellpadding="0" cellspacing="0" class="container-for-gmail-android" width="100%" style="border-collapse: collapse !important; min-width: 600px; font-family: 'Raleway', 'Helvetica Neue', 'Arial', 'sans-serif' !important;">
<tr style="font-family: 'Raleway', 'Helvetica Neue', 'Arial', 'sans-serif' !important;">
<td align="left" valign="top" width="100%" style="border-collapse: collapse; font-family: 'Raleway', 'Helvetica Neue', 'Arial', 'sans-serif' !important; font-size: 14px; color: #777777; text-align: center; line-height: 21px; background: #ffffff url(http://s3.amazonaws.com/swu-filepicker/4E687TRe69Ld95IDWyEg_bg_top_02.jpg) repeat-x;" bgcolor="#ffffff">
<center style="font-family: 'Raleway', 'Helvetica Neue', 'Arial', 'sans-serif' !important;">
<table cellspacing="0" cellpadding="0" width="100%" bgcolor="#ffffff" background="http://s3.amazonaws.com/swu-filepicker/4E687TRe69Ld95IDWyEg_bg_top_02.jpg" style="border-collapse: collapse !important; font-family: 'Raleway', 'Helvetica Neue', 'Arial', 'sans-serif' !important; background: transparent;"><tr style="font-family: 'Raleway', 'Helvetica Neue', 'Arial', 'sans-serif' !important;">
<td width="100%" height="80" valign="top" style="text-align: center; vertical-align: middle; border-collapse: collapse; font-family: 'Raleway', 'Helvetica Neue', 'Arial', 'sans-serif' !important; font-size: 14px; color: #777777; line-height: 21px; background-color: #0f1221" align="center">
<!--[if gte mso 9]>
<v:rect xmlns:v="urn:schemas-microsoft-com:vml" fill="true" stroke="false" style="mso-width-percent:1000;height:80px; v-text-anchor:middle;">
<v:fill type="tile" src="http://s3.amazonaws.com/swu-filepicker/4E687TRe69Ld95IDWyEg_bg_top_02.jpg" color="#ffffff" />
<v:textbox inset="0,0,0,0">
<![endif]-->
<center style="font-family: 'Raleway', 'Helvetica Neue', 'Arial', 'sans-serif' !important;">
<table cellpadding="0" cellspacing="0" width="600" class="w320" style="border-collapse: collapse !important; font-family: 'Raleway', 'Helvetica Neue', 'Arial', 'sans-serif' !important;"><tr style="font-family: 'Raleway', 'Helvetica Neue', 'Arial', 'sans-serif' !important;">
<td class="pull-left mobile-header-padding-left" style="vertical-align: middle; border-collapse: collapse; font-family: 'Raleway', 'Helvetica Neue', 'Arial', 'sans-serif' !important; font-size: 14px; color: #777777; text-align: left; line-height: 21px; width: 290px; padding-left: 10px;" align="left" valign="middle">
<a href="{{base_url}}" style="font-family: 'Raleway', 'Helvetica Neue', 'Arial', 'sans-serif' !important; color: #676767; text-decoration: none !important;"><img width="137" src="{{base_url}}{% static 'digitalglarus/img/logo_white.svg' %}" alt="logo" style="max-width: 600px; outline: none; text-decoration: none; -ms-interpolation-mode: bicubic; font-family: 'Raleway', 'Helvetica Neue', 'Arial', 'sans-serif' !important; border: none;"></a>
</td>
<td class="pull-right mobile-header-padding-right" style="color: #4d4d4d; border-collapse: collapse; font-family: 'Raleway', 'Helvetica Neue', 'Arial', 'sans-serif' !important; font-size: 14px; text-align: right; line-height: 21px; width: 290px; padding-left: 10px;" align="right">
</td>
</tr></table>
</center>
<!--[if gte mso 9]>
</v:textbox>
</v:rect>
<![endif]-->
</td>
</tr></table>
</center>
</td>
</tr>
<tr style="font-family: 'Raleway', 'Helvetica Neue', 'Arial', 'sans-serif' !important;">
<td align="center" valign="top" width="100%" style="border-collapse: collapse; font-family: 'Raleway', 'Helvetica Neue', 'Arial', 'sans-serif' !important; font-size: 14px; color: #777777; text-align: center; line-height: 21px; background: #f7f7f7; padding: 20px 0 5px;" class="content-padding" bgcolor="#f7f7f7">
<center style="font-family: 'Raleway', 'Helvetica Neue', 'Arial', 'sans-serif' !important;">
<table cellspacing="0" cellpadding="0" width="600" class="w320" style="border-collapse: collapse !important; font-family: 'Raleway', 'Helvetica Neue', 'Arial', 'sans-serif' !important;">
<tr style="font-family: 'Raleway', 'Helvetica Neue', 'Arial', 'sans-serif' !important;">
<td class="header-lg" style="border-collapse: collapse; font-family: 'Raleway', 'Helvetica Neue', 'Arial', 'sans-serif' !important; font-size: 32px; color: #4d4d4d; text-align: center; line-height: normal; font-weight: 700; padding: 35px 0 0;" align="center">
User {{user.name}}/{{user.email}} requested a booking cancellation
</td>
</tr>
<tr style="font-family: 'Raleway', 'Helvetica Neue', 'Arial', 'sans-serif' !important;">
<td class="free-text" style="border-collapse: collapse; font-family: 'Raleway', 'Helvetica Neue', 'Arial', 'sans-serif' !important; font-size: 14px; color: #777777; text-align: center; line-height: 21px; width: 100% !important; padding: 40px 60px 20px;" align="center">
{{user.name}} requested a booking cancellation from following dates. <br/> {{booking.start_date|date}} to {{booking.end_date|date}} <br/>
</td>
</tr>
<tr style="font-family: 'Raleway', 'Helvetica Neue', 'Arial', 'sans-serif' !important;">
<td class="button" style="border-collapse: collapse; font-family: 'Raleway', 'Helvetica Neue', 'Arial', 'sans-serif' !important; font-size: 14px; color: #777777; text-align: center; line-height: 21px; padding: 30px 0;" align="center">
<div style="font-family: 'Raleway', 'Helvetica Neue', 'Arial', 'sans-serif' !important;">
<!--[if mso]>
<v:roundrect xmlns:v="urn:schemas-microsoft-com:vml" xmlns:w="urn:schemas-microsoft-com:office:word" href="http://" style="height:45px;v-text-anchor:middle;width:155px;" arcsize="15%" strokecolor="#ffffff" fillcolor="#ff6f6f">
<w:anchorlock/>
<center style="color:#ffffff;font-family:Helvetica, Arial, sans-serif;font-size:14px;font-weight:regular;">My Account</center>
</v:roundrect>
<![endif]-->
</div>
</td>
</tr>
</table>
</center>
</td>
</tr>
<tr style="font-family: 'Raleway', 'Helvetica Neue', 'Arial', 'sans-serif' !important;">
<td align="center" valign="top" width="100%" style="height: 100px; border-collapse: collapse; font-family: 'Raleway', 'Helvetica Neue', 'Arial', 'sans-serif' !important; font-size: 14px; color: #777777; text-align: center; line-height: 21px; background: #f7f7f7;" bgcolor="#f7f7f7">
<center style="font-family: 'Raleway', 'Helvetica Neue', 'Arial', 'sans-serif' !important;">
<table cellspacing="0" cellpadding="0" width="600" class="w320" style="border-collapse: collapse !important; font-family: 'Oxygen', 'Helvetica Neue', 'Arial', 'sans-serif' !important;"><tr style="font-family: 'Raleway', 'Helvetica Neue', 'Arial', 'sans-serif' !important;">
<td style="border-collapse: collapse; font-family: 'Raleway', 'Helvetica Neue', 'Arial', 'sans-serif' !important; font-size: 15px; color: #777777; text-align: center; line-height: 21px;;" align="center">
<strong style="font-family: 'Raleway', 'Helvetica Neue', 'Arial', 'sans-serif' !important;">Your Digital Glarus Team</strong><br style="font-family: 'Raleway', 'Helvetica Neue', 'Arial', 'sans-serif' !important;">
</td>
</tr></table>
</center>
</td>
</tr>
</table>
</body>
</html>

View File

@ -0,0 +1,136 @@
{% load static from staticfiles %}
<!-- Inliner Build Version 4380b7741bb759d6cb997545f3add21ad48f010b -->
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" style="font-family: 'Raleway', 'Helvetica Neue', 'Arial', 'sans-serif' !important;">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Oxygen Invoice</title>
</head>
<body bgcolor="#f7f7f7" style="font-family: 'Raleway', 'Helvetica Neue', 'Arial', 'sans-serif' !important; -webkit-font-smoothing: antialiased; -webkit-text-size-adjust: none; width: 100% !important; height: 100%; color: white; margin: 0;">
<style type="text/css">
@media only screen and (max-width: 480px) {
table[class*="container-for-gmail-android"] {
min-width: 290px !important; width: 100% !important;
}
img[class="force-width-gmail"] {
display: none !important; width: 0 !important; height: 0 !important;
}
table[class="w320"] {
width: 320px !important;
}
td[class*="mobile-header-padding-left"] {
width: 160px !important; padding-left: 0 !important;
}
td[class*="mobile-header-padding-right"] {
width: 160px !important; padding-right: 0 !important;
}
td[class="header-lg"] {
font-size: 24px !important; padding-bottom: 5px !important;
}
td[class="content-padding"] {
padding: 5px 0 5px !important;
}
td[class="button"] {
padding: 5px 5px 30px !important;
}
td[class*="free-text"] {
padding: 10px 18px 30px !important;
}
td[class~="mobile-hide-img"] {
display: none !important; height: 0 !important; width: 0 !important; line-height: 0 !important;
}
td[class~="item"] {
width: 140px !important; vertical-align: top !important;
}
td[class~="quantity"] {
width: 50px !important;
}
td[class~="price"] {
width: 90px !important;
}
td[class="item-table"] {
padding: 30px 20px !important;
}
td[class="mini-container-left"] {
padding: 0 15px 15px !important; display: block !important; width: 290px !important;
}
td[class="mini-container-right"] {
padding: 0 15px 15px !important; display: block !important; width: 290px !important;
}
}
</style>
<table align="center" cellpadding="0" cellspacing="0" class="container-for-gmail-android" width="100%" style="border-collapse: collapse !important; min-width: 600px; font-family: 'Raleway', 'Helvetica Neue', 'Arial', 'sans-serif' !important;">
<tr style="font-family: 'Raleway', 'Helvetica Neue', 'Arial', 'sans-serif' !important;">
<td align="left" valign="top" width="100%" style="border-collapse: collapse; font-family: 'Raleway', 'Helvetica Neue', 'Arial', 'sans-serif' !important; font-size: 14px; color: #777777; text-align: center; line-height: 21px; background: #ffffff url(http://s3.amazonaws.com/swu-filepicker/4E687TRe69Ld95IDWyEg_bg_top_02.jpg) repeat-x;" bgcolor="#ffffff">
<center style="font-family: 'Raleway', 'Helvetica Neue', 'Arial', 'sans-serif' !important;">
<table cellspacing="0" cellpadding="0" width="100%" bgcolor="#ffffff" background="http://s3.amazonaws.com/swu-filepicker/4E687TRe69Ld95IDWyEg_bg_top_02.jpg" style="border-collapse: collapse !important; font-family: 'Raleway', 'Helvetica Neue', 'Arial', 'sans-serif' !important; background: transparent;"><tr style="font-family: 'Raleway', 'Helvetica Neue', 'Arial', 'sans-serif' !important;">
<td width="100%" height="80" valign="top" style="text-align: center; vertical-align: middle; border-collapse: collapse; font-family: 'Raleway', 'Helvetica Neue', 'Arial', 'sans-serif' !important; font-size: 14px; color: #777777; line-height: 21px; background-color: #0f1221" align="center">
<!--[if gte mso 9]>
<v:rect xmlns:v="urn:schemas-microsoft-com:vml" fill="true" stroke="false" style="mso-width-percent:1000;height:80px; v-text-anchor:middle;">
<v:fill type="tile" src="http://s3.amazonaws.com/swu-filepicker/4E687TRe69Ld95IDWyEg_bg_top_02.jpg" color="#ffffff" />
<v:textbox inset="0,0,0,0">
<![endif]-->
<center style="font-family: 'Raleway', 'Helvetica Neue', 'Arial', 'sans-serif' !important;">
<table cellpadding="0" cellspacing="0" width="600" class="w320" style="border-collapse: collapse !important; font-family: 'Raleway', 'Helvetica Neue', 'Arial', 'sans-serif' !important;"><tr style="font-family: 'Raleway', 'Helvetica Neue', 'Arial', 'sans-serif' !important;">
<td class="pull-left mobile-header-padding-left" style="vertical-align: middle; border-collapse: collapse; font-family: 'Raleway', 'Helvetica Neue', 'Arial', 'sans-serif' !important; font-size: 14px; color: #777777; text-align: left; line-height: 21px; width: 290px; padding-left: 10px;" align="left" valign="middle">
<a href="{{base_url}}" style="font-family: 'Raleway', 'Helvetica Neue', 'Arial', 'sans-serif' !important; color: #676767; text-decoration: none !important;"><img width="137" src="{{base_url}}{% static 'digitalglarus/img/logo_white.svg' %}" alt="logo" style="max-width: 600px; outline: none; text-decoration: none; -ms-interpolation-mode: bicubic; font-family: 'Raleway', 'Helvetica Neue', 'Arial', 'sans-serif' !important; border: none;"></a>
</td>
<td class="pull-right mobile-header-padding-right" style="color: #4d4d4d; border-collapse: collapse; font-family: 'Raleway', 'Helvetica Neue', 'Arial', 'sans-serif' !important; font-size: 14px; text-align: right; line-height: 21px; width: 290px; padding-left: 10px;" align="right">
</td>
</tr></table>
</center>
<!--[if gte mso 9]>
</v:textbox>
</v:rect>
<![endif]-->
</td>
</tr></table>
</center>
</td>
</tr>
<tr style="font-family: 'Raleway', 'Helvetica Neue', 'Arial', 'sans-serif' !important;">
<td align="center" valign="top" width="100%" style="border-collapse: collapse; font-family: 'Raleway', 'Helvetica Neue', 'Arial', 'sans-serif' !important; font-size: 14px; color: #777777; text-align: center; line-height: 21px; background: #f7f7f7; padding: 20px 0 5px;" class="content-padding" bgcolor="#f7f7f7">
<center style="font-family: 'Raleway', 'Helvetica Neue', 'Arial', 'sans-serif' !important;">
<table cellspacing="0" cellpadding="0" width="600" class="w320" style="border-collapse: collapse !important; font-family: 'Raleway', 'Helvetica Neue', 'Arial', 'sans-serif' !important;">
<tr style="font-family: 'Raleway', 'Helvetica Neue', 'Arial', 'sans-serif' !important;">
<td class="header-lg" style="border-collapse: collapse; font-family: 'Raleway', 'Helvetica Neue', 'Arial', 'sans-serif' !important; font-size: 32px; color: #4d4d4d; text-align: center; line-height: normal; font-weight: 700; padding: 35px 0 0;" align="center">
User {{user.name}}/{{user.email}} requested a booking cancellation
</td>
</tr>
<tr style="font-family: 'Raleway', 'Helvetica Neue', 'Arial', 'sans-serif' !important;">
<td class="free-text" style="border-collapse: collapse; font-family: 'Raleway', 'Helvetica Neue', 'Arial', 'sans-serif' !important; font-size: 14px; color: #777777; text-align: center; line-height: 21px; width: 100% !important; padding: 40px 60px 20px;" align="center">
{{user.name}} requested a booking cancellation from following dates. <br/> {{booking.start_date|date}} to {{booking.end_date|date}} <br/>
</td>
</tr>
<tr style="font-family: 'Raleway', 'Helvetica Neue', 'Arial', 'sans-serif' !important;">
<td class="button" style="border-collapse: collapse; font-family: 'Raleway', 'Helvetica Neue', 'Arial', 'sans-serif' !important; font-size: 14px; color: #777777; text-align: center; line-height: 21px; padding: 30px 0;" align="center">
<div style="font-family: 'Raleway', 'Helvetica Neue', 'Arial', 'sans-serif' !important;">
<!--[if mso]>
<v:roundrect xmlns:v="urn:schemas-microsoft-com:vml" xmlns:w="urn:schemas-microsoft-com:office:word" href="http://" style="height:45px;v-text-anchor:middle;width:155px;" arcsize="15%" strokecolor="#ffffff" fillcolor="#ff6f6f">
<w:anchorlock/>
<center style="color:#ffffff;font-family:Helvetica, Arial, sans-serif;font-size:14px;font-weight:regular;">My Account</center>
</v:roundrect>
<![endif]-->
</div>
</td>
</tr>
</table>
</center>
</td>
</tr>
<tr style="font-family: 'Raleway', 'Helvetica Neue', 'Arial', 'sans-serif' !important;">
<td align="center" valign="top" width="100%" style="height: 100px; border-collapse: collapse; font-family: 'Raleway', 'Helvetica Neue', 'Arial', 'sans-serif' !important; font-size: 14px; color: #777777; text-align: center; line-height: 21px; background: #f7f7f7;" bgcolor="#f7f7f7">
<center style="font-family: 'Raleway', 'Helvetica Neue', 'Arial', 'sans-serif' !important;">
<table cellspacing="0" cellpadding="0" width="600" class="w320" style="border-collapse: collapse !important; font-family: 'Oxygen', 'Helvetica Neue', 'Arial', 'sans-serif' !important;"><tr style="font-family: 'Raleway', 'Helvetica Neue', 'Arial', 'sans-serif' !important;">
<td style="border-collapse: collapse; font-family: 'Raleway', 'Helvetica Neue', 'Arial', 'sans-serif' !important; font-size: 15px; color: #777777; text-align: center; line-height: 21px;;" align="center">
<strong style="font-family: 'Raleway', 'Helvetica Neue', 'Arial', 'sans-serif' !important;">Your Digital Glarus Team</strong><br style="font-family: 'Raleway', 'Helvetica Neue', 'Arial', 'sans-serif' !important;">
</td>
</tr></table>
</center>
</td>
</tr>
</table>
</body>
</html>

View File

@ -136,7 +136,7 @@
</p> </p>
<div class="text-center"> <div class="text-center">
<button type="submit" class="btn btn-primary btn-blue">Still have a question?</button> <a href="mailto:info@ungleich.ch" class="btn btn-primary btn-blue">Still have a question?</a>
</div> </div>
<div class="row col-md-2 text-center wow fadeInDown"> <div class="row col-md-2 text-center wow fadeInDown">
</div> </div>

View File

@ -29,6 +29,7 @@
<hr class="greyline-long"> <hr class="greyline-long">
<h2 class="billing-head">Billing Adress</h2> <h2 class="billing-head">Billing Adress</h2>
<div class="signup-form form-group row"> <div class="signup-form form-group row">
{% if current_billing_address %}
<form role="form" id="billing-address-form" method="post" action="{% url 'digitalglarus:user_billing_address' %}" novalidate> <form role="form" id="billing-address-form" method="post" action="{% url 'digitalglarus:user_billing_address' %}" novalidate>
{% for field in form %} {% for field in form %}
{% csrf_token %} {% csrf_token %}
@ -49,6 +50,12 @@
</div> </div>
</div> </div>
</form> </form>
{% else %}
<div class="text-center">
<h2 class="billing-head text-center">You don't have any order yet</h2>
</div>
{% endif %}
</div> </div>
</div> </div>

View File

@ -37,7 +37,7 @@ from .forms import LoginForm, SignupForm, MembershipBillingForm, BookingDateForm
BookingBillingForm, CancelBookingForm BookingBillingForm, CancelBookingForm
from .models import MembershipType, Membership, MembershipOrder, Booking, BookingPrice,\ from .models import MembershipType, Membership, MembershipOrder, Booking, BookingPrice,\
BookingOrder BookingOrder, BookingCancellation
from .mixins import MembershipRequiredMixin, IsNotMemberMixin from .mixins import MembershipRequiredMixin, IsNotMemberMixin
@ -519,6 +519,14 @@ class UserBillingAddressView(LoginRequiredMixin, UpdateView):
return next_url return next_url
def get_context_data(self, **kwargs):
context = super(UserBillingAddressView, self).get_context_data(**kwargs)
current_billing_address = self.request.user.billing_addresses.first()
context.update({
'current_billing_address': current_billing_address
})
return current_billing_address
def form_valid(self, form): def form_valid(self, form):
""" """
If the form is valid, save the associated model. If the form is valid, save the associated model.
@ -546,8 +554,8 @@ class UserBillingAddressView(LoginRequiredMixin, UpdateView):
def get_object(self): def get_object(self):
current_billing_address = self.request.user.billing_addresses.filter(current=True).last() current_billing_address = self.request.user.billing_addresses.filter(current=True).last()
if not current_billing_address: # if not current_billing_address:
raise AttributeError("Billing Address does not exists") # raise AttributeError("Billing Address does not exists")
return current_billing_address return current_billing_address
@ -639,6 +647,27 @@ class OrdersBookingDetailView(LoginRequiredMixin, UpdateView):
booking_order.cancel() booking_order.cancel()
request = self.request request = self.request
BookingCancellation.create(booking_order)
context = {
'order': booking_order,
'booking': booking_order.booking,
'base_url': "{0}://{1}".format(request.scheme, request.get_host()),
'user': request.user
}
email_data = {
'subject': 'A cancellation has been requested',
'to': 'info@ungleich.ch',
'context': context,
'template_name': 'booking_cancellation_notification',
'template_path': 'digitalglarus/emails/'
}
email = BaseEmail(**email_data)
email.send()
context = { context = {
'order': booking_order, 'order': booking_order,
'booking': booking_order.booking, 'booking': booking_order.booking,
@ -646,7 +675,7 @@ class OrdersBookingDetailView(LoginRequiredMixin, UpdateView):
} }
email_data = { email_data = {
'subject': 'Your membership has been charged', 'subject': 'Your booking has been cancelled',
'to': request.user.email, 'to': request.user.email,
'context': context, 'context': context,
'template_name': 'booking_cancellation', 'template_name': 'booking_cancellation',