From f6b36702158cbe348dcccc9e2dc66143d2e53fc8 Mon Sep 17 00:00:00 2001 From: "jason.moore@dbca.wa.gov.au" Date: Tue, 28 Aug 2018 14:35:43 +0800 Subject: [PATCH 1/4] Bug Fixes for Mooring --- mooring/api.py | 10 ++- .../frontend/exploreparks/src/parkfinder.vue | 6 +- .../src/components/campgrounds/campground.vue | 10 +-- .../campsites-types/campsite-type.vue | 6 +- .../stayHistory/addMaximumStayPeriod.vue | 2 +- .../utils/priceHistory/priceHistory.vue | 7 +- .../utils/priceHistory/priceHistoryDetail.vue | 11 +-- .../stayHistory/addMaximumStayPeriod.vue | 2 +- .../utils/stayHistory/stayHistory.vue | 6 +- mooring/migrations/0038_auto_20180827_1341.py | 35 +++++++++ mooring/migrations/0039_auto_20180827_1422.py | 39 ++++++++++ mooring/migrations/0040_updateviews.py | 71 +++++++++++++++++++ mooring/models.py | 29 ++++---- mooring/serialisers.py | 13 ++-- mooring/static/exploreparks/js/map.js | 2 +- mooring/static/parkstay/js/parkstay.js | 2 +- mooring/utils.py | 8 +-- 17 files changed, 202 insertions(+), 57 deletions(-) create mode 100644 mooring/migrations/0038_auto_20180827_1341.py create mode 100644 mooring/migrations/0039_auto_20180827_1422.py create mode 100644 mooring/migrations/0040_updateviews.py diff --git a/mooring/api.py b/mooring/api.py index dc21f38be8..e46f4b0220 100644 --- a/mooring/api.py +++ b/mooring/api.py @@ -767,7 +767,9 @@ def addPrice(self, request, format='json', pk=None): except Rate.DoesNotExist as e : raise serializers.ValidationError('The selected rate does not exist') else: - rate = Rate.objects.get_or_create(adult=serializer.validated_data['adult'],concession=serializer.validated_data['concession'],child=serializer.validated_data['child'],infant=serializer.validated_data['infant'])[0] +# rate = Rate.objects.get_or_create(mooring=serializer.validated_data['mooring'],adult=serializer.validated_data['adult'],concession=serializer.validated_data['concession'],child=serializer.validated_data['child'],infant=serializer.validated_data['infant'])[0] +# rate = Rate.objects.get_or_create(mooring=serializer.validated_data['mooring'],adult='0.00',concession='0.00',child='0.00',infant='0.00')[0] + rate = Rate.objects.get_or_create(mooring=serializer.validated_data['mooring'])[0] if rate: serializer.validated_data['rate']= rate data = { @@ -809,7 +811,8 @@ def updatePrice(self, request, format='json', pk=None): except Rate.DoesNotExist as e : raise serializers.ValidationError('The selected rate does not exist') else: - rate = Rate.objects.get_or_create(adult=serializer.validated_data['adult'],concession=serializer.validated_data['concession'],child=serializer.validated_data['child'],infant=serializer.validated_data['infant'])[0] + #rate = Rate.objects.get_or_create(adult=serializer.validated_data['adult'],concession=serializer.validated_data['concession'],child=serializer.validated_data['child'],infant=serializer.validated_data['infant'])[0] + rate = Rate.objects.get_or_create(mooring=serializer.validated_data['mooring'])[0] if rate: serializer.validated_data['rate']= rate new_data = { @@ -1085,7 +1088,6 @@ def retrieve(self, request, pk=None, ratis_id=None, format=None, show_all=False) for date, info in dates.items() } for siteid, dates in utils.get_visit_rates(sites_qs, start_date, end_date).items() } - # fetch availability map availability = utils.get_campsite_availability(sites_qs, start_date, end_date) # create our result object, which will be returned as JSON @@ -1747,6 +1749,8 @@ def list(self, request, *args, **kwargs): for bk in data: cg = None booking = booking_map[bk['id']] + print "BOOKING STATUS" + print booking.refund_status cg = booking.mooringarea bk['editable'] = booking.editable bk['status'] = booking.status diff --git a/mooring/frontend/exploreparks/src/parkfinder.vue b/mooring/frontend/exploreparks/src/parkfinder.vue index 5edb6eb2dd..e36ec337fa 100644 --- a/mooring/frontend/exploreparks/src/parkfinder.vue +++ b/mooring/frontend/exploreparks/src/parkfinder.vue @@ -1974,8 +1974,10 @@ export default { var vessel_size = $('#vesselSize').val(); if (vessel_size > 0 ) { $("#mapPopupBook").attr('href', vm.parkstayUrl+'/availability/?site_id='+properties.marker_id+'&'+vm.bookingParam); + $("#mapPopupBook").attr('target','_blank'); } else { - $("#mapPopupBook").attr('href','javascript:void();'); + $("#mapPopupBook").attr('href','javascript:void(0);'); + $("#mapPopupBook").attr('target',''); } } else { $("#vessel_size_popup").html(properties.props.vessel_size_limit); @@ -2002,7 +2004,7 @@ export default { if (vessel_size > 0 ) { $("#mapPopupBook").attr('href', vm.parkstayUrl+'/availability/?site_id='+properties.marker_id+'&'+vm.bookingParam); } else { - $("#mapPopupBook").attr('href','javascript:void();'); + $("#mapPopupBook").attr('href','javascript:void;'); } } else { $('#mapPopupBook').hide(); diff --git a/mooring/frontend/mooring/src/components/campgrounds/campground.vue b/mooring/frontend/mooring/src/components/campgrounds/campground.vue index 69fc3512eb..e3aa31d9e0 100644 --- a/mooring/frontend/mooring/src/components/campgrounds/campground.vue +++ b/mooring/frontend/mooring/src/components/campgrounds/campground.vue @@ -153,11 +153,11 @@ export default { } }, { - data: 'adult' - }, { - data: 'concession' - }, { - data: 'child' + data: 'mooring' +// }, { +// data: 'concession' +// }, { +// data: 'child' }, { data: 'details', mRender: function(data, type, full) { diff --git a/mooring/frontend/mooring/src/components/campsites-types/campsite-type.vue b/mooring/frontend/mooring/src/components/campsites-types/campsite-type.vue index b1fb31e83b..0703b731a8 100644 --- a/mooring/frontend/mooring/src/components/campsites-types/campsite-type.vue +++ b/mooring/frontend/mooring/src/components/campsites-types/campsite-type.vue @@ -169,11 +169,7 @@ export default { } }, { - data: 'adult' - }, { - data: 'concession' - }, { - data: 'child' + data: 'mooring' }, { data: 'details', mRender: function(data, type, full) { diff --git a/mooring/frontend/mooring/src/components/campsites/stayHistory/addMaximumStayPeriod.vue b/mooring/frontend/mooring/src/components/campsites/stayHistory/addMaximumStayPeriod.vue index 0ed174e264..076135d614 100644 --- a/mooring/frontend/mooring/src/components/campsites/stayHistory/addMaximumStayPeriod.vue +++ b/mooring/frontend/mooring/src/components/campsites/stayHistory/addMaximumStayPeriod.vue @@ -127,7 +127,7 @@ module.exports = { this.stay.reason = id; }, addMaxStay: function() { - if ($(this.form).valid()){ + if ($(this.form).valid()) { if (!this.stay.id){ this.$emit('addStayHistory'); }else { diff --git a/mooring/frontend/mooring/src/components/utils/priceHistory/priceHistory.vue b/mooring/frontend/mooring/src/components/utils/priceHistory/priceHistory.vue index f1a6b2056e..bf295cb32c 100644 --- a/mooring/frontend/mooring/src/components/utils/priceHistory/priceHistory.vue +++ b/mooring/frontend/mooring/src/components/utils/priceHistory/priceHistory.vue @@ -68,7 +68,8 @@ export default { dt_headers:{ type:Array, default:function () { - return ['Period Start', 'Period End', 'Adult Price', 'Concession Price', 'Child Price', 'Comment', 'Action']; +// return ['Period Start', 'Period End', 'Adult Price', 'Concession Price', 'Child Price', 'Comment', 'Action']; + return ['Period Start', 'Period End', 'Mooring Price', 'Comment', 'Action']; } } }, @@ -119,11 +120,11 @@ export default { getTitle: function() { if (this.price.id || this.price.original){ return 'Update Price History'; - }else{ + } else { return 'Add Price History'; } }, - showHistory: function(){ + showHistory: function() { this.$refs.historyModal.title = this.getTitle(); this.$refs.historyModal.isOpen = true; }, diff --git a/mooring/frontend/mooring/src/components/utils/priceHistory/priceHistoryDetail.vue b/mooring/frontend/mooring/src/components/utils/priceHistory/priceHistoryDetail.vue index d4767bd7f2..74e544bdb1 100644 --- a/mooring/frontend/mooring/src/components/utils/priceHistory/priceHistoryDetail.vue +++ b/mooring/frontend/mooring/src/components/utils/priceHistory/priceHistoryDetail.vue @@ -160,12 +160,13 @@ module.exports = { } }); } - else{ + else { delete vm.priceHistory.rate; - vm.priceHistory.adult = ''; - vm.priceHistory.concession = ''; - vm.priceHistory.child = ''; - vm.priceHistory.infant = ''; + vm.priceHistory.mooring = '0.00'; + vm.priceHistory.adult = '0.00'; + vm.priceHistory.concession = '0.00'; + vm.priceHistory.child = '0.00'; + vm.priceHistory.infant = '0.00'; } } }, diff --git a/mooring/frontend/mooring/src/components/utils/stayHistory/addMaximumStayPeriod.vue b/mooring/frontend/mooring/src/components/utils/stayHistory/addMaximumStayPeriod.vue index fb796303cf..80d3b4df72 100644 --- a/mooring/frontend/mooring/src/components/utils/stayHistory/addMaximumStayPeriod.vue +++ b/mooring/frontend/mooring/src/components/utils/stayHistory/addMaximumStayPeriod.vue @@ -70,7 +70,7 @@ import alert from '../../utils/alert.vue' module.exports = { name: 'addMaxStayCS', props: { - campground: { + mooringarea: { type: Object, required: true }, diff --git a/mooring/frontend/mooring/src/components/utils/stayHistory/stayHistory.vue b/mooring/frontend/mooring/src/components/utils/stayHistory/stayHistory.vue index 1218031c37..06b32c2b37 100644 --- a/mooring/frontend/mooring/src/components/utils/stayHistory/stayHistory.vue +++ b/mooring/frontend/mooring/src/components/utils/stayHistory/stayHistory.vue @@ -1,6 +1,6 @@