diff options
Diffstat (limited to 'ctrack/organisations')
-rw-r--r-- | ctrack/organisations/__init__.py | 0 | ||||
-rw-r--r-- | ctrack/organisations/admin.py | 6 | ||||
-rw-r--r-- | ctrack/organisations/apps.py | 5 | ||||
-rw-r--r-- | ctrack/organisations/migrations/0001_initial.py | 21 | ||||
-rw-r--r-- | ctrack/organisations/migrations/__init__.py | 0 | ||||
-rw-r--r-- | ctrack/organisations/models.py | 15 | ||||
-rw-r--r-- | ctrack/organisations/tests/__init__.py | 0 | ||||
-rw-r--r-- | ctrack/organisations/tests/test_models.py | 11 | ||||
-rw-r--r-- | ctrack/organisations/urls.py | 9 | ||||
-rw-r--r-- | ctrack/organisations/views.py | 2 |
10 files changed, 69 insertions, 0 deletions
diff --git a/ctrack/organisations/__init__.py b/ctrack/organisations/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/ctrack/organisations/__init__.py diff --git a/ctrack/organisations/admin.py b/ctrack/organisations/admin.py new file mode 100644 index 0000000..8890f15 --- /dev/null +++ b/ctrack/organisations/admin.py @@ -0,0 +1,6 @@ +from django.contrib import admin + +from .models import Organisation + +# Register your models here. +admin.site.register(Organisation) diff --git a/ctrack/organisations/apps.py b/ctrack/organisations/apps.py new file mode 100644 index 0000000..72eb1d9 --- /dev/null +++ b/ctrack/organisations/apps.py @@ -0,0 +1,5 @@ +from django.apps import AppConfig + + +class OrganisationsConfig(AppConfig): + name = 'ctrack.organisations' diff --git a/ctrack/organisations/migrations/0001_initial.py b/ctrack/organisations/migrations/0001_initial.py new file mode 100644 index 0000000..6171bb8 --- /dev/null +++ b/ctrack/organisations/migrations/0001_initial.py @@ -0,0 +1,21 @@ +# Generated by Django 2.2.9 on 2020-01-20 16:12 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ] + + operations = [ + migrations.CreateModel( + name='Organisation', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('name', models.CharField(max_length=255)), + ], + ), + ] diff --git a/ctrack/organisations/migrations/__init__.py b/ctrack/organisations/migrations/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/ctrack/organisations/migrations/__init__.py diff --git a/ctrack/organisations/models.py b/ctrack/organisations/models.py new file mode 100644 index 0000000..976e661 --- /dev/null +++ b/ctrack/organisations/models.py @@ -0,0 +1,15 @@ +from django.db import models + +# Create your models here. +from django.urls import reverse +from slugify import slugify + + +class Organisation(models.Model): + name = models.CharField(max_length=255, blank=False) + + def get_absolute_url(self): + return reverse("organisations:detail", kwargs={"name": self.slugify_name()}) + + def slugify_name(self): + return slugify(self.name) diff --git a/ctrack/organisations/tests/__init__.py b/ctrack/organisations/tests/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/ctrack/organisations/tests/__init__.py diff --git a/ctrack/organisations/tests/test_models.py b/ctrack/organisations/tests/test_models.py new file mode 100644 index 0000000..1307a83 --- /dev/null +++ b/ctrack/organisations/tests/test_models.py @@ -0,0 +1,11 @@ +import pytest +from slugify import slugify + +from ..models import Organisation + +pytestmark = pytest.mark.django_db + + +def test_organisation_get_absolute_url(org: Organisation): + slug = slugify(org.name) + assert org.get_absolute_url() == f"/organisations/{slug}/" diff --git a/ctrack/organisations/urls.py b/ctrack/organisations/urls.py new file mode 100644 index 0000000..a3b1b9f --- /dev/null +++ b/ctrack/organisations/urls.py @@ -0,0 +1,9 @@ +from django.urls import path + +from ctrack.organisations.views import organisations_detail_view + +app_name = "organisations" + +urlpatterns = [ + path("<str:name>/", view=organisations_detail_view, name="detail") +] diff --git a/ctrack/organisations/views.py b/ctrack/organisations/views.py new file mode 100644 index 0000000..30d00be --- /dev/null +++ b/ctrack/organisations/views.py @@ -0,0 +1,2 @@ +def organisations_detail_view(request): + pass |