Skip to content

Commit

Permalink
Merge pull request #244 from rayrayndwiga/master
Browse files Browse the repository at this point in the history
PS & WL: Various bug fixes
  • Loading branch information
dbca-asi committed Oct 31, 2017
2 parents 85b342a + 6f8bf39 commit dc24b45
Show file tree
Hide file tree
Showing 11 changed files with 72 additions and 22 deletions.
4 changes: 2 additions & 2 deletions parkstay/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -901,8 +901,8 @@ def retrieve(self, request, pk=None, ratis_id=None , format=None):
if ground.campground_type != 0:
return Response({'error': 'Campground doesn\'t support online bookings'}, status=400)

if not ground._is_open(start_date):
return Response({'closed': 'Campground is closed for your selected dates'}, status=status.HTTP_400_BAD_REQUEST)
#if not ground._is_open(start_date):
# return Response({'closed': 'Campground is closed for your selected dates'}, status=status.HTTP_400_BAD_REQUEST)

# get a length of the stay (in days), capped if necessary to the request maximum
length = max(0, (end_date-start_date).days)
Expand Down
12 changes: 12 additions & 0 deletions parkstay/emails.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,17 @@ def send_booking_confirmation(booking,request):
my_bookings_url = request.build_absolute_uri('/mybookings/')
booking_availability = request.build_absolute_uri('/availability/?site_id={}'.format(booking.campground.id))
unpaid_vehicle = False
mobile_number = booking.customer.mobile_number
booking_number = booking.details.get('phone',None)
phone_number = booking.customer.phone_number
tel = None
if booking_number:
tel = booking_number
elif mobile_number:
tel = mobile_number
else:
tel = phone_number
tel = tel if tel else ''

for v in booking.vehicle_payment_status:
if v.get('Paid') == 'No':
Expand All @@ -62,6 +73,7 @@ def send_booking_confirmation(booking,request):

