From 427c5f1fd2061e229ad06dde4bd5921d296b12d9 Mon Sep 17 00:00:00 2001 From: Mitch Riedstra Date: Thu, 19 Oct 2017 21:11:29 -0400 Subject: Rename Company to Customer system wide. Let's not do this again --- app/dispatch/admin.py | 4 +-- .../management/commands/insert_fake_data.py | 23 +++++++------- app/dispatch/migrations/0001_initial.py | 12 ++++---- app/dispatch/migrations/0002_auto_20171018_1602.py | 30 ------------------ .../migrations/0003_remove_load_load_number.py | 19 ------------ app/dispatch/models.py | 8 ++--- .../templates/dispatch/companies/detail.html | 8 ++--- .../templates/dispatch/companies/list.html | 22 ++++++------- .../templates/dispatch/drivers/detail.html | 2 +- .../templates/dispatch/generic_load_listing.html | 8 ++--- app/dispatch/templates/dispatch/loads/detail.html | 4 +-- app/dispatch/templates/dispatch/nav.html | 2 +- app/dispatch/urls.py | 10 +++--- app/dispatch/views.py | 36 +++++++++++----------- 14 files changed, 69 insertions(+), 119 deletions(-) delete mode 100644 app/dispatch/migrations/0002_auto_20171018_1602.py delete mode 100644 app/dispatch/migrations/0003_remove_load_load_number.py (limited to 'app') diff --git a/app/dispatch/admin.py b/app/dispatch/admin.py index b512e70..617eac4 100644 --- a/app/dispatch/admin.py +++ b/app/dispatch/admin.py @@ -1,7 +1,7 @@ from django.contrib import admin # Register your models here. -from .models import Load, Company +from .models import Load, Customer admin.site.register(Load) -admin.site.register(Company) +admin.site.register(Customer) diff --git a/app/dispatch/management/commands/insert_fake_data.py b/app/dispatch/management/commands/insert_fake_data.py index 0919181..5d4203d 100644 --- a/app/dispatch/management/commands/insert_fake_data.py +++ b/app/dispatch/management/commands/insert_fake_data.py @@ -1,6 +1,6 @@ from django.core.management.base import BaseCommand, CommandError from django.contrib.auth import get_user_model -from dispatch.models import Company, Load +from dispatch.models import Customer, Load from faker import Faker import random @@ -35,15 +35,15 @@ class Command(BaseCommand): self.end_date = options['enddate'] self.start_date = options['startdate'] - company_ids = [] + customer_ids = [] user_ids = [] for i in range(0, options['companies']): - co = self.fake_company() + co = self.fake_customer() # We're going to hold the model IDs in memory to access randomly # later on - company_ids.append(co.pk) + customer_ids.append(co.pk) for i in range(0, options['users']): u = self.fake_user() @@ -51,37 +51,36 @@ class Command(BaseCommand): user_ids.append(u.pk) for i in range(0, options['loads']): - co_id = company_ids[random.randint(0, len(company_ids)-1)] - co = Company.objects.get(pk=co_id) + co_id = customer_ids[random.randint(0, len(customer_ids)-1)] + co = Customer.objects.get(pk=co_id) u_id = user_ids[random.randint(0, len(user_ids)-1)] u = User.objects.get(pk=u_id) l = self.fake_load(u, co) - def fake_company(self): - new_company = Company( + def fake_customer(self): + new_customer = Customer( name=self.fake.company(), address=self.fake.address(), phone_number=self.fake.msisdn(), email_address=self.fake.company_email(), contact_name=self.fake.name(), ) - new_company.save() - return new_company + new_customer.save() + return new_customer def fake_load(self, usr, co): fake_description = "{}-{} {} {}K".format( self.fake.month(), self.fake.day_of_month(), self.fake.license_plate(), random.randint(5, 50)) - print(fake_description) new_load = Load( user=usr, # Because that's going to be random enough # load_number=self.fake.license_plate(), # description=self.fake.sentence(nb_words=6), description=fake_description, - company=co, + customer=co, amount=random.randint(150,2500), delivered_to=self.fake.city(), ) diff --git a/app/dispatch/migrations/0001_initial.py b/app/dispatch/migrations/0001_initial.py index 7a920f7..500e6ea 100644 --- a/app/dispatch/migrations/0001_initial.py +++ b/app/dispatch/migrations/0001_initial.py @@ -1,7 +1,8 @@ # -*- coding: utf-8 -*- -# Generated by Django 1.11.5 on 2017-10-18 15:46 +# Generated by Django 1.11.5 on 2017-10-20 00:51 from __future__ import unicode_literals +import dispatch.models from django.conf import settings from django.db import migrations, models import django.db.models.deletion @@ -17,7 +18,7 @@ class Migration(migrations.Migration): operations = [ migrations.CreateModel( - name='Company', + name='Customer', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('name', models.CharField(max_length=256)), @@ -31,11 +32,11 @@ class Migration(migrations.Migration): name='Load', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('load_number', models.CharField(default='', max_length=64)), ('date', models.DateField()), ('description', models.CharField(max_length=256)), + ('delivered_to', models.CharField(default='', max_length=256)), ('amount', models.DecimalField(decimal_places=2, default='0', max_digits=10)), - ('company', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='dispatch.Company')), + ('customer', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='dispatch.Customer')), ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), ], ), @@ -44,8 +45,7 @@ class Migration(migrations.Migration): fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('description', models.CharField(max_length=256)), - ('filename', models.CharField(max_length=256)), - ('document', models.FileField(upload_to='paperwork/')), + ('document', models.FileField(upload_to=dispatch.models.paperwork_user_directory_path)), ('load', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='dispatch.Load')), ], ), diff --git a/app/dispatch/migrations/0002_auto_20171018_1602.py b/app/dispatch/migrations/0002_auto_20171018_1602.py deleted file mode 100644 index 6446dd4..0000000 --- a/app/dispatch/migrations/0002_auto_20171018_1602.py +++ /dev/null @@ -1,30 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by Django 1.11.5 on 2017-10-18 16:02 -from __future__ import unicode_literals - -import dispatch.models -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('dispatch', '0001_initial'), - ] - - operations = [ - migrations.RemoveField( - model_name='paperwork', - name='filename', - ), - migrations.AddField( - model_name='load', - name='delivered_to', - field=models.CharField(default='', max_length=256), - ), - migrations.AlterField( - model_name='paperwork', - name='document', - field=models.FileField(upload_to=dispatch.models.paperwork_user_directory_path), - ), - ] diff --git a/app/dispatch/migrations/0003_remove_load_load_number.py b/app/dispatch/migrations/0003_remove_load_load_number.py deleted file mode 100644 index cd352ee..0000000 --- a/app/dispatch/migrations/0003_remove_load_load_number.py +++ /dev/null @@ -1,19 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by Django 1.11.5 on 2017-10-20 00:39 -from __future__ import unicode_literals - -from django.db import migrations - - -class Migration(migrations.Migration): - - dependencies = [ - ('dispatch', '0002_auto_20171018_1602'), - ] - - operations = [ - migrations.RemoveField( - model_name='load', - name='load_number', - ), - ] diff --git a/app/dispatch/models.py b/app/dispatch/models.py index 3174f14..6cbaf6c 100644 --- a/app/dispatch/models.py +++ b/app/dispatch/models.py @@ -7,7 +7,7 @@ import uuid # Create your models here. -class Company(models.Model): +class Customer(models.Model): history = AuditlogHistoryField() name = models.CharField(max_length=256) address = models.CharField(max_length=256) @@ -23,14 +23,14 @@ class Load(models.Model): history = AuditlogHistoryField() date = models.DateField() user = models.ForeignKey(settings.AUTH_USER_MODEL) - company = models.ForeignKey(Company) + customer = models.ForeignKey(Customer) description = models.CharField(max_length=256) delivered_to = models.CharField(max_length=256, default="") 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) + c=self.customer, d=self.description, a=self.amount) def get_absolute_url(self): return "/loads/view/%i" % self.id @@ -53,5 +53,5 @@ class Paperwork(models.Model): return "%s" % self.load -auditlog.register(Company) +auditlog.register(Customer) auditlog.register(Load) diff --git a/app/dispatch/templates/dispatch/companies/detail.html b/app/dispatch/templates/dispatch/companies/detail.html index 5c643da..3ededbe 100644 --- a/app/dispatch/templates/dispatch/companies/detail.html +++ b/app/dispatch/templates/dispatch/companies/detail.html @@ -12,10 +12,10 @@
@@ -25,10 +25,10 @@
diff --git a/app/dispatch/templates/dispatch/companies/list.html b/app/dispatch/templates/dispatch/companies/list.html index e0a128f..e08837b 100644 --- a/app/dispatch/templates/dispatch/companies/list.html +++ b/app/dispatch/templates/dispatch/companies/list.html @@ -1,14 +1,14 @@ {% extends 'dispatch/base.html' %} -{% block title %}Companies{% endblock %} +{% block title %}Customers{% endblock %} {% block content %}
-

