Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Edit Pricing Screen Fixes and Updates #363

Merged
merged 3 commits into from
Aug 7, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions mooring/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ class MarinaAdmin(admin.GeoModelAdmin):

@admin.register(models.MooringArea)
class MooringAreaAdmin(admin.GeoModelAdmin):
list_display = ('name','park','promo_area','mooring_type','site_type','max_advance_booking')
list_display = ('name','park','promo_area','mooring_type','max_advance_booking')
ordering = ('name',)
search_fields = ('name',)
list_filter = ('mooring_type','site_type')
openlayers_url = 'https://cdnjs.cloudflare.com/ajax/libs/openlayers/2.13.1/OpenLayers.js'

@admin.register(models.MooringAreaGroup)
class MooringAreaGroupAdmin(admin.ModelAdmin):
filter_horizontal = ('members','campgrounds')
filter_horizontal = ('members','moorings')

@admin.register(models.Mooringsite)
class MooringsiteAdmin(admin.GeoModelAdmin):
Expand Down
20 changes: 10 additions & 10 deletions mooring/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -518,14 +518,14 @@ def retrieve(self, request, *args, **kwargs):
instance = self.get_object()
#print request.GET.get("formatted", False)
formatted = bool(request.GET.get("formatted", False))
instance.mooring_group = MooringAreaGroup.objects.filter(members__in=[request.user.id,],campgrounds__in=[instance.id,])
instance.mooring_group = MooringAreaGroup.objects.filter(members__in=[request.user.id,],moorings__in=[instance.id,])
if Mooringsite.objects.filter(mooringarea__id=instance.id).exists():
pass
else:
mooringsite_class = MooringsiteClass.objects.all().first()
Mooringsite.objects.create(mooringarea=instance,
name=instance.name,
mooring_site_class=mooringsite_class,
mooringsite_class=mooringsite_class,
description=None)

serializer = self.get_serializer(instance, formatted=formatted, method='get')
Expand Down Expand Up @@ -577,16 +577,16 @@ def create(self, request, format=None):
for i in mg:
# i.campgrounds.clear()
if i.id in mooring_group:
m_all = i.campgrounds.all()
m_all = i.moorings.all()
if instance.id in m_all:
pass
else:
i.campgrounds.add(instance)
i.moorings.add(instance)
else:
m_all = i.campgrounds.all()
m_all = i.moorings.all()
for b in m_all:
if instance.id == b.id:
i.campgrounds.remove(b)
i.moorings.remove(b)

if Mooringsite.objects.filter(mooringarea__id=instance.id).exists():
pass
Expand Down Expand Up @@ -622,16 +622,16 @@ def update(self, request, *args, **kwargs):
for i in mg:
# i.campgrounds.clear()
if i.id in mooring_group:
m_all = i.campgrounds.all()
m_all = i.moorings.all()
if instance.id in m_all:
pass
else:
i.campgrounds.add(instance)
i.moorings.add(instance)
else:
m_all = i.campgrounds.all()
m_all = i.moorings.all()
for b in m_all:
if instance.id == b.id:
i.campgrounds.remove(b)
i.moorings.remove(b)

if "images" in request.data:
images_data = request.data.pop("images")
Expand Down
24 changes: 17 additions & 7 deletions mooring/context_processors.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,24 @@
from django.conf import settings

def mooring_url(request):
# print "TEST"
# print request.META['HTTP_HOST']
web_url = request.META['HTTP_HOST']
if web_url in settings.ROTTNEST_ISLAND_URL:
#@['mooring-rottnest.austwa.com']:
template_group = 'rottnest'
else:
template_group = 'pvs'

return {
'EXPLORE_PARKS_SEARCH': '{}/map'.format(settings.EXPLORE_PARKS_URL),
'EXPLORE_PARKS_CONTACT': '{}/contact-us'.format(settings.EXPLORE_PARKS_URL),
'EXPLORE_PARKS_CONSERVE': '{}/know/conserving-our-moorings'.format(settings.EXPLORE_PARKS_URL),
'EXPLORE_PARKS_PEAK_PERIODS': '{}/know/when-visit'.format(settings.EXPLORE_PARKS_URL),
'EXPLORE_PARKS_ENTRY_FEES': '{}/know/entry-fees'.format(settings.EXPLORE_PARKS_URL),
'EXPLORE_PARKS_TERMS': '{}/know/online-mooring-site-booking-terms-and-conditions'.format(settings.EXPLORE_PARKS_URL),
'EXPLORE_PARKS_SEARCH': '/map',
'EXPLORE_PARKS_CONTACT': '/contact-us',
'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',
'PARKSTAY_EXTERNAL_URL': settings.PARKSTAY_EXTERNAL_URL,
'DEV_STATIC': settings.DEV_STATIC,
'DEV_STATIC_URL': settings.DEV_STATIC_URL
'DEV_STATIC_URL': settings.DEV_STATIC_URL,
'TEMPLATE_GROUP' : template_group
}
6 changes: 2 additions & 4 deletions mooring/frontend/mooring/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

