From af6167f9d47182cc332ba4f4bdc65cc7ed890726 Mon Sep 17 00:00:00 2001 From: Mitch Riedstra Date: Mon, 9 Oct 2017 22:32:36 -0400 Subject: Start the ugly process of cleaning up the views. Added a datepicker to the load date form. Added the 'load_number' field to the LoadCreate view --- app/dispatch/migrations/0002_auto_20171010_0140.py | 20 +++++++++++++++++++ app/dispatch/models.py | 2 +- app/dispatch/static/base.js | 20 +++++++++++++++++++ app/dispatch/templates/dispatch/base.html | 23 ++++++++-------------- .../templates/dispatch/drivers/detail.html | 10 +++++----- app/dispatch/views.py | 12 ++++++----- 6 files changed, 61 insertions(+), 26 deletions(-) create mode 100644 app/dispatch/migrations/0002_auto_20171010_0140.py create mode 100644 app/dispatch/static/base.js (limited to 'app/dispatch') diff --git a/app/dispatch/migrations/0002_auto_20171010_0140.py b/app/dispatch/migrations/0002_auto_20171010_0140.py new file mode 100644 index 0000000..499153b --- /dev/null +++ b/app/dispatch/migrations/0002_auto_20171010_0140.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.5 on 2017-10-10 01:40 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('dispatch', '0001_initial'), + ] + + operations = [ + migrations.AlterField( + model_name='load', + name='amount', + field=models.DecimalField(decimal_places=2, default='0', max_digits=10), + ), + ] diff --git a/app/dispatch/models.py b/app/dispatch/models.py index 440804e..dfb5273 100644 --- a/app/dispatch/models.py +++ b/app/dispatch/models.py @@ -20,7 +20,7 @@ class Load(models.Model): user = models.ForeignKey(settings.AUTH_USER_MODEL) company = models.ForeignKey(Company) description = models.CharField(max_length=256) - amount = models.DecimalField(max_digits=10,decimal_places=2) + amount = models.DecimalField(max_digits=10,decimal_places=2, default="0") def __str__(self): return "{c}, {d} ( {a} )".format(c=self.company, d=self.description, a=self.amount) diff --git a/app/dispatch/static/base.js b/app/dispatch/static/base.js new file mode 100644 index 0000000..5f57441 --- /dev/null +++ b/app/dispatch/static/base.js @@ -0,0 +1,20 @@ +$( document ).ready(function(){ + all_date_fields = document.querySelectorAll("[name='date']"); + + for ( i = 0 ; i < all_date_fields.length ; i++ ) { + console.log(all_date_fields[0]) + $(all_date_fields[0]).pickadate({ + selectMonths: true, // Creates a dropdown to control month + selectYears: 15, // Creates a dropdown of 15 years to control year, + // format: 'dd/mm/yyyy', + format: 'yyyy-mm-dd', + today: 'Today', + clear: 'Clear', + close: 'Ok', + closeOnSelect: false // Close upon selecting a date, + }); + + } + + +}); diff --git a/app/dispatch/templates/dispatch/base.html b/app/dispatch/templates/dispatch/base.html index 693208f..00116e3 100644 --- a/app/dispatch/templates/dispatch/base.html +++ b/app/dispatch/templates/dispatch/base.html @@ -31,14 +31,13 @@ -