Skip to content

Commit

Permalink
Merge pull request #558 from xzzy/master
Browse files Browse the repository at this point in the history
Rottnest Bug Fixes
  • Loading branch information
dbca-asi committed Mar 12, 2019
2 parents 582bb3b + 63ec6be commit f7c3025
Show file tree
Hide file tree
Showing 27 changed files with 305 additions and 42 deletions.
14 changes: 12 additions & 2 deletions mooring/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import calendar
import time
import math
import hashlib
from six.moves.urllib.parse import urlparse
from wsgiref.util import FileWrapper
from django.db.models import Q, Min
Expand Down Expand Up @@ -1847,8 +1848,16 @@ def retrieve(self, request, pk=None, ratis_id=None, format=None, show_all=False)
## row['item'] = ms.campsite.name
# total_price = total_price +ms.amount
# current_booking.append(row)


booking_changed = True
if ongoing_booking.old_booking:

current_booking_obj = MooringsiteBooking.objects.filter(booking=ongoing_booking).values('campsite','from_dt','to_dt','booking_period_option')
old_booking_obj = MooringsiteBooking.objects.filter(booking=ongoing_booking.old_booking).values('campsite','from_dt','to_dt','booking_period_option')
# compare old and new booking for changes
if hashlib.md5(str(current_booking_obj)).hexdigest() == hashlib.md5(str(old_booking_obj)).hexdigest():
booking_changed = False


availability = utils.get_campsite_availability(sites_qs, start_date, end_date, ongoing_booking, request)
# create our result object, which will be returned as JSON
result = {
Expand All @@ -1858,6 +1867,7 @@ def retrieve(self, request, pk=None, ratis_id=None, format=None, show_all=False)
'map': ground.mooring_map.url if ground.mooring_map else None,
'ongoing_booking': True if ongoing_booking else False,
'ongoing_booking_id': ongoing_booking.id if ongoing_booking else None,
'booking_changed': booking_changed,
'expiry': expiry,
'timer': timer,
'current_booking': current_booking,
Expand Down
4 changes: 3 additions & 1 deletion mooring/context_processors.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ def mooring_url(request):
web_url = request.META['HTTP_HOST']
if web_url in settings.ROTTNEST_ISLAND_URL:
template_group = 'rottnest'
TERMS = "https://www.rottnestisland.com/boating/moorings/Rental%20Moorings%20and%20Jetty%20Pens"
else:
template_group = 'pvs'
TERMS = "/know/online-mooring-site-booking-terms-and-conditions"

is_officer = False
is_inventory = False
Expand All @@ -31,7 +33,7 @@ def mooring_url(request):
'EXPLORE_PARKS_CONSERVE': '/know/conserving-our-moorings',
'EXPLORE_PARKS_PEAK_PERIODS': '/know/when-visit',
'EXPLORE_PARKS_ENTRY_FEES': '/know/entry-fees',
'EXPLORE_PARKS_TERMS': '/know/online-mooring-site-booking-terms-and-conditions',
'EXPLORE_PARKS_TERMS': TERMS,
'PARKSTAY_EXTERNAL_URL': settings.PARKSTAY_EXTERNAL_URL,
'DEV_STATIC': settings.DEV_STATIC,
'DEV_STATIC_URL': settings.DEV_STATIC_URL,
Expand Down
54 changes: 54 additions & 0 deletions mooring/emails.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,48 @@ def send_booking_period_email(moorings, group, days):
}
email_obj.send(emails, from_address=default_from_email, context=context)

### Admission Emails
def send_refund_failure_email_admissions(booking, context_processor):

subject = 'Failed to refund for {}, requires manual intervention.'.format(booking)
template = 'mooring/email/refund_failed_admissions.html'
cc = None
bcc = None
from_email = None
context= {'booking': booking}
template_group = context_processor['TEMPLATE_GROUP']
if not settings.PRODUCTION_EMAIL:
to = settings.NON_PROD_EMAIL
sendHtmlEmail([to],subject,context,template,cc,bcc,from_email,template_group,attachments=None)
else:
for u in user_list:
to = u.email
sendHtmlEmail([to],subject,context,template,cc,bcc,from_email,template_group,attachments=None)


