From 9d77a7d232e8d2712ecc9290b5746d4623fac39e Mon Sep 17 00:00:00 2001 From: binaryDiv Date: Wed, 20 Mar 2019 23:35:33 +0100 Subject: [PATCH] add index view; add Project and Issue models --- issues/admin.py | 5 +++- issues/migrations/0001_initial.py | 39 +++++++++++++++++++++++++++++++ issues/models.py | 20 +++++++++++++++- issues/urls.py | 7 ++++++ issues/views.py | 7 ++++-- tofu/settings.py | 3 ++- tofu/urls.py | 3 ++- 7 files changed, 78 insertions(+), 6 deletions(-) create mode 100644 issues/migrations/0001_initial.py create mode 100644 issues/urls.py diff --git a/issues/admin.py b/issues/admin.py index 8c38f3f..034f76d 100644 --- a/issues/admin.py +++ b/issues/admin.py @@ -1,3 +1,6 @@ from django.contrib import admin -# Register your models here. +from .models import Project, Issue + +admin.site.register(Project) +admin.site.register(Issue) diff --git a/issues/migrations/0001_initial.py b/issues/migrations/0001_initial.py new file mode 100644 index 0000000..e9e18f9 --- /dev/null +++ b/issues/migrations/0001_initial.py @@ -0,0 +1,39 @@ +# Generated by Django 2.1.7 on 2019-03-20 22:34 + +from django.db import migrations, models +import django.db.models.deletion +import django.utils.timezone + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ] + + operations = [ + migrations.CreateModel( + name='Issue', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('title', models.CharField(max_length=200)), + ('text', models.TextField(blank=True)), + ('create_date', models.DateTimeField(default=django.utils.timezone.now)), + ], + ), + migrations.CreateModel( + name='Project', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('project_key', models.CharField(max_length=16, unique=True)), + ('name', models.CharField(max_length=200)), + ('description', models.TextField(blank=True)), + ], + ), + migrations.AddField( + model_name='issue', + name='project', + field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='issues.Project'), + ), + ] diff --git a/issues/models.py b/issues/models.py index 71a8362..cc04388 100644 --- a/issues/models.py +++ b/issues/models.py @@ -1,3 +1,21 @@ from django.db import models +from django.utils import timezone -# Create your models here. + +class Project(models.Model): + project_key = models.CharField(max_length=16, unique=True) + name = models.CharField(max_length=200) + description = models.TextField(blank=True) + + def __str__(self): + return self.name + + +class Issue(models.Model): + project = models.ForeignKey(Project, on_delete=models.CASCADE) + title = models.CharField(max_length=200) + text = models.TextField(blank=True) + create_date = models.DateTimeField(default=timezone.now) + + def __str__(self): + return self.title diff --git a/issues/urls.py b/issues/urls.py new file mode 100644 index 0000000..2fcca0d --- /dev/null +++ b/issues/urls.py @@ -0,0 +1,7 @@ +from django.urls import path + +from . import views + +urlpatterns = [ + path('', views.index, name='index') +] diff --git a/issues/views.py b/issues/views.py index 91ea44a..3879a9b 100644 --- a/issues/views.py +++ b/issues/views.py @@ -1,3 +1,6 @@ -from django.shortcuts import render +# from django.shortcuts import render +from django.http import HttpResponse -# Create your views here. + +def index(request): + return HttpResponse('Hello Tofu.') diff --git a/tofu/settings.py b/tofu/settings.py index fddf93d..a6d2ece 100644 --- a/tofu/settings.py +++ b/tofu/settings.py @@ -31,6 +31,7 @@ ALLOWED_HOSTS = [] # Application definition INSTALLED_APPS = [ + 'issues.apps.IssuesConfig', 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', @@ -105,7 +106,7 @@ AUTH_PASSWORD_VALIDATORS = [ LANGUAGE_CODE = 'en-us' -TIME_ZONE = 'UTC' +TIME_ZONE = 'Europe/Berlin' USE_I18N = True diff --git a/tofu/urls.py b/tofu/urls.py index c6a89d2..30e127a 100644 --- a/tofu/urls.py +++ b/tofu/urls.py @@ -14,8 +14,9 @@ Including another URLconf 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) """ from django.contrib import admin -from django.urls import path +from django.urls import include, path urlpatterns = [ + path('issues/', include('issues.urls')), path('admin/', admin.site.urls), ]