diff --git a/.gitignore b/.gitignore index 7213d8e..058ad98 100644 --- a/.gitignore +++ b/.gitignore @@ -24,6 +24,3 @@ dist/ # Installer logs pip-log.txt pip-delete-this-directory.txt - -# IDE stuff -.idea/ diff --git a/issues/admin.py b/issues/admin.py index dfbf979..034f76d 100644 --- a/issues/admin.py +++ b/issues/admin.py @@ -1,5 +1,6 @@ from django.contrib import admin -from .models import Issue +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 index 82fb950..e9e18f9 100644 --- a/issues/migrations/0001_initial.py +++ b/issues/migrations/0001_initial.py @@ -1,4 +1,4 @@ -# Generated by Django 2.2.1 on 2019-05-27 12:56 +# Generated by Django 2.1.7 on 2019-03-20 22:34 from django.db import migrations, models import django.db.models.deletion @@ -10,7 +10,6 @@ class Migration(migrations.Migration): initial = True dependencies = [ - ('projects', '0001_initial'), ] operations = [ @@ -21,7 +20,20 @@ class Migration(migrations.Migration): ('title', models.CharField(max_length=200)), ('text', models.TextField(blank=True)), ('create_date', models.DateTimeField(default=django.utils.timezone.now)), - ('project', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='projects.Project')), ], ), + 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 180923f..cc04388 100644 --- a/issues/models.py +++ b/issues/models.py @@ -1,7 +1,14 @@ from django.db import models from django.utils import timezone -from projects.models import Project + +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): diff --git a/issues/templates/issues/detail.html b/issues/templates/issues/detail.html deleted file mode 100644 index 42ea47c..0000000 --- a/issues/templates/issues/detail.html +++ /dev/null @@ -1,6 +0,0 @@ -

#{{ issue.id }}: {{ issue.title }}

-

- Project: {{ issue.project }}
- Created: {{ issue.create_date }} -

-

{{ issue.text }}

\ No newline at end of file diff --git a/issues/templates/issues/index.html b/issues/templates/issues/index.html deleted file mode 100644 index bcf3760..0000000 --- a/issues/templates/issues/index.html +++ /dev/null @@ -1,11 +0,0 @@ -{% if issue_list %} - -{% else %} -

No issues.

-{% endif %} \ No newline at end of file diff --git a/issues/urls.py b/issues/urls.py index 93ae9ac..2fcca0d 100644 --- a/issues/urls.py +++ b/issues/urls.py @@ -2,8 +2,6 @@ from django.urls import path from . import views -app_name = 'issues' urlpatterns = [ - path('', views.index, name='index'), - path('/', views.detail, name='detail'), + path('', views.index, name='index') ] diff --git a/issues/views.py b/issues/views.py index b6d463a..3879a9b 100644 --- a/issues/views.py +++ b/issues/views.py @@ -1,17 +1,6 @@ -from django.shortcuts import get_object_or_404, render - -from .models import Issue +# from django.shortcuts import render +from django.http import HttpResponse def index(request): - issue_list = Issue.objects.order_by('create_date') - return render(request, 'issues/index.html', { - 'issue_list': issue_list, - }) - - -def detail(request, issue_id): - issue = get_object_or_404(Issue, pk=issue_id) - return render(request, 'issues/detail.html', { - 'issue': issue, - }) + return HttpResponse('Hello Tofu.') diff --git a/projects/__init__.py b/projects/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/projects/admin.py b/projects/admin.py deleted file mode 100644 index badc1bb..0000000 --- a/projects/admin.py +++ /dev/null @@ -1,5 +0,0 @@ -from django.contrib import admin - -from .models import Project - -admin.site.register(Project) diff --git a/projects/apps.py b/projects/apps.py deleted file mode 100644 index 3ef44de..0000000 --- a/projects/apps.py +++ /dev/null @@ -1,5 +0,0 @@ -from django.apps import AppConfig - - -class ProjectsConfig(AppConfig): - name = 'projects' diff --git a/projects/migrations/0001_initial.py b/projects/migrations/0001_initial.py deleted file mode 100644 index 55089c4..0000000 --- a/projects/migrations/0001_initial.py +++ /dev/null @@ -1,23 +0,0 @@ -# Generated by Django 2.2.1 on 2019-05-27 12:56 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - initial = True - - dependencies = [ - ] - - operations = [ - 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)), - ], - ), - ] diff --git a/projects/migrations/__init__.py b/projects/migrations/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/projects/models.py b/projects/models.py deleted file mode 100644 index c6ba458..0000000 --- a/projects/models.py +++ /dev/null @@ -1,10 +0,0 @@ -from django.db import models - - -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 diff --git a/projects/templates/projects/index.html b/projects/templates/projects/index.html deleted file mode 100644 index b64c0da..0000000 --- a/projects/templates/projects/index.html +++ /dev/null @@ -1,11 +0,0 @@ -{% if project_list %} - -{% else %} -

No projects.

-{% endif %} \ No newline at end of file diff --git a/projects/templates/projects/view.html b/projects/templates/projects/view.html deleted file mode 100644 index e38e16f..0000000 --- a/projects/templates/projects/view.html +++ /dev/null @@ -1,15 +0,0 @@ -

{{ project.project_key }} - {{ project.name }}

-

{{ project.description }}

- -

Issues

-{% if issue_list %} - -{% else %} -

This project has no issues yet.

-{% endif %} \ No newline at end of file diff --git a/projects/tests.py b/projects/tests.py deleted file mode 100644 index 7ce503c..0000000 --- a/projects/tests.py +++ /dev/null @@ -1,3 +0,0 @@ -from django.test import TestCase - -# Create your tests here. diff --git a/projects/urls.py b/projects/urls.py deleted file mode 100644 index d53296a..0000000 --- a/projects/urls.py +++ /dev/null @@ -1,9 +0,0 @@ -from django.urls import path - -from . import views - -app_name = 'projects' -urlpatterns = [ - path('', views.index, name='index'), - path('/', views.view, name='view'), -] diff --git a/projects/views.py b/projects/views.py deleted file mode 100644 index 8f914a0..0000000 --- a/projects/views.py +++ /dev/null @@ -1,20 +0,0 @@ -from django.shortcuts import get_object_or_404, render - -from .models import Project -from issues.models import Issue - - -def index(request): - project_list = Project.objects.order_by('project_key') - return render(request, 'projects/index.html', { - 'project_list': project_list, - }) - - -def view(request, project_key): - project = get_object_or_404(Project, project_key=project_key) - issue_list = Issue.objects.filter(project=project.id).order_by('create_date') - return render(request, 'projects/view.html', { - 'project': project, - 'issue_list': issue_list, - }) diff --git a/tofu/settings.py b/tofu/settings.py index c0a261a..a6d2ece 100644 --- a/tofu/settings.py +++ b/tofu/settings.py @@ -32,7 +32,6 @@ ALLOWED_HOSTS = [] INSTALLED_APPS = [ 'issues.apps.IssuesConfig', - 'projects.apps.ProjectsConfig', 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', diff --git a/tofu/urls.py b/tofu/urls.py index cda4b72..30e127a 100644 --- a/tofu/urls.py +++ b/tofu/urls.py @@ -18,6 +18,5 @@ from django.urls import include, path urlpatterns = [ path('issues/', include('issues.urls')), - path('projects/', include('projects.urls')), path('admin/', admin.site.urls), ]