context = {
'booking': booking,
'phone_number': tel,
'campground_email': campground_email,
'my_bookings': my_bookings_url,
'availability': booking_availability,
Expand Down
25 changes: 20 additions & 5 deletions parkstay/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1392,9 +1392,15 @@ def _post_delete(sender, instance, **kwargs):
if linked_open:
linked_open = linked_open[0]
linked_open.range_start = instance.range_start
else:
linked_open = None
else:
linked_open.range_start = today
if len(linked_open) > 0:
if linked_open:
linked_open = linked_open[0]
linked_open.range_start = today
else:
linked_open = None
if linked_open:
linked_open[0].save(skip_validation=True)
except CampgroundBookingRange.DoesNotExist:
pass
Expand Down Expand Up @@ -1505,10 +1511,19 @@ def _post_delete(sender, instance, **kwargs):
try:
linked_open = CampsiteBookingRange.objects.get(range_start=instance.range_end + timedelta(days=1), status=0)
if instance.range_start >= today:
linked_open.range_start = instance.range_start
if linked_open:
linked_open = linked_open[0]
linked_open.range_start = instance.range_start
else:
linked_open = None
else:
linked_open.range_start = today
linked_open.save(skip_validation=True)
if linked_open:
linked_open = linked_open[0]
linked_open.range_start = today
else:
linked_open = None
if linked_open:
linked_open[0].save(skip_validation=True)
except CampsiteBookingRange.DoesNotExist:
pass
elif instance.status != 0 and not instance.range_end:
Expand Down
5 changes: 5 additions & 0 deletions parkstay/templates/ps/booking/make_booking.html
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,11 @@ <h3 class="text-primary">Vehicles</h3>
</div>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<p style="margin-top:30px;">Changes not permitted.Cancel up to 29 days before arrival for 50% refund.</p>
</div>
</div>
</div>

<div class="row">
Expand Down
20 changes: 13 additions & 7 deletions parkstay/templates/ps/email/confirmation.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
<p>Print or save this confirmation for presentation on arrival and at any time during your stay.</p>

<p>Arrival: {{booking.arrival|date:"d/m/Y"}}</p>
<p>Departure: {{booking.departure|date:"d/m/Y"}}</p><br />
<p>Departure: {{booking.departure|date:"d/m/Y"}}</p>

{% if booking.campground.site_type == 2 %}
<p>Campsite: {{booking.first_campsite.type}}</p>
{% else %}
<p>Campsite: {{booking.first_campsite.name}} ({{booking.first_campsite.type}})</p><br />
<p>Campsite: {{booking.first_campsite.name}} ({{booking.first_campsite.type}})</p>
{% endif %}
<p>Campers: {{booking.stay_guests}}</p><br />
<p>Campers: {{booking.stay_guests}}</p>

{% for v in booking.vehicle_payment_status %}
{% if not v.Paid %}
Expand All @@ -24,17 +24,23 @@
<p>Vehicle: {{v.Rego}}, {{v.Type}}, {% if v.Paid == 'Yes' %} Entry fee paid {% elif v.Paid == 'No' %} Unpaid {% elif v.Paid == 'pass_required' %} Park Pass Required {% endif %}</p>
{% endif %}
{% endfor %}

<p>Phone Number: {{phone_number}}</p>
<br />

{% if unpaid_vehicle %}
<p>Purchase a park entry pass at our <a href="https://shop.dpaw.wa.gov.au/park-passes">online store</a> or <a href="{{EXPLORE_PARKS_ENTRY_FEES}}">pay on arrival</a></p>
{% endif %}

<p>About {{booking.campground.name}} and booking conditions {{availability}}</p><br />
<a href="{{availability}}">About {{booking.campground.name}} and booking conditions</a>

<p>Before you go, check</p>
<p>Before you go, check:</p>

<p>Your contact details and vehicle registration are correct [link to on screen details] The <a href="http://www.bom.gov.au/">Bureau of Meteorology</a> for weather forecasts and warnings <a href="https://www.emergency.wa.gov.au/">Emergency WA</a> for warnings and incidents The <a href="http://www.abc.net.au/">ABC</a> radio frequency for the area you are visiting (ABC local radio broadcasts emergency information)</p><br />
<ul>
<li>Your contact details and vehicle registration are correct</li>
<li>The <a href="http://www.bom.gov.au/">Bureau of Meteorology</a> for weather forecasts and warnings <a href="https://www.emergency.wa.gov.au/">Emergency WA</a> for warnings and incidents</li>
<li>The <a href="http://www.abc.net.au/">ABC</a> radio frequency for the area you are visiting (ABC local radio broadcasts emergency information)</li>
</ul>

<p>Contact us about your booking</p>
<p>{{campground_email}}</p>
Expand All @@ -43,5 +49,5 @@
{% endif %}
<br />

<p>View my Park Stay WA bookings {{my_bookings}}</p>
<a href="{{my_bookings}}">View my Park Stay WA bookings</a>
{% endblock %}
6 changes: 5 additions & 1 deletion parkstay/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,10 +218,14 @@ def get_campsite_availability(campsites_qs, start_date, end_date):
for closure in cgbr_qs:
start = max(start_date, closure.range_start)
end = min(end_date, closure.range_end) if closure.range_end else end_date
today = date.today()
for i in range((end-start).days):
for cs in campground_map[closure.campground.pk]:
#results[cs][start+timedelta(days=i)][0] = 'closed'
if not closure.campground._is_open(start+timedelta(days=i)):
if start+timedelta(days=i) == today:
if not closure.campground._is_open(start+timedelta(days=i)):
results[cs][start+timedelta(days=i)][0] = 'closed'
else:
results[cs][start+timedelta(days=i)][0] = 'closed'

# strike out campsite closures
Expand Down
2 changes: 2 additions & 0 deletions wildlifelicensing/apps/applications/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,8 @@ def format_application(instance, attrs):
attrs['licence_type']['default_conditions'] = serialize([ap.condition for ap in instance.licence_type.defaultcondition_set.order_by('order')])
attrs['conditions'] = serialize([ap.condition for ap in instance.applicationcondition_set.order_by('order')])

attrs['applicant_profile']['user'] = serialize(instance.applicant_profile.user,exclude=['postal_address','residential_address','billing_address'])
attrs['applicant_profile']['postal_address'] = serialize(instance.applicant_profile.postal_address,exclude=['user','oscar_address'])
if instance.applicant.identification is not None and instance.applicant.identification.file is not None:
attrs['applicant']['identification']['url'] = instance.applicant.identification.file.url
if instance.applicant.senior_card is not None and instance.applicant.senior_card.file is not None:
Expand Down
6 changes: 4 additions & 2 deletions wildlifelicensing/apps/applications/views/conditions.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ def get_context_data(self, **kwargs):

convert_documents_to_url(application.data, application.documents.all(), '')

kwargs['application'] = serialize(application, posthook=format_application)
#kwargs['application'] = serialize(application, posthook=format_application)
kwargs['application'] = serialize(application,posthook=format_application,related={'applicant': {'exclude': ['residential_address','postal_address','billing_address']},'applicant_profile':{'fields':['email','id','institution','name']}})
kwargs['form_structure'] = application.licence_type.application_schema
kwargs['assessments'] = serialize(Assessment.objects.filter(application=application),
posthook=format_assessment)
Expand Down Expand Up @@ -92,7 +93,8 @@ def get_context_data(self, **kwargs):

convert_documents_to_url(application.data, application.documents.all(), '')

kwargs['application'] = serialize(application, posthook=format_application)
#kwargs['application'] = serialize(application, posthook=format_application)
kwargs['application'] = serialize(application,posthook=format_application,related={'applicant': {'exclude': ['residential_address','postal_address','billing_address']},'applicant_profile':{'fields':['email','id','institution','name']}})
kwargs['form_structure'] = application.licence_type.application_schema

kwargs['assessment'] = serialize(assessment, post_hook=format_assessment)
Expand Down
9 changes: 6 additions & 3 deletions wildlifelicensing/apps/applications/views/issue.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,8 @@ def _issue_licence(self, request, application, issue_licence_form):
def get_context_data(self, **kwargs):
application = get_object_or_404(Application, pk=self.args[0])

kwargs['application'] = serialize(application, posthook=format_application)
#kwargs['application'] = serialize(application, posthook=format_application)
kwargs['application'] = serialize(application,posthook=format_application,related={'applicant': {'exclude': ['residential_address','postal_address','billing_address']},'applicant_profile':{'fields':['email','id','institution','name']}})

if application.licence:
kwargs['issue_licence_form'] = IssueLicenceForm(instance=application.licence)
Expand Down Expand Up @@ -273,7 +274,8 @@ def post(self, request, *args, **kwargs):
messages.warning(request, 'Licence saved but not yet issued.')

return render(request, self.template_name, {
'application': serialize(application, posthook=format_application),
#'application': serialize(application, posthook=format_application),
'application': serialize(application,posthook=format_application,related={'applicant': {'exclude': ['residential_address','postal_address','billing_address']},'applicant_profile':{'fields':['email','id','institution','name']}}),
'issue_licence_form': issue_licence_form,
'extracted_fields': extracted_fields,
'payment_status': payment_status_verbose,
Expand All @@ -291,7 +293,8 @@ def post(self, request, *args, **kwargs):
messages.error(request, 'Please fix the errors below before saving / issuing the licence.')

return render(request, self.template_name, {
'application': serialize(application, posthook=format_application),
#'application': serialize(application, posthook=format_application),
'application': serialize(application,posthook=format_application,related={'applicant': {'exclude': ['residential_address','postal_address','billing_address']},'applicant_profile':{'fields':['email','id','institution','name']}}),
'issue_licence_form': issue_licence_form,
'extracted_fields': extracted_fields,
'payment_status': payment_status_verbose,
Expand Down
3 changes: 2 additions & 1 deletion wildlifelicensing/apps/applications/views/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ def _build_data(self, request, application):

data = {
'user': serialize(request.user),
'application': serialize(application, posthook=format_application),
#'application': serialize(application, posthook=format_application),
'application': serialize(application,posthook=format_application,related={'applicant': {'exclude': ['residential_address','postal_address','billing_address']},'applicant_profile':{'fields':['email','id','institution','name']}}),
'form_structure': application.licence_type.application_schema,
'officers': officers,
'amendment_requests': serialize(AmendmentRequest.objects.filter(application=application),
Expand Down
2 changes: 1 addition & 1 deletion wildlifelicensing/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
STATICFILES_DIRS.append(os.path.join(os.path.join(BASE_DIR, 'wildlifelicensing', 'static')))

CRON_CLASSES = [
'wildlifelicensing.apps.applications.cron.AssessmentRemindersCronJob',
#'wildlifelicensing.apps.applications.cron.AssessmentRemindersCronJob',
'wildlifelicensing.apps.main.cron.CheckLicenceRenewalsCronJob',
'wildlifelicensing.apps.returns.cron.CheckOverdueReturnsCronJob',
]
Expand Down

0 comments on commit dc24b45

Please sign in to comment.