aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ctrack/organisations/admin.py1
-rw-r--r--ctrack/organisations/migrations/0008_auto_20200123_1657.py29
-rw-r--r--ctrack/organisations/models.py21
-rw-r--r--ctrack/organisations/templates/organisations/organisation_detail.html50
-rw-r--r--ctrack/organisations/urls.py2
-rw-r--r--ctrack/organisations/views.py19
-rw-r--r--ctrack/static/css/project.css47
-rw-r--r--ctrack/static/css/project.css.map1
-rw-r--r--ctrack/static/sass/project.scss38
-rw-r--r--ctrack/templates/account/login.html30
-rw-r--r--ctrack/templates/base.html24
11 files changed, 239 insertions, 23 deletions
diff --git a/ctrack/organisations/admin.py b/ctrack/organisations/admin.py
index 686cb30..f8ad2aa 100644
--- a/ctrack/organisations/admin.py
+++ b/ctrack/organisations/admin.py
@@ -15,6 +15,7 @@ class AddressInLine(admin.StackedInline):
class OrganisationAdmin(admin.ModelAdmin):
inlines = [AddressInLine,]
+ list_display = ('slug', 'name')
# Register your models here.
diff --git a/ctrack/organisations/migrations/0008_auto_20200123_1657.py b/ctrack/organisations/migrations/0008_auto_20200123_1657.py
new file mode 100644
index 0000000..1b9f833
--- /dev/null
+++ b/ctrack/organisations/migrations/0008_auto_20200123_1657.py
@@ -0,0 +1,29 @@
+# Generated by Django 2.2.9 on 2020-01-23 16:57
+
+from django.db import migrations, models
+import django.db.models.deletion
+import django_extensions.db.fields
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('organisations', '0007_auto_20200121_1806'),
+ ]
+
+ operations = [
+ migrations.AlterModelOptions(
+ name='address',
+ options={'verbose_name_plural': 'Addresses'},
+ ),
+ migrations.AddField(
+ model_name='organisation',
+ name='slug',
+ field=django_extensions.db.fields.AutoSlugField(blank=True, editable=False, populate_from=['name']),
+ ),
+ migrations.AlterField(
+ model_name='address',
+ name='type',
+ field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='organisations.AddressType', verbose_name='Address Type'),
+ ),
+ ]
diff --git a/ctrack/organisations/models.py b/ctrack/organisations/models.py
index 727ef58..0ecac94 100644
--- a/ctrack/organisations/models.py
+++ b/ctrack/organisations/models.py
@@ -2,22 +2,30 @@ from django.db import models
# Create your models here.
from django.urls import reverse
+from django_extensions.db.fields import AutoSlugField
from slugify import slugify
class AddressType(models.Model):
descriptor = models.CharField(max_length=50)
+ def __str__(self):
+ return self.descriptor
+
class Organisation(models.Model):
name = models.CharField(max_length=255, blank=False)
+ slug = AutoSlugField(populate_from=['name'])
def get_absolute_url(self):
- return reverse("organisations:detail", kwargs={"name": self.slugify_name()})
+ return reverse("organisations:detail", kwargs={"slug": self.slug})
def slugify_name(self):
return slugify(self.name)
+ def __str__(self):
+ return self.name
+
class Address(models.Model):
organisation = models.ForeignKey(
@@ -27,13 +35,16 @@ class Address(models.Model):
AddressType, verbose_name="Address Type", on_delete=models.CASCADE, blank=False
)
line1 = models.CharField(max_length=255)
- line2 = models.CharField(max_length=255)
- line3 = models.CharField(max_length=255)
+ line2 = models.CharField(max_length=255, blank=True)
+ line3 = models.CharField(max_length=255, blank=True)
city = models.CharField(max_length=100)
- county = models.CharField(max_length=100)
+ county = models.CharField(max_length=100, blank=True)
postcode = models.CharField(max_length=10)
country = models.CharField(max_length=100)
- other_details = models.CharField(max_length=255)
+ other_details = models.CharField(max_length=255, blank=True)
+
+ def __str__(self):
+ return " ".join([self.organisation.name, self.line1])
class Meta:
verbose_name_plural = "Addresses"
diff --git a/ctrack/organisations/templates/organisations/organisation_detail.html b/ctrack/organisations/templates/organisations/organisation_detail.html
new file mode 100644
index 0000000..5302ef4
--- /dev/null
+++ b/ctrack/organisations/templates/organisations/organisation_detail.html
@@ -0,0 +1,50 @@
+{% extends "base.html" %}
+
+{% block content %}
+ <h2>Organisation detail</h2>
+ <div class="container">
+ <div class="row">
+ {% if n_addr > 1 %}
+ {% for a in addr %}
+ <div class="col-md-6">
+ <div class="card" style="width: 18rem;">
+ <div class="card-body">
+ <h5 class="card-title">{{ object.name }}</h5>
+ <h6 class="card-subtitle mb-2 text-muted">{{ a.type }}</h6>
+ <p class="card-text">
+ {{ a.line1 }}<br>
+ {{ a.line2 }}<br>
+ {{ a.line3 }}<br>
+ {{ a.city }}<br>
+ {{ a.county }}<br>
+ {{ a.country}}<br>
+ </p>
+ <p><strong>{{ a.other_details }}</strong><br></p>
+ <a href="#" class="card-link">Edit Details</a>
+ </div>
+ </div>
+ </div>
+ {% endfor %}
+ {% else %}
+ <div class="col-md-12">
+ <div class="card" style="width: 18rem;">
+ <div class="card-body">
+ <h5 class="card-title">{{ object.name }}</h5>
+ <h6 class="card-subtitle mb-2 text-muted">{{ addr.type }}</h6>
+ <p class="card-text">
+ {{ addr.line1 }}<br>
+ {{ addr.line2 }}<br>
+ {{ addr.line3 }}<br>
+ {{ addr.city }}<br>
+ {{ addr.county }}<br>
+ {{ addr.country}}<br>
+ </p>
+ <p><strong>{{ addr.other_details }}</strong><br></p>
+ <a href="#" class="card-link">Edit Details</a>
+ </div>
+ </div>
+ </div>
+ {% endif %}
+ </div>
+ </div>
+{% endblock %}
diff --git a/ctrack/organisations/urls.py b/ctrack/organisations/urls.py
index c6cc382..454d73f 100644
--- a/ctrack/organisations/urls.py
+++ b/ctrack/organisations/urls.py
@@ -5,5 +5,5 @@ from ctrack.organisations.views import OrganisationDetailView
app_name = "organisations"
urlpatterns = [
- path("<str:name>/", view=OrganisationDetailView, name="detail")
+ path("<slug:slug>/", view=OrganisationDetailView.as_view(), name="detail")
]
diff --git a/ctrack/organisations/views.py b/ctrack/organisations/views.py
index 92bb134..1ec5469 100644
--- a/ctrack/organisations/views.py
+++ b/ctrack/organisations/views.py
@@ -1,8 +1,27 @@
+from typing import Any
+
from django.contrib.auth.mixins import LoginRequiredMixin
+from django.http import HttpRequest
+from django.http import HttpResponse
from django.views.generic import DetailView
+from typing import Dict
from .models import Organisation
class OrganisationDetailView(LoginRequiredMixin, DetailView):
model = Organisation
+
+ def get_context_data(self, **kwargs: Any) -> Dict[str, Any]:
+ context = super().get_context_data()
+ org = kwargs['object']
+ no_addr = org.addresses.count()
+ if no_addr > 1:
+ context['no_addr'] = no_addr
+ addr = org.addresses.all()
+ context['addr'] = addr
+ else:
+ context['no_addr'] = 1
+ addr = org.addresses.first()
+ context['addr'] = addr
+ return context
diff --git a/ctrack/static/css/project.css b/ctrack/static/css/project.css
index f1d543d..dfcbc99 100644
--- a/ctrack/static/css/project.css
+++ b/ctrack/static/css/project.css
@@ -1,13 +1,50 @@
-/* These styles are generated from project.scss. */
-
.alert-debug {
- color: black;
- background-color: white;
+ background-color: #fff;
border-color: #d6e9c6;
+ color: #000;
}
.alert-error {
- color: #b94a48;
background-color: #f2dede;
border-color: #eed3d7;
+ color: #b94a48;
+}
+
+.bg-light {
+ background-color: green;
+}
+
+.btn:hover {
+ background-color: red;
+ border-color: orange;
+}
+
+.container a {
+ color: darkslategrey;
+ background-color: yellowgreen;
+ font-size: large;
}
+
+#chunky {
+ border: 8px dashed yellowgreen;
+ border-radius: 10px;
+ box-shadow: 3px 10px 12px lightgray;
+}
+
+.table-sm tr {
+ font-size: 0.75rem;
+ line-height: 10px;
+ min-height: 10px;
+}
+
+.textinput {
+ background-color: lightgoldenrodyellow;
+ box-shadow: 2px 10px 15px lightgray;
+ height: 49px;
+}
+
+#_title {
+ color: orangered;
+}
+
+/*# sourceMappingURL=project.css.map */
diff --git a/ctrack/static/css/project.css.map b/ctrack/static/css/project.css.map
new file mode 100644
index 0000000..cee13e7
--- /dev/null
+++ b/ctrack/static/css/project.css.map
@@ -0,0 +1 @@
+{"version":3,"sourceRoot":"","sources":["../sass/project.scss"],"names":[],"mappings":"AA2BA;EACE,kBAhBM;EAiBN,cAhBW;EAiBX,OAhBM;;;AAmBR;EACE,kBAnBK;EAoBL,cAnBU;EAoBV,OAnBI;;;AAsBN;EACE;;;AAGF;EACE;EACA;;;AAGF;EACE;EACA;EACA;;;AAGF;EACE;EACA;EACA;;;AAGF;EACE;EACA;EACA;;;AAGF;EACE;EACA;EACA,QAnDa;;;AAsDf;EACE","file":"project.css"} \ No newline at end of file
diff --git a/ctrack/static/sass/project.scss b/ctrack/static/sass/project.scss
index 3c8f261..5980b48 100644
--- a/ctrack/static/sass/project.scss
+++ b/ctrack/static/sass/project.scss
@@ -16,6 +16,7 @@ $black: #000;
$pink: #f2dede;
$dark-pink: #eed3d7;
$red: #b94a48;
+$input-height: 49px;
////////////////////////////////
//Alerts//
@@ -35,3 +36,40 @@ $red: #b94a48;
border-color: $dark-pink;
color: $red;
}
+
+.bg-light {
+ background-color: green;
+}
+
+.btn:hover {
+ background-color: red;
+ border-color: orange;
+}
+
+.container a {
+ color: darkslategrey;
+ background-color: yellowgreen;
+ font-size: large;
+}
+
+#chunky {
+ border: 8px dashed yellowgreen;
+ border-radius: 10px;
+ box-shadow: 3px 10px 12px lightgray;
+}
+
+.table-sm tr {
+ font-size: 0.75rem;
+ line-height: 10px;
+ min-height: 10px;
+}
+
+.textinput {
+ background-color: lightgoldenrodyellow;
+ box-shadow: 2px 10px 15px lightgray;
+ height: $input-height;
+}
+
+#_title {
+ color: orangered;
+}
diff --git a/ctrack/templates/account/login.html b/ctrack/templates/account/login.html
index 2cadea6..fbaa171 100644
--- a/ctrack/templates/account/login.html
+++ b/ctrack/templates/account/login.html
@@ -44,5 +44,35 @@ for a {{ site_name }} account and sign in below:{% endblocktrans %}</p>
<button class="primaryAction btn btn-primary" type="submit">{% trans "Sign In" %}</button>
</form>
+<table class="table table-sm table-bordered">
+ <thead>
+ <tr>
+ <th scope="col">#</th>
+ <th scope="col">First</th>
+ <th scope="col">Last</th>
+ <th scope="col">Handle</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <th scope="row">1</th>
+ <td>Mark</td>
+ <td>Otto</td>
+ <td>@mdo</td>
+ </tr>
+ <tr>
+ <th scope="row">2</th>
+ <td>Jacob</td>
+ <td>Thornton</td>
+ <td>@fat</td>
+ </tr>
+ <tr>
+ <th scope="row">3</th>
+ <td>Larry</td>
+ <td>the Bird</td>
+ <td>@twitter</td>
+ </tr>
+ </tbody>
+</table>
{% endblock %}
diff --git a/ctrack/templates/base.html b/ctrack/templates/base.html
index fbe9d86..7ed25a7 100644
--- a/ctrack/templates/base.html
+++ b/ctrack/templates/base.html
@@ -16,18 +16,18 @@
<link rel="icon" href="{% static 'images/favicons/favicon.ico' %}">
{% block css %}
-
+
<!-- Latest compiled and minified Bootstrap CSS -->
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
-
+
<!-- Your stuff: Third-party CSS libraries go here -->
-
+
<!-- This file stores project-specific CSS -->
-
+
<link href="{% static 'css/project.css' %}" rel="stylesheet">
-
-
+
+
{% endblock %}
</head>
@@ -39,7 +39,7 @@
<button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
- <a class="navbar-brand" href="{% url 'home' %}">ctrack</a>
+ <a id="_title" class="navbar-brand" href="{% url 'home' %}">ctrack</a>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav mr-auto">
@@ -94,21 +94,21 @@
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
{% block javascript %}
-
+
<!-- Bootstrap JS and its dependencies-->
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
<!-- Your stuff: Third-party javascript libraries go here -->
-
+
<!-- place project specific Javascript in this file -->
-
+
<script src="{% static 'js/project.js' %}"></script>
-
+
{% endblock javascript %}
</body>
</html>
-
+