def send_refund_completed_email_customer_admissions(booking, context_processor):
subject = 'Your refund for booking {} was completed.'.format(booking.id)
template = 'mooring/email/refund_completed_customer_admissions.html'
cc = None
bcc = None
from_email = None
context= {'booking': booking}
to = booking.customer.email
template_group = context_processor['TEMPLATE_GROUP']
sendHtmlEmail([to],subject,context,template,cc,bcc,from_email,template_group,attachments=None)

def send_refund_failure_email_customer_admissions(booking, context_processor):

subject = 'Your refund for booking has failed {}.'.format(booking.id)
template = 'mooring/email/refund_failed_customer_admissions.html'
cc = None
bcc = None
from_email = None
context= {'booking': booking}
to = booking.customer.email
template_group = context_processor['TEMPLATE_GROUP']
sendHtmlEmail([to],subject,context,template,cc,bcc,from_email,template_group,attachments=None)
####

def send_refund_failure_email(booking, context_processor):

Expand All @@ -381,6 +423,18 @@ def send_refund_failure_email(booking, context_processor):
to = u.email
sendHtmlEmail([to],subject,context,template,cc,bcc,from_email,template_group,attachments=None)


def send_refund_completed_email_customer(booking, context_processor):
subject = 'Your refund for booking {} was completed.'.format(booking.id)
template = 'mooring/email/refund_completed_customer.html'
cc = None
bcc = None
from_email = None
context= {'booking': booking}
to = booking.customer.email
template_group = context_processor['TEMPLATE_GROUP']
sendHtmlEmail([to],subject,context,template,cc,bcc,from_email,template_group,attachments=None)

def send_refund_failure_email_customer(booking, context_processor):

