aboutsummaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/dispatch/admin.py4
-rw-r--r--app/dispatch/management/commands/insert_fake_data.py23
-rw-r--r--app/dispatch/migrations/0001_initial.py12
-rw-r--r--app/dispatch/migrations/0002_auto_20171018_1602.py30
-rw-r--r--app/dispatch/migrations/0003_remove_load_load_number.py19
-rw-r--r--app/dispatch/models.py8
-rw-r--r--app/dispatch/templates/dispatch/companies/detail.html8
-rw-r--r--app/dispatch/templates/dispatch/companies/list.html22
-rw-r--r--app/dispatch/templates/dispatch/drivers/detail.html2
-rw-r--r--app/dispatch/templates/dispatch/generic_load_listing.html8
-rw-r--r--app/dispatch/templates/dispatch/loads/detail.html4
-rw-r--r--app/dispatch/templates/dispatch/nav.html2
-rw-r--r--app/dispatch/urls.py10
-rw-r--r--app/dispatch/views.py36
14 files changed, 69 insertions, 119 deletions
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 @@
<div class="row">
<div class="col s6 left-align">
- <a href="{% url 'company_detail' object.id %}?date={{previous_week}}" class="btn blue"><i class="material-icons left">arrow_back</i> Prev</a>
+ <a href="{% url 'customer_detail' object.id %}?date={{previous_week}}" class="btn blue"><i class="material-icons left">arrow_back</i> Prev</a>
</div>
<div class="col s6 right-align">
- <a href="{% url 'company_detail' object.id %}?date={{next_week}}" class="btn blue"><i class="material-icons right">arrow_forward</i> Next</a>
+ <a href="{% url 'customer_detail' object.id %}?date={{next_week}}" class="btn blue"><i class="material-icons right">arrow_forward</i> Next</a>
</div>
</div>
@@ -25,10 +25,10 @@
<div class="row">
<div class="col s6 left-align">
- <a href="{% url 'company_detail' object.id %}?date={{previous_week}}" class="btn blue"><i class="material-icons left">arrow_back</i> Prev</a>
+ <a href="{% url 'customer_detail' object.id %}?date={{previous_week}}" class="btn blue"><i class="material-icons left">arrow_back</i> Prev</a>
</div>
<div class="col s6 right-align">
- <a href="{% url 'company_detail' object.id %}?date={{next_week}}" class="btn blue"><i class="material-icons right">arrow_forward</i> Next</a>
+ <a href="{% url 'customer_detail' object.id %}?date={{next_week}}" class="btn blue"><i class="material-icons right">arrow_forward</i> Next</a>
</div>
</div>
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 %}
<div class="row">
<div class="col s12 m6">
- <h1>Companies</h1>
+ <h1>Customers</h1>
</div>
<div class="col s12 m6 right-align">
- <a href="{% url 'company_new' %}" class="btn green">Add Company</a>
+ <a href="{% url 'customer_new' %}" class="btn green">Add Customer</a>
</div>
</div>
<table class="striped bordered">
@@ -21,21 +21,21 @@
</tr>
</thead>
<tbody>
- {% for company in object_list %}
+ {% for customer in object_list %}
<tr>
- <td>{{ company.name }}</td>
- <td>{{ company.address }}</td>
- <td>{{ company.phone_number }}</td>
- <td>{{ company.email_address }}</td>
+ <td>{{ customer.name }}</td>
+ <td>{{ customer.address }}</td>
+ <td>{{ customer.phone_number }}</td>
+ <td>{{ customer.email_address }}</td>
<td class="right-align">
{% if user.is_superuser %}
- <a href="{% url 'company_edit' company.id %}" class="btn orange">Edit</a>
+ <a href="{% url 'customer_edit' customer.id %}" class="btn orange">Edit</a>
{% endif %}
- <a href="{% url 'company_detail' company.id %}" class="btn blue">View</a>
+ <a href="{% url 'customer_detail' customer.id %}" class="btn blue">View</a>
</td>
</tr>
{% empty %}
- <tr><td colspan="4">No companies yet.</td></tr>
+ <tr><td colspan="4">No customers yet.</td></tr>
{% endfor %}
</tbody>
</table>
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" %}
<div class="row">
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 %}
-->
<!--
- <th>Company</th>
+ <th>Customer</th>
<th>Driver</th>
<th>Amount</th>
<th>Load Number</th>
@@ -29,8 +29,8 @@
<tbody>
{% for load in loads|keyvalue:date %}
<tr class="green lighten-4">
- {% if "Company" in load_headers %}
- <td><a href="{% url 'company_detail' load.company.id %}">{{ load.company.name }}</a></td>
+ {% if "Customer" in load_headers %}
+ <td><a href="{% url 'customer_detail' load.customer.id %}">{{ load.customer.name }}</a></td>
{% endif %}
{% if "Driver" in load_headers %}
<td><a href="{% url 'driver_detail' load.user.id %}">{{ load.user.first_name }} {{ load.user.last_name }}</a></td>
diff --git a/app/dispatch/templates/dispatch/loads/detail.html b/app/dispatch/templates/dispatch/loads/detail.html
index 02dc5a0..fff9cf2 100644
--- a/app/dispatch/templates/dispatch/loads/detail.html
+++ b/app/dispatch/templates/dispatch/loads/detail.html
@@ -27,8 +27,8 @@
</tr>
<tr>
- <th>Company</th>
- <td>{{object.company}}</td>
+ <th>Customer</th>
+ <td>{{object.customer}}</td>
</tr>
<tr>
diff --git a/app/dispatch/templates/dispatch/nav.html b/app/dispatch/templates/dispatch/nav.html
index d40224c..c53a07e 100644
--- a/app/dispatch/templates/dispatch/nav.html
+++ b/app/dispatch/templates/dispatch/nav.html
@@ -2,7 +2,7 @@
<li><a href="{% url 'load_list' %}">Loads</a></li>
{% if request.user.is_superuser %}
<li><a href="{% url 'driver_list' %}">Drivers</a></li>
- <li><a href="{% url 'company_list' %}">Companies</a></li>
+ <li><a href="{% url 'customer_list' %}">Customers</a></li>
{% else %}
<li><a href="{% url 'driver_edit' request.user.id %}">My Account</a></li>
{% endif %}
diff --git a/app/dispatch/urls.py b/app/dispatch/urls.py
index 0d784f9..816faae 100644
--- a/app/dispatch/urls.py
+++ b/app/dispatch/urls.py
@@ -14,11 +14,11 @@ urlpatterns = [
url(r'^drivers/view/(?P<pk>\d+)$', views.DriverDetail.as_view(), name='driver_detail'),
url(r'^drivers/edit/(?P<pk>\d+)$', views.DriverUpdate.as_view(), name='driver_edit'),
- url(r'^companies/$', views.CompanyList.as_view(), name='company_list'),
- url(r'^companies/new$', views.CompanyCreate.as_view(), name='company_new'),
- url(r'^companies/view/(?P<pk>\d+)$', views.CompanyDetail.as_view(), name='company_detail'),
- url(r'^companies/edit/(?P<pk>\d+)$', views.CompanyUpdate.as_view(), name='company_edit'),
- url(r'^companies/delete/(?P<pk>\d+)$', views.CompanyDelete.as_view(), name='company_delete'),
+ url(r'^customers/$', views.CustomerList.as_view(), name='customer_list'),
+ url(r'^customers/new$', views.CustomerCreate.as_view(), name='customer_new'),
+ url(r'^customers/view/(?P<pk>\d+)$', views.CustomerDetail.as_view(), name='customer_detail'),
+ url(r'^customers/edit/(?P<pk>\d+)$', views.CustomerUpdate.as_view(), name='customer_edit'),
+ url(r'^customers/delete/(?P<pk>\d+)$', views.CustomerDelete.as_view(), name='customer_delete'),
url(r'^loads/$', views.LoadList.as_view(), name='load_list'),
url(r'^loads/new$', views.LoadCreate.as_view(), name='load_new'),
diff --git a/app/dispatch/views.py b/app/dispatch/views.py
index 0b9c1bf..05a8c2c 100644
--- a/app/dispatch/views.py
+++ b/app/dispatch/views.py
@@ -9,7 +9,7 @@ from django.views.generic import TemplateView,ListView
from django.views.generic.detail import DetailView
from django.views.generic.edit import CreateView, UpdateView, DeleteView
from django.core.urlresolvers import reverse_lazy
-from dispatch.models import Company, Load, Paperwork
+from dispatch.models import Customer, Load, Paperwork
from dispatch.forms import AddPaperworkForm
from django.contrib.auth.models import User
from django.contrib.auth.mixins import UserPassesTestMixin
@@ -52,7 +52,7 @@ class LoadDateSort(DetailView):
week_dates = get_week_dates(self.request.GET.get('date',None))
loads = self.get_object().load_set.filter(date__range=(week_dates['start_date'],
- week_dates['end_date'])).prefetch_related('company')
+ week_dates['end_date'])).prefetch_related('customer')
context['loads'] = split_loads_by_day(loads,week_dates['start_date'],
week_dates['end_date'])
@@ -138,39 +138,39 @@ class DriverUpdate(UserPassesTestMixin, UpdateView):
return self.request.user.is_superuser or \
self.get_object().pk is self.request.user.id
-# Company CRUD
+# Customer CRUD
-class CompanyList(ListView):
+class CustomerList(ListView):
template_name = "dispatch/companies/list.html"
- model = Company
+ model = Customer
-class CompanyCreate(UserPassesTestMixin, CreateView):
+class CustomerCreate(UserPassesTestMixin, CreateView):
template_name = "dispatch/companies/create.html"
- model = Company
- success_url = reverse_lazy('company_list')
+ model = Customer
+ success_url = reverse_lazy('customer_list')
fields = ['name', 'address', 'phone_number','email_address']
def test_func(self):
return self.request.user.is_superuser
-class CompanyDetail(LoadDateSort):
+class CustomerDetail(LoadDateSort):
template_name = "dispatch/companies/detail.html"
- model = Company
+ model = Customer
-class CompanyUpdate(UserPassesTestMixin, UpdateView):
+class CustomerUpdate(UserPassesTestMixin, UpdateView):
template_name = "dispatch/companies/edit.html"
- model = Company
- success_url = reverse_lazy('company_list')
+ model = Customer
+ success_url = reverse_lazy('customer_list')
fields = ['name', 'address', 'phone_number','email_address']
def test_func(self):
return self.request.user.is_superuser
-class CompanyDelete(UserPassesTestMixin, DeleteView):
+class CustomerDelete(UserPassesTestMixin, DeleteView):
template_name = "dispatch/companies/delete.html"
- model = Company
- success_url = reverse_lazy('company_list')
+ model = Customer
+ success_url = reverse_lazy('customer_list')
def test_func(self):
return self.request.user.is_superuser
@@ -197,7 +197,7 @@ class LoadList(FilteredListView):
class LoadCreate(CreateView):
template_name = "dispatch/loads/create.html"
model = Load
- fields = ['date', 'company', 'description', 'delivered_to', 'amount']
+ fields = ['date', 'customer', 'description', 'delivered_to', 'amount']
def get(self,request):
if request.user.is_superuser:
@@ -224,7 +224,7 @@ class LoadDetail(DetailView):
class LoadUpdate(FilteredUpdateView):
template_name = "dispatch/loads/edit.html"
model = Load
- fields = ['date', 'company', 'description', 'delivered_to', 'amount']
+ fields = ['date', 'customer', 'description', 'delivered_to', 'amount']
def get(self,request,pk):
if request.user.is_superuser: