From b5f002276d0e5b0777e63986d632b8e2f022cebb Mon Sep 17 00:00:00 2001
From: janmax <mail-github@jmx.io>
Date: Fri, 3 Mar 2017 19:41:40 +0100
Subject: [PATCH] Added core app, .editorconfig and defined models

---
 .editorconfig                              | 24 +++++++
 core/__init__.py                           |  0
 core/admin.py                              |  9 +++
 core/apps.py                               |  5 ++
 core/migrations/0001_initial.py            | 25 ++++++++
 core/migrations/0002_auto_20170303_1837.py | 75 ++++++++++++++++++++++
 core/migrations/__init__.py                |  0
 core/models.py                             | 65 +++++++++++++++++++
 core/tests.py                              |  3 +
 core/views.py                              |  4 ++
 grady/settings.py                          |  1 +
 11 files changed, 211 insertions(+)
 create mode 100644 .editorconfig
 create mode 100644 core/__init__.py
 create mode 100644 core/admin.py
 create mode 100644 core/apps.py
 create mode 100644 core/migrations/0001_initial.py
 create mode 100644 core/migrations/0002_auto_20170303_1837.py
 create mode 100644 core/migrations/__init__.py
 create mode 100644 core/models.py
 create mode 100644 core/tests.py
 create mode 100644 core/views.py

diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 00000000..0ec61d48
--- /dev/null
+++ b/.editorconfig
@@ -0,0 +1,24 @@
+
+# top-most EditorConfig file
+root = true
+
+# Unix-style newlines with a newline ending every file
+[*]
+end_of_line = lf
+insert_final_newline = true
+trim_trailing_whitespace = true
+
+# Python specific settigs
+[*.py]
+indent_style = space
+indent_size = 4
+charset = utf-8
+
+# Tab indentation (no size specified)
+[Makefile]
+indent_style = tab
+
+# Matches the exact files either package.json or .travis.yml
+[{package.json,.travis.yml}]
+indent_style = space
+indent_size = 2
diff --git a/core/__init__.py b/core/__init__.py
new file mode 100644
index 00000000..e69de29b
diff --git a/core/admin.py b/core/admin.py
new file mode 100644
index 00000000..78a851f3
--- /dev/null
+++ b/core/admin.py
@@ -0,0 +1,9 @@
+from django.contrib import admin
+from .models import SubmissionType, Feedback, Student, Submission
+
+# Register your models here.
+
+admin.site.register(SubmissionType)
+admin.site.register(Feedback)
+admin.site.register(Student)
+admin.site.register(Submission)
diff --git a/core/apps.py b/core/apps.py
new file mode 100644
index 00000000..26f78a8e
--- /dev/null
+++ b/core/apps.py
@@ -0,0 +1,5 @@
+from django.apps import AppConfig
+
+
+class CoreConfig(AppConfig):
+    name = 'core'
diff --git a/core/migrations/0001_initial.py b/core/migrations/0001_initial.py
new file mode 100644
index 00000000..84f7cc74
--- /dev/null
+++ b/core/migrations/0001_initial.py
@@ -0,0 +1,25 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.10.6 on 2017-03-03 15:39
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+    initial = True
+
+    dependencies = [
+    ]
+
+    operations = [
+        migrations.CreateModel(
+            name='SubmissionType',
+            fields=[
+                ('type_id', models.CharField(max_length=20, primary_key=True, serialize=False)),
+                ('name', models.CharField(max_length=50)),
+                ('correct_solution', models.TextField()),
+                ('correction_guideline', models.TextField()),
+            ],
+        ),
+    ]
diff --git a/core/migrations/0002_auto_20170303_1837.py b/core/migrations/0002_auto_20170303_1837.py
new file mode 100644
index 00000000..b7e565b9
--- /dev/null
+++ b/core/migrations/0002_auto_20170303_1837.py
@@ -0,0 +1,75 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.10.6 on 2017-03-03 18:37
+from __future__ import unicode_literals
+
+from django.conf import settings
+from django.db import migrations, models
+import django.db.models.deletion
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
+        ('core', '0001_initial'),
+    ]
+
+    operations = [
+        migrations.CreateModel(
+            name='Feedback',
+            fields=[
+                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
+                ('score', models.PositiveIntegerField(default=0)),
+                ('text', models.TextField()),
+                ('of_reviewer', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='reviewd_submissions', to=settings.AUTH_USER_MODEL)),
+            ],
+            options={
+                'verbose_name': 'Feedback',
+                'verbose_name_plural': 'Feedbacks',
+            },
+        ),
+        migrations.CreateModel(
+            name='Student',
+            fields=[
+                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
+                ('matrikel_no', models.PositiveIntegerField(default=0, unique=True)),
+                ('user', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
+            ],
+        ),
+        migrations.CreateModel(
+            name='Submission',
+            fields=[
+                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
+                ('pre_corrections', models.TextField()),
+                ('student', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to='core.Student')),
+            ],
+            options={
+                'verbose_name': 'Submission',
+                'verbose_name_plural': 'Submissions',
+            },
+        ),
+        migrations.AlterModelOptions(
+            name='submissiontype',
+            options={'verbose_name': 'SubmissionType', 'verbose_name_plural': 'SubmissionTypes'},
+        ),
+        migrations.AddField(
+            model_name='submissiontype',
+            name='full_score',
+            field=models.PositiveIntegerField(default=0),
+        ),
+        migrations.AddField(
+            model_name='submission',
+            name='submission_type',
+            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='submissions', to='core.SubmissionType'),
+        ),
+        migrations.AddField(
+            model_name='feedback',
+            name='of_submission',
+            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='core.Submission'),
+        ),
+        migrations.AddField(
+            model_name='feedback',
+            name='of_tutor',
+            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='corrected_submissions', to=settings.AUTH_USER_MODEL),
+        ),
+    ]
diff --git a/core/migrations/__init__.py b/core/migrations/__init__.py
new file mode 100644
index 00000000..e69de29b
diff --git a/core/models.py b/core/models.py
new file mode 100644
index 00000000..9fb8e884
--- /dev/null
+++ b/core/models.py
@@ -0,0 +1,65 @@
+from django.db import models
+from django.contrib.auth.models import User
+
+
+# Create your models here.
+
+class SubmissionType(models.Model):
+
+    # Fields
+    type_id = models.CharField(primary_key=True, max_length=20)
+    name = models.CharField(max_length=50)
+    full_score = models.PositiveIntegerField(default=0)
+    correct_solution = models.TextField()
+    correction_guideline = models.TextField()
+
+    class Meta:
+        verbose_name = "SubmissionType"
+        verbose_name_plural = "SubmissionTypes"
+
+    def __str__(self):
+        return self.name
+
+
+class Student(models.Model):
+    user = models.OneToOneField(User, on_delete=models.CASCADE)
+    matrikel_no = models.PositiveIntegerField(unique=True, default=0)
+
+    class Meta:
+        verbose_name = "Student"
+        verbose_name_plural = "Students"
+
+
+class Submission(models.Model):
+
+    # Fields
+    pre_corrections = models.TextField()
+    submission_type = models.ForeignKey(SubmissionType, related_name='submissions')
+    student = models.OneToOneField(Student)
+
+    class Meta:
+        verbose_name = "Submission"
+        verbose_name_plural = "Submissions"
+
+    def __str__(self):
+        pass
+
+
+class Feedback(models.Model):
+
+    # fields
+    score = models.PositiveIntegerField(default=0)
+    text = models.TextField()
+    of_submission = models.ForeignKey(Submission)
+    of_tutor = models.ForeignKey(User, related_name='corrected_submissions')
+    of_reviewer = models.ForeignKey(User, related_name='reviewd_submissions')
+
+    class Meta:
+        verbose_name = "Feedback"
+        verbose_name_plural = "Feedback Set"
+
+    def __str__(self):
+        pass
+
+    def is_full_score(self):
+        return of_submission.full_score == score
diff --git a/core/tests.py b/core/tests.py
new file mode 100644
index 00000000..7ce503c2
--- /dev/null
+++ b/core/tests.py
@@ -0,0 +1,3 @@
+from django.test import TestCase
+
+# Create your tests here.
diff --git a/core/views.py b/core/views.py
new file mode 100644
index 00000000..27cdb63b
--- /dev/null
+++ b/core/views.py
@@ -0,0 +1,4 @@
+from django.shortcuts import render
+
+# Create your views here.
+
diff --git a/grady/settings.py b/grady/settings.py
index 571600e8..552b307e 100644
--- a/grady/settings.py
+++ b/grady/settings.py
@@ -37,6 +37,7 @@ INSTALLED_APPS = [
     'django.contrib.sessions',
     'django.contrib.messages',
     'django.contrib.staticfiles',
+    'core',
 ]
 
 MIDDLEWARE = [
-- 
GitLab