subject = 'Your refund for booking has failed {}.'.format(booking.id)
Expand Down
2 changes: 1 addition & 1 deletion mooring/frontend/admissions/src/admissions.vue
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ export default {
lastName: lastName,
email: email,
location: location,
mooring_group: mooring_group
// mooring_group: mooring_group
}
$.ajax({
url: vm.mooringUrl + "/api/create_admissions_booking",
Expand Down
6 changes: 4 additions & 2 deletions mooring/frontend/availability2/src/availability.vue
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@
<button title="Please enter vessel details" style="border-radius: 4px; border: 1px solid #2e6da4" class="button small-12 medium-12 large-12" @click="validateVessel()">Proceed to Check Out</button>
</div>
<div v-else>
<a v-show="current_booking.length > 0" class="button small-12 medium-12 large-12" :href="parkstayUrl+'/booking'" style="border-radius: 4px; border: 1px solid #2e6da4">Proceed to Check Out</a>
<button title="Please add items into your trolley." v-show="current_booking.length == 0 " style="color: #000000; background-color: rgb(224, 217, 217); border: 1px solid #000; border-radius: 4px;" class="button small-12 medium-12 large-12" disabled >Add items to Proceed to Check Out</button> </div>
<a v-show="current_booking.length > 0 && booking_changed == true" class="button small-12 medium-12 large-12" :href="parkstayUrl+'/booking'" style="border-radius: 4px; border: 1px solid #2e6da4">Proceed to Check Out</a>
<button title="Please add items into your trolley." v-show="current_booking.length == 0 || booking_changed == false" style="color: #000000; background-color: rgb(224, 217, 217); border: 1px solid #000; border-radius: 4px;" class="button small-12 medium-12 large-12" disabled >Add items to Proceed to Check Out</button> </div>
</div>
</div>
</div>
Expand Down Expand Up @@ -511,6 +511,7 @@ export default {
ongoing_booking: false,
ongoing_booking_id: null,
current_booking: [],
booking_changed: true,
total_booking: '0.00',
showSecondErrorLine: true,
timer: -1,
Expand Down Expand Up @@ -1004,6 +1005,7 @@ export default {
vm.max_advance_booking = data.max_advance_booking;
vm.max_advance_booking_days = data.max_advance_booking_days;
vm.current_booking = data.current_booking;
vm.booking_changed = data.booking_changed;
vm.total_booking = data.total_booking;
vm.timer = data.timer;
vm.expiry = data.expiry;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,7 @@ export default {
if (full.booking_type == 0 || full.booking_type == 1 || full.booking_type == 2) {
var cancel_booking = "<a href='/cancel-admissions-booking/"+full.id+"' class='text-primary'> Cancel</a><br/>";
column += cancel_booking;
}
}
}
// invoices += " <a href='/booking-history/{{ full.id }}'>View History</a>";
column += invoices;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,9 @@ module.exports = {
vm.form.validate({
rules: {
closure_start: "required",
closure_start_time: "required",
closure_end: "required",
closure_end_time: "required",
closure_status: "required",
closure_details: {
required: {
Expand All @@ -185,6 +188,9 @@ module.exports = {
},
messages: {
closure_start: "Enter a start date",
closure_start_time: "Enter a start time",
closure_end: "Enter a end date",
closure_end_time: "Enter a end time",
closure_status: "Select a closure reason from the options",
closure_details: "Details required if Other reason is selected"
},
Expand Down
4 changes: 2 additions & 2 deletions mooring/management/commands/set_global_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def handle(self, *args, **options):
for i in range(15):
if GlobalSettings.objects.filter(mooring_group=group, key=i).count() == 0:
if i == 0:
value = 25
value = 0
if i == 1:
value = 31
if i == 2:
Expand All @@ -27,4 +27,4 @@ def handle(self, *args, **options):
if i in (5,8,11,14):
value = 100

new = GlobalSettings.objects.create(mooring_group=group, key=i, value=value)
new = GlobalSettings.objects.create(mooring_group=group, key=i, value=value)
26 changes: 26 additions & 0 deletions mooring/migrations/0119_auto_20190307_1359.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.10.8 on 2019-03-07 05:59
from __future__ import unicode_literals

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
('mooring', '0118_admissionsbooking_location'),
]

operations = [
migrations.AddField(
model_name='refundfailed',
name='admission_booking',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='mooring.AdmissionsBooking'),
),
migrations.AlterField(
model_name='refundfailed',
name='booking',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='booking_refund', to='mooring.Booking'),
),
]
3 changes: 2 additions & 1 deletion mooring/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1958,7 +1958,8 @@ class RefundFailed(models.Model):
)


booking = models.ForeignKey(Booking, related_name = "booking_refund")
booking = models.ForeignKey(Booking, related_name = "booking_refund", null=True, blank=True)
admission_booking = models.ForeignKey(AdmissionsBooking, null=True, blank=True)
invoice_reference = models.CharField(max_length=50, null=True, blank=True, default='')
refund_amount = models.DecimalField(max_digits=8, decimal_places=2, default='0.00', blank=False, null=False)
status = models.SmallIntegerField(choices=STATUS, default=0)
Expand Down
2 changes: 1 addition & 1 deletion mooring/static/admissions/js/app.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion mooring/static/availability2/js/app.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion mooring/static/parkstay/js/parkstay.js

Large diffs are not rendered by default.

22 changes: 22 additions & 0 deletions mooring/templates/mooring/booking/admission_cancel_completed.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{% extends 'mooring/base.html' %}
{% load static %}
{% load forms %}
{% block content %}
<div class="container">
<div class="well">
<div class="row"><div class="col-sm-12">
<h2>Cancellation Completed</h2>
<p>A confirmation email has been sent to {{ booking.customer.email }}. </p>
{% if refund_failed %}
Your refund has failed. A reference number for your refund is :
{% for i in refund_failed %}
{{ i.id }}
{% endfor %}
A job has been creating to manually process your refund. This can take upto 28 days.
{% else %}
Your refund was automatically refunded to you. Please allow upto 1 - 3 business days for the refund to appear in your account.
{% endif %}
</div></div>
</div>
</div>
{% endblock %}
24 changes: 24 additions & 0 deletions mooring/templates/mooring/booking/cancel_completed.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{% extends 'mooring/base.html' %}
{% load static %}
{% load forms %}
{% block content %}
<div class="container">
<div class="well">
<div class="row"><div class="col-sm-12">
<h2>Cancellation Completed</h2>
<p>A confirmation email has been sent to {{ booking.customer.email }}. </p>
{% if booking.cost_total < 0 %}
{% if refund_failed %}
Your refund has failed. A reference number for your refund is :
{% for i in refund_failed %}
{{ i.id }}
{% endfor %}
A job has been creating to manually process your refund. This can take upto 28 days.
{% else %}
A refund has automatically been refunded to you, please allow 1-3 business days for the money to be credit to your account.
{%endif %}
{% endif %}
</div></div>
</div>
</div>
{% endblock %}
6 changes: 3 additions & 3 deletions mooring/templates/mooring/booking/make_booking.html
Original file line number Diff line number Diff line change
Expand Up @@ -817,7 +817,7 @@ <h3 class="text-primary">Guest Details</h3>
vm.entryFee = 0;
vm.total = 0;
vm.total = '{{ booking_total }}';
vm.total = parseInt(vm.total);
vm.total = parseFloat(vm.total);
vm.admissionFee = 0;

if (vm.nononline){
Expand Down Expand Up @@ -884,8 +884,8 @@ <h3 class="text-primary">Guest Details</h3>
thisAdmission += (family * parseFloat(vm.linesAdmissions[i].family));
}
vm.linesAdmissions[i].admissionFee = parseFloat(thisAdmission).toFixed(2);
vm.admissionFee += parseInt(thisAdmission);
vm.total += parseInt(thisAdmission);
vm.admissionFee += parseFloat(thisAdmission);
vm.total += parseFloat(thisAdmission);

}
vm.admissionsLines = JSON.stringify(vm.linesAdmissions);
Expand Down
5 changes: 4 additions & 1 deletion mooring/templates/mooring/booking/success.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@
<div class="row"><div class="col-sm-12">
<h2>Success!</h2>
<p>A confirmation email has been sent to {{ booking.customer.email }}. </p>
<p>Please click <a href="{{EXPLORE_PARKS_SEARCH}}">here</a> if you want to make another booking.</p>
<p>{% if booking.cost_total < 0 %}{% if refund_failed|length > 0 %}Sorry your refund failed to automatically refund and require a manually refund to be completed. Please allow upto 28 days for this to be completed. Your reference is {{ refund_failed.0.refund_amount }} {% else %}A refund has automatically been refunded to you, please allow 1-3 business days for the money to be credit to your account.{%endif %}{%endif %}</p>
<p>&nbsp;</p>
<p>Please click <a href="{{EXPLORE_PARKS_SEARCH}}">here</a> if you want to make another booking.</p>

</div></div>
</div>
{% include "mooring/booking/booking_view.html" %}
Expand Down
6 changes: 6 additions & 0 deletions mooring/templates/mooring/dash/view_cancel_policy.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ <h1 class="panel-title">
<div class="col-lg-12">
&nbsp;
</div>
<div class="col-lg-12">
{% if cpo_check == False %}
<div class="alert alert-danger" role="alert"> <strong>ERROR</strong> Missing Zero day Policy </div>
{% endif %}
</div>

<table width="100%" id='table-policy' class='hover table table-striped table-bordered dt-responsive nowrap dataTable no-footer dtr-inline'>
<thead>
<tr><th>ID</th><th>Calculation Type</th><th>Amount/Percentage</th><th>Days</th><th>Action</th></tr>
Expand Down
11 changes: 8 additions & 3 deletions mooring/templates/mooring/dash/view_change_policy.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,15 @@ <h1 class="panel-title">
</div>

</div>
</div>
</div>
<div class="col-lg-12">
&nbsp;
</div>
&nbsp;
</div>
<div class="col-lg-12">
{% if cpo_check == False %}
<div class="alert alert-danger" role="alert"> <strong>ERROR</strong> Missing Zero day Policy </div>
{% endif %}
</div>
<table width="100%" id='table-policy' class='hover table table-striped table-bordered dt-responsive nowrap dataTable no-footer dtr-inline'>
<thead>
<tr><th>ID</th><th>Calculation Type</th><th>Amount/Percentage</th><th>Days</th><th>Action</th></tr>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

<p>Hello,</p>

A refund for booking PS{{ booking.id }} was automatically refunded to you.

Please allow upto 1 - 3 business days for the refund to appear in your account.


Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

<p>Hello,</p>

A refund for admission booking AD{{ booking.id }} was automatically refunded to you.

Please allow upto 1 - 3 business days for the refund to appear in your account.


11 changes: 11 additions & 0 deletions mooring/templates/mooring/email/refund_failed_admissions.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

<p>Hello,</p>
{% if booking.old_booking.id %}
<p>A refund on admission booking {{booking.old_booking.id}} with new booking {{booking.id}} has failed and require intervention.</p>
{% else %}
<p>A refund on admission booking {{booking.id}} has failed and requires intervention.</p>
{% endif %}

<p>Please check the failed refund dashboard within the department internal portal for more information.</p>


Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

<p>Hello,</p>

We failed to refund your payment automatically and require manual intervention to refund you.
We failed to refund your booking amount automatically and require manual intervention to refund you.

Please allow upto 28 days for us to manually process your refund.

Expand Down
Loading

0 comments on commit f7c3025

Please sign in to comment.