diff options
| author | Mitch Riedstra <mitch@riedstra.us> | 2019-01-19 17:41:30 -0500 |
|---|---|---|
| committer | Mitch Riedstra <mitch@riedstra.us> | 2019-01-19 17:41:30 -0500 |
| commit | af0c892c49156fa1dfe7fe5c28d0e8b4dd9ba8b1 (patch) | |
| tree | d5fefa66285714c7a72ccc7901e1522784328f3f | |
| parent | d16ac1fa8e8b7019156ae11267a23d957aed6495 (diff) | |
| download | dispatch-tracker-af0c892c49156fa1dfe7fe5c28d0e8b4dd9ba8b1.tar.gz dispatch-tracker-af0c892c49156fa1dfe7fe5c28d0e8b4dd9ba8b1.tar.xz | |
Most things seem to work, needs more testing
| -rw-r--r-- | .gitignore | 3 | ||||
| -rw-r--r-- | README.md | 29 | ||||
| -rw-r--r-- | app/config-example.yml | 20 | ||||
| -rw-r--r-- | app/dispatch/middleware.py | 4 | ||||
| -rw-r--r-- | app/dispatch/models.py | 6 | ||||
| -rw-r--r-- | app/dispatch/views.py | 8 | ||||
| -rw-r--r-- | app/dispatchAuth/models.py | 2 | ||||
| -rw-r--r-- | app/requirements.txt | 4 |
8 files changed, 52 insertions, 24 deletions
@@ -60,3 +60,6 @@ target/ app/uwsgi.pid static + +pg_data +pg_log @@ -4,7 +4,7 @@ Most of the features are here and the application should fulfill the use case at this time. -Things to fix/add going forward: +## Things to fix/add going forward: * Friendly Error pages * Description format field for customer objects & @@ -16,14 +16,37 @@ Things to fix/add going forward: * Figure out if auditlog timestamps are fucked or not with timezones -To get a development system setup: +## To get a development system setup: +Not strictly part of the Django app, but worth noting that if you have +Postgres installed locally but don't want to muck with permissions, service +etc it's as simple as: + +```bash +pg_ctl -D pg_data initdb +pg_ctl -D pg_data -l pg_log start +echo create database $(id -un)\; | psql postgres +``` + +Your user should be able to connect with just a simple `psql` + +You will need to install + +``` +base-devel +python3-devel +postgresql-libs-devel +``` + +On Void Linux. On Ubuntu machines it will be similar. ``` bash cd app virtualenv env . env/bin/activate pip install -r requirements.txt +cp config-example.yml config.yml +sed -i.bak -e"s/USER: postgres$/USER: $(id -un)" config.yml ./manage.py migrate ./manage.py createsuperuser # This will create some fake records if you wish @@ -37,7 +60,7 @@ pip install -r requirements.txt -To get a production system setup: +## To get a production system setup: ``` bash diff --git a/app/config-example.yml b/app/config-example.yml index bae3923..eab6d57 100644 --- a/app/config-example.yml +++ b/app/config-example.yml @@ -1,12 +1,12 @@ --- # Postgres Example -# db_default: -# ENGINE: django.db.backends.postgresql -# NAME: dispatch -# USER: postgres -# PASSWORD: -# HOST: 127.0.0.1 -# PORT: 5432 +db_default: + ENGINE: django.db.backends.postgresql + NAME: dispatch + USER: postgres + PASSWORD: + HOST: 127.0.0.1 + PORT: 5432 # MySQL Example # db_default: # ENGINE: django.db.backends.mysql @@ -16,9 +16,9 @@ # HOST: 127.0.0.1 # PORT: 3306 # Sqlite example. Full path is recommended -db_default: - ENGINE: django.db.backends.sqlite3 - NAME: /home/mitch/scm/dispatch-tracker/app/db.sqlite3 +# db_default: +# ENGINE: django.db.backends.sqlite3 +# NAME: /home/mitch/scm/dispatch-tracker/app/db.sqlite3 allowed_hosts: - localhost diff --git a/app/dispatch/middleware.py b/app/dispatch/middleware.py index a3b9ec6..5669d4f 100644 --- a/app/dispatch/middleware.py +++ b/app/dispatch/middleware.py @@ -1,7 +1,7 @@ from django.http import HttpResponseRedirect from django.conf import settings import re -from django.core.urlresolvers import reverse, reverse_lazy +from django.urls import reverse, reverse_lazy EXEMPT_URLS = [ reverse('login'), @@ -26,7 +26,7 @@ class LoginRequiredMiddleware(object): self.get_response = get_response def __call__(self, request): - if not request.user or not request.user.is_authenticated(): + if not request.user.is_authenticated: path = request.path_info # Check for any regex matches reg = EXEMPT_REGEX.match(path) diff --git a/app/dispatch/models.py b/app/dispatch/models.py index 5d8ae6c..a933c76 100644 --- a/app/dispatch/models.py +++ b/app/dispatch/models.py @@ -7,7 +7,7 @@ from datetime import datetime from django.core.exceptions import ObjectDoesNotExist from .misc import get_week_dates, paperwork_user_directory_path, \ get_week_dates_datetime -from django.core.urlresolvers import reverse +from django.urls import reverse import re # Create your models here. @@ -44,8 +44,8 @@ class Customer(models.Model): class Load(models.Model): history = AuditlogHistoryField() date = models.DateField() - user = models.ForeignKey(settings.AUTH_USER_MODEL) - customer = models.ForeignKey(Customer) + user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE) + customer = models.ForeignKey(Customer, on_delete=models.CASCADE) 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") diff --git a/app/dispatch/views.py b/app/dispatch/views.py index f4e9a92..fc8bab2 100644 --- a/app/dispatch/views.py +++ b/app/dispatch/views.py @@ -3,7 +3,7 @@ from django.http import HttpResponse from django.utils.encoding import smart_str from auditlog.models import LogEntry # from django.template import loader -from django.core.urlresolvers import reverse +from django.urls import reverse, reverse_lazy # import django.contrib.auth as auth # from django.conf import settings # Create your views here. @@ -12,7 +12,6 @@ from django.core.exceptions import ObjectDoesNotExist from django.views.generic import 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 Customer, Load, Paperwork, \ Invoice, UserInvoiceNumber, Identity, Settings from dispatch.forms import AddPaperworkForm, InviteForm @@ -80,8 +79,11 @@ class FilteredDeleteView(DeleteView): class DriverList(UserPassesTestMixin, ListView): template_name = "dispatch/drivers/list.html" - model = User paginate_by = 10 + # model = User + + def get_queryset(self): + return User.objects.order_by("id") def test_func(self): return self.request.user.is_superuser diff --git a/app/dispatchAuth/models.py b/app/dispatchAuth/models.py index fe720fd..5244c54 100644 --- a/app/dispatchAuth/models.py +++ b/app/dispatchAuth/models.py @@ -2,7 +2,7 @@ from django.contrib.auth.models import AbstractUser, AbstractBaseUser, Permissio from app.settings import WEBSITE_URI, WEB_APP_NAME from django.template.loader import render_to_string from django.core.mail import send_mail -from django.core.urlresolvers import reverse +from django.urls import reverse from django.db import models # Create your models here. diff --git a/app/requirements.txt b/app/requirements.txt index c4f2f33..f6bfcf2 100644 --- a/app/requirements.txt +++ b/app/requirements.txt @@ -1,5 +1,5 @@ -Django==1.11.5 -django-auditlog==0.4.3 +Django==2.1.5 +django-auditlog==0.4.5 django-jsonfield==1.0.1 Faker==0.8.4 psycopg2==2.7.3.2 |
