aboutsummaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorMitch Riedstra <Mitch@riedstra.us>2017-08-01 10:55:23 -0400
committerMitch Riedstra <Mitch@riedstra.us>2017-08-01 10:55:23 -0400
commit8df0bda39f6c7e56e6f8f4e59b42c8b82aeb750b (patch)
treeb63a1c5b2d5bb5ca6a1902de45889e8d7e403736 /app
parent3c04b55a9734f45b93eafbae19f29544adb20f9b (diff)
downloaddispatch-tracker-8df0bda39f6c7e56e6f8f4e59b42c8b82aeb750b.tar.gz
dispatch-tracker-8df0bda39f6c7e56e6f8f4e59b42c8b82aeb750b.tar.xz
Schema and template updates
Diffstat (limited to 'app')
-rw-r--r--app/dispatch/migrations/0006_auto_20170715_2104.py22
-rw-r--r--app/dispatch/migrations/0007_auto_20170715_2105.py21
-rw-r--r--app/dispatch/models.py4
-rw-r--r--app/dispatch/templates/dispatch/base.html20
-rw-r--r--app/dispatch/templates/dispatch/index.html2
-rw-r--r--app/dispatch/templates/dispatch/login.html3
-rw-r--r--app/dispatch/urls.py1
-rw-r--r--app/dispatch/views.py22
8 files changed, 67 insertions, 28 deletions
diff --git a/app/dispatch/migrations/0006_auto_20170715_2104.py b/app/dispatch/migrations/0006_auto_20170715_2104.py
new file mode 100644
index 0000000..391240f
--- /dev/null
+++ b/app/dispatch/migrations/0006_auto_20170715_2104.py
@@ -0,0 +1,22 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.11.1 on 2017-07-15 21:04
+from __future__ import unicode_literals
+
+from django.conf import settings
+from django.db import migrations, models
+import django.db.models.deletion
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('dispatch', '0005_auto_20170628_1614'),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ model_name='load',
+ name='user',
+ field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL),
+ ),
+ ]
diff --git a/app/dispatch/migrations/0007_auto_20170715_2105.py b/app/dispatch/migrations/0007_auto_20170715_2105.py
new file mode 100644
index 0000000..72781ab
--- /dev/null
+++ b/app/dispatch/migrations/0007_auto_20170715_2105.py
@@ -0,0 +1,21 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.11.1 on 2017-07-15 21:05
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+import django.db.models.deletion
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('dispatch', '0006_auto_20170715_2104'),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ model_name='load',
+ name='company',
+ field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='dispatch.Company'),
+ ),
+ ]
diff --git a/app/dispatch/models.py b/app/dispatch/models.py
index 16703fd..f97c42b 100644
--- a/app/dispatch/models.py
+++ b/app/dispatch/models.py
@@ -25,8 +25,8 @@ class Contact(models.Model):
class Load(models.Model):
date = models.DateField()
- user = models.OneToOneField(settings.AUTH_USER_MODEL)
- company = models.OneToOneField(Company)
+ 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)
diff --git a/app/dispatch/templates/dispatch/base.html b/app/dispatch/templates/dispatch/base.html
index 71483d6..8654d2e 100644
--- a/app/dispatch/templates/dispatch/base.html
+++ b/app/dispatch/templates/dispatch/base.html
@@ -17,7 +17,7 @@
<body>
<nav class="light-blue lighten-1" role="navigation">
- <div class="nav-wrapper container"><a id="logo-container" href="#" class="brand-logo">Logo</a>
+ <div class="nav-wrapper container"><a id="logo-container" href="#" class="brand-logo">Dispatch Tracker</a>
<ul class="right hide-on-med-and-down">
<li><a href="#">Navbar Link</a></li>
</ul>
@@ -46,24 +46,6 @@
</div>
- <div class="col l3 s12">
- <h5 class="white-text">Settings</h5>
- <ul>
- <li><a class="white-text" href="#!">Link 1</a></li>
- <li><a class="white-text" href="#!">Link 2</a></li>
- <li><a class="white-text" href="#!">Link 3</a></li>
- <li><a class="white-text" href="#!">Link 4</a></li>
- </ul>
- </div>
- <div class="col l3 s12">
- <h5 class="white-text">Connect</h5>
- <ul>
- <li><a class="white-text" href="#!">Link 1</a></li>
- <li><a class="white-text" href="#!">Link 2</a></li>
- <li><a class="white-text" href="#!">Link 3</a></li>
- <li><a class="white-text" href="#!">Link 4</a></li>
- </ul>
- </div>
</div>
</div>
<div class="footer-copyright">
diff --git a/app/dispatch/templates/dispatch/index.html b/app/dispatch/templates/dispatch/index.html
index 35b17ad..fd87570 100644
--- a/app/dispatch/templates/dispatch/index.html
+++ b/app/dispatch/templates/dispatch/index.html
@@ -4,6 +4,6 @@
{% block content %}
<br />
-<h1>FUCKING CONTENT </h1>
+<h1>Index Page</h1>
{% endblock %}
diff --git a/app/dispatch/templates/dispatch/login.html b/app/dispatch/templates/dispatch/login.html
index e8e8ede..b43f363 100644
--- a/app/dispatch/templates/dispatch/login.html
+++ b/app/dispatch/templates/dispatch/login.html
@@ -27,9 +27,8 @@
<h3 class="panel-title">Please Sign In</h3>
</div>
<div class="panel-body">
- <form method="post" action="{% url 'django.contrib.auth.LoginView' %}">
+ <form method="post" action="">
{% csrf_token %}
-
<p class="bs-component">
<table>
<tr>
diff --git a/app/dispatch/urls.py b/app/dispatch/urls.py
index 86dc762..d40462b 100644
--- a/app/dispatch/urls.py
+++ b/app/dispatch/urls.py
@@ -8,4 +8,5 @@ from django.contrib.auth import views as authviews
urlpatterns = [
url(r'^$', views.home, name='home'),
url(r'^login/$', authviews.LoginView.as_view(template_name="dispatch/login.html")),
+ url(r'^logout/$', views.logout),
]
diff --git a/app/dispatch/views.py b/app/dispatch/views.py
index 889cf84..916c04b 100644
--- a/app/dispatch/views.py
+++ b/app/dispatch/views.py
@@ -1,7 +1,10 @@
-from django.shortcuts import render
+from django.shortcuts import render, redirect
from django.http import HttpResponse
from django.template import loader
+
from django.contrib.auth.decorators import login_required
+# from django.contrib.auth import authenticate, login, logout
+import django.contrib.auth as auth
# Create your views here.
@@ -11,6 +14,17 @@ def home(request):
return render(request,"dispatch/index.html")
def login(request):
- template = loader.get_template('dispatch/login.html')
- context = {}
- return HttpResponse(template.render(context, request))
+ username = request.POST['username']
+ password = request.POST['password']
+ user = auth.authenticate(request, username=username, password=password)
+ if user is not None:
+ auth.login(request, user)
+ return redirect('/dispatch/')
+ else:
+ template = loader.get_template('dispatch/login.html')
+ context = {}
+ return HttpResponse(template.render(context, request))
+
+def logout(request):
+ auth.logout(request)
+ return redirect('/dispatch/login', permanent=False)