From b8fa5c2bfe74ae4ef4da1dc2f4c884f1ec165668 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A1s=20Cz=C3=A9m=C3=A1n?= <trabarni@gmail.com> Date: Mon, 28 May 2018 17:22:37 +0200 Subject: [PATCH] Create initial app & models for documents --- src/document/__init__.py | 0 src/document/admin.py | 3 +++ src/document/apps.py | 5 +++++ src/document/migrations/0001_initial.py | 27 +++++++++++++++++++++++++ src/document/migrations/__init__.py | 0 src/document/models.py | 14 +++++++++++++ src/document/tests.py | 3 +++ src/document/views.py | 3 +++ src/kszkepzes/settings/base.py | 1 + 9 files changed, 56 insertions(+) create mode 100644 src/document/__init__.py create mode 100644 src/document/admin.py create mode 100644 src/document/apps.py create mode 100644 src/document/migrations/0001_initial.py create mode 100644 src/document/migrations/__init__.py create mode 100644 src/document/models.py create mode 100644 src/document/tests.py create mode 100644 src/document/views.py diff --git a/src/document/__init__.py b/src/document/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/document/admin.py b/src/document/admin.py new file mode 100644 index 0000000..8c38f3f --- /dev/null +++ b/src/document/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/src/document/apps.py b/src/document/apps.py new file mode 100644 index 0000000..fd7bdcb --- /dev/null +++ b/src/document/apps.py @@ -0,0 +1,5 @@ +from django.apps import AppConfig + + +class DocumentConfig(AppConfig): + name = 'document' diff --git a/src/document/migrations/0001_initial.py b/src/document/migrations/0001_initial.py new file mode 100644 index 0000000..1982261 --- /dev/null +++ b/src/document/migrations/0001_initial.py @@ -0,0 +1,27 @@ +# Generated by Django 2.0.1 on 2018-05-28 15:21 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ('account', '0017_auto_20180205_2004'), + ] + + operations = [ + migrations.CreateModel( + name='Document', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('uploaded_at', models.DateTimeField(auto_now_add=True)), + ('name', models.CharField(max_length=150)), + ('description', models.TextField()), + ('file', models.FileField(upload_to='')), + ('uploaded_by', models.ForeignKey(on_delete=django.db.models.deletion.DO_NOTHING, to='account.Profile')), + ], + ), + ] diff --git a/src/document/migrations/__init__.py b/src/document/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/document/models.py b/src/document/models.py new file mode 100644 index 0000000..e2c30e3 --- /dev/null +++ b/src/document/models.py @@ -0,0 +1,14 @@ +from django.db import models + +from account.models import Profile + + +class Document(models.Model): + uploaded_by = models.ForeignKey(Profile, on_delete=models.DO_NOTHING) + uploaded_at = models.DateTimeField(auto_now_add=True, editable=False) + name = models.CharField(max_length=150) + description = models.TextField() + file = models.FileField() + + def __str__(self): + return self.name diff --git a/src/document/tests.py b/src/document/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/src/document/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/src/document/views.py b/src/document/views.py new file mode 100644 index 0000000..91ea44a --- /dev/null +++ b/src/document/views.py @@ -0,0 +1,3 @@ +from django.shortcuts import render + +# Create your views here. diff --git a/src/kszkepzes/settings/base.py b/src/kszkepzes/settings/base.py index 277106b..dd73603 100644 --- a/src/kszkepzes/settings/base.py +++ b/src/kszkepzes/settings/base.py @@ -47,6 +47,7 @@ INSTALLED_APPS = [ 'account', 'stats', 'news', + 'document', ] MIDDLEWARE = [ -- GitLab