<title>

Mooring - Department of Parks and Wildlife
Mooring - Department of Biodiversity, Conservation and Attractions

</title>

Expand All @@ -30,9 +30,7 @@
<body>
<header class="topmast">





<div class="">
<div class="container">
<div class="masthead">
Expand Down
17 changes: 12 additions & 5 deletions mooring/frontend/mooring/src/components/booking/changebooking2.vue
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,17 @@
</div>
<div class="form-group">
<div class="col-md-4">
<label class="control-label pull-left required" for="Dates">Campground: </label>
<label class="control-label pull-left required" for="Dates">Mooring: </label>
</div>
<div class="col-md-8">
<select @change="updateCampground" class="form-control" name="campground" v-model="booking.campground">
<select @change="updateCampground" class="form-control" name="campground" v-model="booking.mooringarea" readonly="true">
<option v-for="c in onlineCampgrounds" :value="c.id">{{c.name}}</option>
</select>
</div>
</div>
<div class="form-group" v-if="booking.campground != null || booking.campground != ''">
<div class="col-md-4">
<label class="control-label pull-left required" for="Dates">Camp Site: </label>
<label class="control-label pull-left required" for="Dates">Mooring Site: </label>
</div>
<div class="col-md-8" v-if="campsites.length > 0">
<select class="form-control" name="campground" v-model="selected_campsite">
Expand Down Expand Up @@ -92,7 +92,7 @@
<div class="form-group">
<label for="vehicles" class="required col-md-4">Number of Vehicles</label>
<div class="dropdown guests col-md-8">
<input type="number" min="0" max="10" name="vehicles" class="form-control dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true" readonly="true" v-model="booking.parkEntry.vehicles">
<input type="number" min="1" max="1" name="vehicles" class="form-control dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true" readonly="true" v-model="booking.parkEntry.vehicles">
<ul class="dropdown-menu" aria-labelledby="dropdownMenu1">
<li v-for="park_entry in parkEntryPicker">
<div class="row">
Expand Down Expand Up @@ -316,7 +316,11 @@ export default {
return entries;
},
onlineCampgrounds() {
return this.campgrounds.filter(c => c.campground_type === 0);
console.log("onlineCampgrounds");
console.log(this.campgrounds);
console.log(this.mooringarea);
return this.campgrounds;
// return this.campgrounds.filter(c => c.campground_type === 0);
},
...mapGetters({
campgrounds: 'campgrounds'
Expand Down Expand Up @@ -850,6 +854,9 @@ export default {
vm.selected_departure = vm.booking.departure;
// set the campground
console.log('MOO LOG');
console.log(vm);
console.log(this.campgrounds);
// console.log(this.campgrounds.filter(c => c.campground_type === 0));
// console.log(vm.booking.mooringarea);
// console.log(vm.campgrounds);
// console.log(vm.campgrounds.find(c => parseInt(c.id) === parseInt(vm.booking.mooringarea)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<div class="row">
<div class="col-md-4">
<div class="form-group">
<label for="">Mooring Area</label>
<label for="">Mooring</label>
<select v-show="isLoading" class="form-control" >
<option value="">Loading...</option>
</select>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@

</div>
<div class="row">
<div class="col-md-4">
<div class="col-md-6">
<div class="form-group ">
<label class="control-label" >Mooring Type</label>
<select id="campground_type" name="campground_type" class="form-control" v-model="campground.mooring_type">
Expand All @@ -60,17 +60,17 @@
</select>
</div>
</div>
<div class="col-md-4">
<div class="form-group ">
<div class="col-md-0">
<div class="form-group " style='display:none'>
<label class="control-label" >Booking Configuration</label>
<select id="site_type" name="site_type" class="form-control" v-model="campground.site_type">
<option value="0">Bookable per site</option>
<option value="1">Bookable per site type</option>
<option value="0" selected >Bookable per site</option>
<option value="1" >Bookable per site type</option>
<option value="2">Bookable per site type (hide site number)</option>
</select>
</div>
</div>
<div class="col-md-4">
<div class="col-md-6">
<div class="form-group ">
<label class="control-label" >Mooring Group (Permissions)</label>
<select class="form-control" v-model="campground.mooring_group" id='mooring_groups' name='mooring_groups' multiple>
Expand Down Expand Up @@ -187,13 +187,13 @@
</div>
<div class="row" style="margin-top: 40px;">
<div class="col-sm-8">
<div class="form-group">
<div class="form-group" style='display:none;'>
<div class="col-sm-4 col-md-3 col-lg-2">
<label style="line-height: 2.5;">Price set at: </label>
</div>
<div class="col-sm-8 col-md-9 col-lg-10">
<select id="price_level" name="price_level" class="form-control" v-model="campground.price_level">
<option v-for="level in priceSet" :value="level.val">{{ level.name }}</option>
<option value="0" selected>Mooring level</option>
</select>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@
<div class="col-md-4">
<div class="form-group pull-right">
<a style="margin-top: 20px;" class="btn btn-primary" @click="addCampground()">Add Mooring</a>
<a style="margin-top: 20px;" class="btn btn-primary" @click="showBulkClose = true">Close Mooring</a>
<a style="margin-top: 20px;" class="btn btn-primary" @click="showBulkClose = true">Close Moorings</a>
</div>
</div>
</form>
<datatable :dtHeaders="['Mooring Area','Status','Region','District','Park','Action']" :dtOptions="dtoptions" ref="dtGrounds" id="campground-table" ></datatable>
<datatable :dtHeaders="['Mooring','Status','Region','District','Park','Action']" :dtOptions="dtoptions" ref="dtGrounds" id="campground-table" ></datatable>
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<template lang="html">
<div id="bulk-close">
<modal okText="Close Campgrounds" @ok="closeCampgrounds()" :force="true">
<h4 slot="title">Bulk Close Campgrounds</h4>
<modal okText="Close Moorings" @ok="closeCampgrounds()" :force="true">
<h4 slot="title">Bulk Close Moorings</h4>
<div class="body">
<alert :show="false" type="danger">{{errorString}}</alert>
<form name="closeForm" class="form-horizontal">
<div class="row">
<div class="form-group">
<div class="col-md-4">
<label for="Campgrounds">Campgrounds</label>
<label for="Moorings">Moorings</label>
</div>
<div class="col-md-8">
<select class="form-control" id="bc-campgrounds" name="campgrounds" placeholder="" multiple v-model="selected_campgrounds">
Expand Down Expand Up @@ -147,7 +147,7 @@ export default {
$('#bc-campgrounds').select2({
theme: 'bootstrap',
allowClear: true,
placeholder: "Select Campgrounds",
placeholder: "Select Moorings",
tags:false,
}).
on("select2:select",function (e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<button v-show="showAddBtn" @click="showHistory()" class="btn btn-primary pull-right table_btn">Add Price History</button>
</div>
<datatable ref="history_dt" :dtHeaders ="dt_headers" :dtOptions="dt_options" id="ph_table"></datatable>
</div>
</div>
<confirmbox id="deleteHistory" :options="deleteHistoryPrompt"></confirmbox>
</div>
</template>
Expand Down Expand Up @@ -174,7 +174,7 @@ export default {
vm.$refs.history_dt.vmDataTable.ajax.reload();
});
}
else{
else {
url = api_endpoints.campsiterate_detail(data);
$.ajax({
beforeSend: function(xhrObj) {
Expand Down Expand Up @@ -217,7 +217,9 @@ export default {
this.sendData(this.getAddURL(),'POST',JSON.stringify(this.price));
},
updateHistory: function() {
if (this.level == 'campsite'){
console.log('UPDATE HIST');
var vm=this;
if (this.level == 'campsite') {
this.price.campsite = this.object_id;
this.sendData(this.getEditURL(),'PUT',JSON.stringify(vm.price));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,17 @@
</div>
</div>
<div class="row">
<div class="form-group">
<div class="col-md-2">
<label>Mooring: </label>
</div>
<div class="col-md-4">
<input :readonly="selected_rate != ''" name="mooring" v-model="priceHistory.mooring" type='text' class="form-control" />
</div>
</div>
</div>

<div class="row" style='display: none'>
<div class="form-group">
<div class="col-md-2">
<label>Adult Price: </label>
Expand All @@ -27,7 +38,7 @@
</div>
</div>
</div>
<div class="row">
<div class="row" style='display: none'>
<div class="form-group">
<div class="col-md-2">
<label>Concession Price: </label>
Expand All @@ -37,7 +48,7 @@
</div>
</div>
</div>
<div class="row">
<div class="row" style='display: none'>
<div class="form-group">
<div class="col-md-2">
<label>Child Price: </label>
Expand All @@ -47,7 +58,7 @@
</div>
</div>
</div>
<div class="row">
<div class="row" style='display: none'>
<div class="form-group">
<div class="col-md-2">
<label>Infant Price: </label>
Expand Down Expand Up @@ -141,6 +152,7 @@ module.exports = {
$.each(vm.rates, function(i, rate) {
if (rate.id== vm.selected_rate){
vm.priceHistory.rate = rate.id;
vm.priceHistory.mooring = rate.mooring;
vm.priceHistory.adult = rate.adult;
vm.priceHistory.concession = rate.concession;
vm.priceHistory.child = rate.child;
Expand Down
Loading