Companies

+

Customers

@@ -21,21 +21,21 @@ - {% for company in object_list %} + {% for customer in object_list %} - - - - + + + + {% empty %} - + {% endfor %}
{{ company.name }}{{ company.address }}{{ company.phone_number }}{{ company.email_address }}{{ customer.name }}{{ customer.address }}{{ customer.phone_number }}{{ customer.email_address }} {% if user.is_superuser %} - Edit + Edit {% endif %} - View + View
No companies yet.
No customers yet.
diff --git a/app/dispatch/templates/dispatch/drivers/detail.html b/app/dispatch/templates/dispatch/drivers/detail.html index 7655470..c4c19e8 100644 --- a/app/dispatch/templates/dispatch/drivers/detail.html +++ b/app/dispatch/templates/dispatch/drivers/detail.html @@ -54,7 +54,7 @@ {% endif %} {% load custom_tags %} -{% listForCommaString "Company,Amount,Load Number,Description" as load_headers %} +{% listForCommaString "Customer,Amount,Description" as load_headers %} {% include "dispatch/generic_load_listing.html" %}
diff --git a/app/dispatch/templates/dispatch/generic_load_listing.html b/app/dispatch/templates/dispatch/generic_load_listing.html index e92176e..235a371 100644 --- a/app/dispatch/templates/dispatch/generic_load_listing.html +++ b/app/dispatch/templates/dispatch/generic_load_listing.html @@ -15,10 +15,10 @@ the fields beforehand i.e. \{\% load custom_tags %} - \{\% listForCommaString "Company,Amount,Load Number,Description" as load_headers %} + \{\% listForCommaString "Customer,Amount,Load Number,Description" as load_headers %} -->