diff --git a/src/account/auth_pipeline.py b/src/account/auth_pipeline.py index abd99b924b4e7a62570c3eea830e64c87660bb9c..1e9d01f081c694642564ec7ac9088553b6343535 100644 --- a/src/account/auth_pipeline.py +++ b/src/account/auth_pipeline.py @@ -1,4 +1,5 @@ from django.core import exceptions +from django.http import HttpResponseServerError from . import models @@ -8,4 +9,4 @@ def create_profile(backend, user, response, *args, **kwargs): try: user.profile except exceptions.ObjectDoesNotExist: - models.Profile.objects.create(user=user, ) + models.Profile.objects.create(user=user) diff --git a/src/account/migrations/0001_initial.py b/src/account/migrations/0001_initial.py index 37a8b78b7801665d27a394de0fc81c290fde193a..a77bc00588b40f9aa42a745e464613a61758b59e 100644 --- a/src/account/migrations/0001_initial.py +++ b/src/account/migrations/0001_initial.py @@ -1,4 +1,4 @@ -# Generated by Django 2.0.1 on 2018-12-24 16:02 +# Generated by Django 2.0.1 on 2019-01-17 11:27 from django.conf import settings from django.db import migrations, models @@ -42,7 +42,8 @@ class Migration(migrations.Migration): ('motivation_exercise', models.TextField(blank=True, default='')), ('nick', models.CharField(blank=True, default='', max_length=15)), ('signed', models.BooleanField(default=False)), - ('groups', models.ManyToManyField(related_name='profiles', to='account.GroupChoice')), + ('role', models.CharField(choices=[('Staff', 'Staff'), ('Applicant', 'Applicant'), ('Student', 'Student')], default='Applicant', max_length=10)), + ('groups', models.ManyToManyField(blank=True, related_name='profiles', to='account.GroupChoice')), ('user', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name='profile', to=settings.AUTH_USER_MODEL)), ], ), diff --git a/src/account/migrations/0002_profile_role.py b/src/account/migrations/0002_profile_role.py deleted file mode 100644 index 77f8eb7d1784cc27dcd4318538a706de4462fc80..0000000000000000000000000000000000000000 --- a/src/account/migrations/0002_profile_role.py +++ /dev/null @@ -1,18 +0,0 @@ -# Generated by Django 2.0.1 on 2019-01-05 18:22 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('account', '0001_initial'), - ] - - operations = [ - migrations.AddField( - model_name='profile', - name='role', - field=models.CharField(choices=[('Staff', 'Staff'), ('Applicant', 'Applicant'), ('Student', 'Student')], default='Applicant', max_length=10, unique=True), - ), - ] diff --git a/src/account/migrations/0003_auto_20190106_1846.py b/src/account/migrations/0003_auto_20190106_1846.py deleted file mode 100644 index 8c4f05b384b49fdbfcdf90f2554089267f290912..0000000000000000000000000000000000000000 --- a/src/account/migrations/0003_auto_20190106_1846.py +++ /dev/null @@ -1,26 +0,0 @@ -# Generated by Django 2.0.1 on 2019-01-06 17:46 - -import common.middleware -from django.conf import settings -from django.db import migrations, models -import django.db.models.deletion - - -class Migration(migrations.Migration): - - dependencies = [ - ('account', '0002_profile_role'), - ] - - operations = [ - migrations.AlterField( - model_name='profile', - name='role', - field=models.CharField(choices=[('Staff', 'Staff'), ('Applicant', 'Applicant'), ('Student', 'Student')], default='Applicant', max_length=10), - ), - migrations.AlterField( - model_name='profile', - name='user', - field=models.OneToOneField(default=common.middleware.CurrentUserMiddleware.get_current_user, on_delete=django.db.models.deletion.CASCADE, related_name='profile', to=settings.AUTH_USER_MODEL), - ), - ] diff --git a/src/account/migrations/0004_auto_20190107_2218.py b/src/account/migrations/0004_auto_20190107_2218.py deleted file mode 100644 index b4ab1f0dea6c2ea83c188c6e91161552ae9e822c..0000000000000000000000000000000000000000 --- a/src/account/migrations/0004_auto_20190107_2218.py +++ /dev/null @@ -1,20 +0,0 @@ -# Generated by Django 2.0.1 on 2019-01-07 21:18 - -from django.conf import settings -from django.db import migrations, models -import django.db.models.deletion - - -class Migration(migrations.Migration): - - dependencies = [ - ('account', '0003_auto_20190106_1846'), - ] - - operations = [ - migrations.AlterField( - model_name='profile', - name='user', - field=models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name='profile', to=settings.AUTH_USER_MODEL), - ), - ] diff --git a/src/account/models.py b/src/account/models.py index 66cbf6c9679fd8a191d4a9e57d4303ad90d5d141..b8188f304cce32d6c8577739e1cf6aa1656efab8 100644 --- a/src/account/models.py +++ b/src/account/models.py @@ -3,6 +3,7 @@ from django.contrib.auth.models import User from solo.models import SingletonModel from common.middleware import CurrentUserMiddleware + class GroupChoice(models.Model): TEAMS = ( ('DT', 'DevTeam'), @@ -37,8 +38,8 @@ class Profile(models.Model): motivation_exercise = models.TextField(blank=True, default='') nick = models.CharField(max_length=15, blank=True, default='') signed = models.BooleanField(default=False, null=False) - groups = models.ManyToManyField(GroupChoice, related_name='profiles') - role = models.CharField(max_length=10, choices=ROLES, default='Applicant',) + groups = models.ManyToManyField(GroupChoice, related_name='profiles', blank=True) + role = models.CharField(max_length=10, choices=ROLES, default='Applicant') @property def full_name(self): diff --git a/src/document/migrations/0001_initial.py b/src/document/migrations/0001_initial.py index bbb87de9002518621184d2c0d6a17bc6863f861f..d66e3a5867b65bca64765059d994d3f68a438139 100644 --- a/src/document/migrations/0001_initial.py +++ b/src/document/migrations/0001_initial.py @@ -1,4 +1,4 @@ -# Generated by Django 2.0.1 on 2019-01-04 19:59 +# Generated by Django 2.0.1 on 2019-01-17 11:27 import common.validators import django.core.validators @@ -12,6 +12,7 @@ class Migration(migrations.Migration): dependencies = [ ('account', '0001_initial'), + ('homework', '0001_initial'), ] operations = [ @@ -21,8 +22,9 @@ class Migration(migrations.Migration): ('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()), - ('files', models.FileField(upload_to='', validators=[django.core.validators.FileExtensionValidator(['png', 'jpeg', 'jpg', 'zip']), common.validators.FileSizeValidator(size_limit=52428800)])), + ('description', models.TextField(blank=True, default='')), + ('file', models.FileField(upload_to='', validators=[django.core.validators.FileExtensionValidator(['png', 'jpeg', 'jpg', 'zip']), common.validators.FileSizeValidator(size_limit=52428800)])), + ('solution', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.DO_NOTHING, related_name='files', to='homework.Solution')), ('uploaded_by', models.ForeignKey(on_delete=django.db.models.deletion.DO_NOTHING, to='account.Profile')), ], ), diff --git a/src/document/migrations/0002_auto_20190113_1239.py b/src/document/migrations/0002_auto_20190113_1239.py deleted file mode 100644 index 59c9ba8dcb78053ee81c265b4aa827a0f0257132..0000000000000000000000000000000000000000 --- a/src/document/migrations/0002_auto_20190113_1239.py +++ /dev/null @@ -1,18 +0,0 @@ -# Generated by Django 2.0.1 on 2019-01-13 11:39 - -from django.db import migrations - - -class Migration(migrations.Migration): - - dependencies = [ - ('document', '0001_initial'), - ] - - operations = [ - migrations.RenameField( - model_name='document', - old_name='files', - new_name='file', - ), - ] diff --git a/src/document/migrations/0003_document_solution.py b/src/document/migrations/0003_document_solution.py deleted file mode 100644 index fef922a0e5a9e42fe1562f1d05fccb5c7904e75a..0000000000000000000000000000000000000000 --- a/src/document/migrations/0003_document_solution.py +++ /dev/null @@ -1,20 +0,0 @@ -# Generated by Django 2.0.1 on 2019-01-13 11:41 - -from django.db import migrations, models -import django.db.models.deletion - - -class Migration(migrations.Migration): - - dependencies = [ - ('homework', '0003_auto_20190113_1239'), - ('document', '0002_auto_20190113_1239'), - ] - - operations = [ - migrations.AddField( - model_name='document', - name='solution', - field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.DO_NOTHING, related_name='files', to='homework.Solution'), - ), - ] diff --git a/src/document/migrations/0004_auto_20190114_2016.py b/src/document/migrations/0004_auto_20190114_2016.py deleted file mode 100644 index fa317eeedd01b653bac85982709bf5bcf3e49d34..0000000000000000000000000000000000000000 --- a/src/document/migrations/0004_auto_20190114_2016.py +++ /dev/null @@ -1,18 +0,0 @@ -# Generated by Django 2.0.1 on 2019-01-14 19:16 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('document', '0003_document_solution'), - ] - - operations = [ - migrations.AlterField( - model_name='document', - name='description', - field=models.TextField(blank=True, default=''), - ), - ] diff --git a/src/document/models.py b/src/document/models.py index 862ec5e032b116db9e0476a1026c9a621b5c1148..3401e64aeb507e9f452e4a8733b4a1199cef9cbe 100644 --- a/src/document/models.py +++ b/src/document/models.py @@ -10,7 +10,7 @@ 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(blank=True, default='', ) + description = models.TextField(blank=True, default='') file = models.FileField( validators=[ validators.FileExtensionValidator([ @@ -20,9 +20,9 @@ class Document(models.Model): 'zip', ]), FileSizeValidator(size_limit=52428800), # 52428800 - 50MiB - ], + ] ) - solution = models.ForeignKey(Solution, related_name='files', on_delete=models.DO_NOTHING, blank=True, null=True,) + solution = models.ForeignKey(Solution, related_name='files', on_delete=models.DO_NOTHING, blank=True, null=True) def __str__(self): return self.name diff --git a/src/homework/migrations/0001_initial.py b/src/homework/migrations/0001_initial.py index 601da871836d6dc8ff1ad8b3cd92e0f2edb094ac..c4e232284bc7f5a37da9ccb6dd6991d4f709c1a0 100644 --- a/src/homework/migrations/0001_initial.py +++ b/src/homework/migrations/0001_initial.py @@ -1,7 +1,6 @@ -# Generated by Django 2.0.1 on 2019-01-04 19:59 +# Generated by Django 2.0.1 on 2019-01-17 11:27 -import common.validators -import django.core.validators +import common.middleware from django.db import migrations, models import django.db.models.deletion @@ -21,11 +20,10 @@ class Migration(migrations.Migration): ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('created_at', models.DateTimeField(auto_now_add=True)), ('updated_at', models.DateTimeField(auto_now=True)), - ('note', models.TextField()), + ('note', models.TextField(blank=True, default='')), ('accepted', models.BooleanField()), ('corrected', models.BooleanField()), - ('files', models.FileField(upload_to='', validators=[django.core.validators.FileExtensionValidator(['png', 'jpeg', 'jpg', 'zip']), common.validators.FileSizeValidator(size_limit=52428800)])), - ('created_by', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='student_solution', to='account.Profile')), + ('created_by', models.ForeignKey(default=common.middleware.CurrentUserMiddleware.get_current_user_profile, on_delete=django.db.models.deletion.DO_NOTHING, related_name='solution', to='account.Profile')), ], ), migrations.CreateModel( @@ -37,12 +35,12 @@ class Migration(migrations.Migration): ('title', models.CharField(max_length=150)), ('text', models.TextField()), ('deadline', models.DateTimeField()), - ('created_by', models.ForeignKey(on_delete=django.db.models.deletion.DO_NOTHING, to='account.Profile')), + ('created_by', models.ForeignKey(default=common.middleware.CurrentUserMiddleware.get_current_user_profile, on_delete=django.db.models.deletion.DO_NOTHING, related_name='tasks', to='account.Profile')), ], ), migrations.AddField( model_name='solution', name='task', - field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='task_solution', to='homework.Task'), + field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='solutions', to='homework.Task'), ), ] diff --git a/src/homework/migrations/0002_auto_20190105_1922.py b/src/homework/migrations/0002_auto_20190105_1922.py deleted file mode 100644 index 9f4e7663b40f4c198a6145bfdb2a55a442e36f1f..0000000000000000000000000000000000000000 --- a/src/homework/migrations/0002_auto_20190105_1922.py +++ /dev/null @@ -1,19 +0,0 @@ -# Generated by Django 2.0.1 on 2019-01-05 18:22 - -from django.db import migrations, models -import django.db.models.deletion - - -class Migration(migrations.Migration): - - dependencies = [ - ('homework', '0001_initial'), - ] - - operations = [ - migrations.AlterField( - model_name='solution', - name='created_by', - field=models.ForeignKey(on_delete=django.db.models.deletion.DO_NOTHING, related_name='student_solution', to='account.Profile'), - ), - ] diff --git a/src/homework/migrations/0003_auto_20190113_1239.py b/src/homework/migrations/0003_auto_20190113_1239.py deleted file mode 100644 index e06f6b326d17fc96b3174b5448bbe8dbde250940..0000000000000000000000000000000000000000 --- a/src/homework/migrations/0003_auto_20190113_1239.py +++ /dev/null @@ -1,28 +0,0 @@ -# Generated by Django 2.0.1 on 2019-01-13 11:39 - -from django.db import migrations, models -import django.db.models.deletion - - -class Migration(migrations.Migration): - - dependencies = [ - ('homework', '0002_auto_20190105_1922'), - ] - - operations = [ - migrations.RemoveField( - model_name='solution', - name='files', - ), - migrations.AlterField( - model_name='solution', - name='created_by', - field=models.ForeignKey(on_delete=django.db.models.deletion.DO_NOTHING, related_name='solution', to='account.Profile'), - ), - migrations.AlterField( - model_name='solution', - name='task', - field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='solution', to='homework.Task'), - ), - ] diff --git a/src/homework/migrations/0004_auto_20190114_1641.py b/src/homework/migrations/0004_auto_20190114_1641.py deleted file mode 100644 index a8c1133e37545849ab15d91ed7b97957d4dcb334..0000000000000000000000000000000000000000 --- a/src/homework/migrations/0004_auto_20190114_1641.py +++ /dev/null @@ -1,20 +0,0 @@ -# Generated by Django 2.0.1 on 2019-01-14 15:41 - -import common.middleware -from django.db import migrations, models -import django.db.models.deletion - - -class Migration(migrations.Migration): - - dependencies = [ - ('homework', '0003_auto_20190113_1239'), - ] - - operations = [ - migrations.AlterField( - model_name='solution', - name='created_by', - field=models.ForeignKey(default=common.middleware.CurrentUserMiddleware.get_current_user_profile, on_delete=django.db.models.deletion.DO_NOTHING, related_name='solution', to='account.Profile'), - ), - ] diff --git a/src/homework/migrations/0005_auto_20190114_1658.py b/src/homework/migrations/0005_auto_20190114_1658.py deleted file mode 100644 index 720bbc23297729f88824b0fe99a5385a3ad55ac7..0000000000000000000000000000000000000000 --- a/src/homework/migrations/0005_auto_20190114_1658.py +++ /dev/null @@ -1,25 +0,0 @@ -# Generated by Django 2.0.1 on 2019-01-14 15:58 - -import common.middleware -from django.db import migrations, models -import django.db.models.deletion - - -class Migration(migrations.Migration): - - dependencies = [ - ('homework', '0004_auto_20190114_1641'), - ] - - operations = [ - migrations.AlterField( - model_name='solution', - name='task', - field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='solutions', to='homework.Task'), - ), - migrations.AlterField( - model_name='task', - name='created_by', - field=models.ForeignKey(default=common.middleware.CurrentUserMiddleware.get_current_user_profile, on_delete=django.db.models.deletion.DO_NOTHING, related_name='tasks', to='account.Profile'), - ), - ] diff --git a/src/homework/migrations/0006_auto_20190114_1938.py b/src/homework/migrations/0006_auto_20190114_1938.py deleted file mode 100644 index 02e23165017fa0dc5efac9723039b79eec37fdbd..0000000000000000000000000000000000000000 --- a/src/homework/migrations/0006_auto_20190114_1938.py +++ /dev/null @@ -1,18 +0,0 @@ -# Generated by Django 2.0.1 on 2019-01-14 18:38 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('homework', '0005_auto_20190114_1658'), - ] - - operations = [ - migrations.AlterField( - model_name='solution', - name='note', - field=models.TextField(blank=True, default=''), - ), - ] diff --git a/src/homework/models.py b/src/homework/models.py index 6e1147c2d884cf168ce188edbd9513cccc7a8bad..692686e627bb1ace011332e3766640a9d211d170 100755 --- a/src/homework/models.py +++ b/src/homework/models.py @@ -26,11 +26,11 @@ class Solution(models.Model): Profile, related_name='solution', on_delete=models.DO_NOTHING, - default=CurrentUserMiddleware.get_current_user_profile, + default=CurrentUserMiddleware.get_current_user_profile ) - created_at = models.DateTimeField(auto_now_add=True, editable=False,) - updated_at = models.DateTimeField(auto_now=True, editable=False,) - note = models.TextField(blank=True, default='',) + created_at = models.DateTimeField(auto_now_add=True, editable=False) + updated_at = models.DateTimeField(auto_now=True, editable=False) + note = models.TextField(blank=True, default='') accepted = models.BooleanField() corrected = models.BooleanField() diff --git a/src/homework/serializers.py b/src/homework/serializers.py index 0e5191f3c29fbfe25271b0762fe26fa02adeb00d..cb9ff5b9cf25f98a28c6121f2a3df35799822d15 100755 --- a/src/homework/serializers.py +++ b/src/homework/serializers.py @@ -1,7 +1,6 @@ from rest_framework import serializers from django.utils import timezone -from common.serializers import CurrentUserProfileDefault from . import models from common.middleware import CurrentUserMiddleware diff --git a/src/news/migrations/0001_initial.py b/src/news/migrations/0001_initial.py index fb3427740244597c278ef123918a83fa0a0b21ec..1d8f82e338f75404ac0ebd0df5121ab8a1f98a8f 100644 --- a/src/news/migrations/0001_initial.py +++ b/src/news/migrations/0001_initial.py @@ -1,5 +1,6 @@ -# Generated by Django 2.0.1 on 2018-12-24 16:02 +# Generated by Django 2.0.1 on 2019-01-17 11:27 +import common.middleware from django.db import migrations, models import django.db.models.deletion @@ -21,7 +22,7 @@ class Migration(migrations.Migration): ('text', models.TextField()), ('created_at', models.DateTimeField(auto_now_add=True)), ('updated_at', models.DateTimeField(auto_now=True)), - ('author', models.ForeignKey(on_delete=django.db.models.deletion.DO_NOTHING, related_name='author', to='account.Profile')), + ('author', models.ForeignKey(default=common.middleware.CurrentUserMiddleware.get_current_user_profile, on_delete=django.db.models.deletion.DO_NOTHING, related_name='author', to='account.Profile')), ('updated_by', models.ForeignKey(on_delete=django.db.models.deletion.DO_NOTHING, related_name='updater', to='account.Profile')), ], ), diff --git a/src/news/migrations/0002_auto_20181229_2019.py b/src/news/migrations/0002_auto_20181229_2019.py deleted file mode 100644 index 07d22c2d508deb673d4c75b1ab6eef8c977262b1..0000000000000000000000000000000000000000 --- a/src/news/migrations/0002_auto_20181229_2019.py +++ /dev/null @@ -1,20 +0,0 @@ -# Generated by Django 2.0.1 on 2018-12-29 19:19 - -import common.middleware -from django.db import migrations, models -import django.db.models.deletion - - -class Migration(migrations.Migration): - - dependencies = [ - ('news', '0001_initial'), - ] - - operations = [ - migrations.AlterField( - model_name='article', - name='author', - field=models.ForeignKey(default=common.middleware.CurrentUserMiddleware.get_current_user_profile, on_delete=django.db.models.deletion.DO_NOTHING, related_name='author', to='account.Profile'), - ), - ] diff --git a/src/news/models.py b/src/news/models.py index d405a078ec5167c34bb7d72df005e35916059566..c216221410bc8e9f04f3b76c90265ed94191b9d6 100644 --- a/src/news/models.py +++ b/src/news/models.py @@ -8,7 +8,7 @@ class Article(models.Model): Profile, related_name="author", on_delete=models.DO_NOTHING, - default=CurrentUserMiddleware.get_current_user_profile, + default=CurrentUserMiddleware.get_current_user_profile ) title = models.CharField(null=False, max_length=200) text = models.TextField() @@ -17,7 +17,7 @@ class Article(models.Model): updated_by = models.ForeignKey( Profile, related_name="updater", - on_delete=models.DO_NOTHING, + on_delete=models.DO_NOTHING ) def __str__(self): diff --git a/src/stats/migrations/0001_initial.py b/src/stats/migrations/0001_initial.py index 1464e8c4d274f2d082373f47fac63a1ef48b5db9..8595f0c7c9a44dc60ed746bfdb264cc14bd075ca 100644 --- a/src/stats/migrations/0001_initial.py +++ b/src/stats/migrations/0001_initial.py @@ -1,5 +1,6 @@ -# Generated by Django 2.0.1 on 2019-01-07 21:18 +# Generated by Django 2.0.1 on 2019-01-17 11:27 +import common.middleware from django.db import migrations, models import django.db.models.deletion @@ -9,7 +10,7 @@ class Migration(migrations.Migration): initial = True dependencies = [ - ('account', '0004_auto_20190107_2218'), + ('account', '0001_initial'), ] operations = [ @@ -21,8 +22,8 @@ class Migration(migrations.Migration): ('date', models.DateTimeField()), ('created_at', models.DateTimeField(auto_now_add=True)), ('updated_at', models.DateTimeField(auto_now=True)), - ('created_by', models.ForeignKey(on_delete=django.db.models.deletion.DO_NOTHING, related_name='created_event', to='account.Profile')), - ('visitors', models.ManyToManyField(related_name='visitor', to='account.Profile')), + ('created_by', models.ForeignKey(default=common.middleware.CurrentUserMiddleware.get_current_user_profile, on_delete=django.db.models.deletion.DO_NOTHING, related_name='created_event', to='account.Profile')), + ('visitors', models.ManyToManyField(blank=True, related_name='events', to='account.Profile')), ], ), migrations.CreateModel( @@ -32,7 +33,7 @@ class Migration(migrations.Migration): ('note', models.TextField()), ('created_at', models.DateTimeField(auto_now_add=True)), ('updated_at', models.DateTimeField(auto_now=True)), - ('created_by', models.ForeignKey(on_delete=django.db.models.deletion.DO_NOTHING, related_name='created_notes', to='account.Profile')), + ('created_by', models.ForeignKey(default=common.middleware.CurrentUserMiddleware.get_current_user_profile, on_delete=django.db.models.deletion.DO_NOTHING, related_name='created_notes', to='account.Profile')), ('event', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='notes', to='stats.Event')), ('profile', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='notes', to='account.Profile')), ], diff --git a/src/stats/migrations/0002_auto_20190107_2220.py b/src/stats/migrations/0002_auto_20190107_2220.py deleted file mode 100644 index e088f2dfb28b840e16f6f3584ec4a5c881bce1f7..0000000000000000000000000000000000000000 --- a/src/stats/migrations/0002_auto_20190107_2220.py +++ /dev/null @@ -1,24 +0,0 @@ -# Generated by Django 2.0.1 on 2019-01-07 21:20 - -from django.db import migrations, models -import django.db.models.deletion - - -class Migration(migrations.Migration): - - dependencies = [ - ('stats', '0001_initial'), - ] - - operations = [ - migrations.AlterField( - model_name='note', - name='event', - field=models.ForeignKey(blank=True, default='', on_delete=django.db.models.deletion.CASCADE, related_name='notes', to='stats.Event'), - ), - migrations.AlterField( - model_name='note', - name='profile', - field=models.ForeignKey(blank=True, default='', on_delete=django.db.models.deletion.CASCADE, related_name='notes', to='account.Profile'), - ), - ] diff --git a/src/stats/migrations/0003_auto_20190107_2224.py b/src/stats/migrations/0003_auto_20190107_2224.py deleted file mode 100644 index dc96481d82ae7579977886df0d422a12d26ee01a..0000000000000000000000000000000000000000 --- a/src/stats/migrations/0003_auto_20190107_2224.py +++ /dev/null @@ -1,24 +0,0 @@ -# Generated by Django 2.0.1 on 2019-01-07 21:24 - -from django.db import migrations, models -import django.db.models.deletion - - -class Migration(migrations.Migration): - - dependencies = [ - ('stats', '0002_auto_20190107_2220'), - ] - - operations = [ - migrations.AlterField( - model_name='note', - name='event', - field=models.ForeignKey(blank=True, default='', null=True, on_delete=django.db.models.deletion.CASCADE, related_name='notes', to='stats.Event'), - ), - migrations.AlterField( - model_name='note', - name='profile', - field=models.ForeignKey(blank=True, default='', null=True, on_delete=django.db.models.deletion.CASCADE, related_name='notes', to='account.Profile'), - ), - ] diff --git a/src/stats/migrations/0004_auto_20190113_1239.py b/src/stats/migrations/0004_auto_20190113_1239.py deleted file mode 100644 index c6d5a7810b77f984ed4d6883193af9cab6b2f13f..0000000000000000000000000000000000000000 --- a/src/stats/migrations/0004_auto_20190113_1239.py +++ /dev/null @@ -1,24 +0,0 @@ -# Generated by Django 2.0.1 on 2019-01-13 11:39 - -from django.db import migrations, models -import django.db.models.deletion - - -class Migration(migrations.Migration): - - dependencies = [ - ('stats', '0003_auto_20190107_2224'), - ] - - operations = [ - migrations.AlterField( - model_name='note', - name='event', - field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='notes', to='stats.Event'), - ), - migrations.AlterField( - model_name='note', - name='profile', - field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='notes', to='account.Profile'), - ), - ] diff --git a/src/stats/migrations/0005_auto_20190114_1713.py b/src/stats/migrations/0005_auto_20190114_1713.py deleted file mode 100644 index 769bc79bdb0a62afa792beb06a93b56603fe32f9..0000000000000000000000000000000000000000 --- a/src/stats/migrations/0005_auto_20190114_1713.py +++ /dev/null @@ -1,30 +0,0 @@ -# Generated by Django 2.0.1 on 2019-01-14 16:13 - -import common.middleware -from django.db import migrations, models -import django.db.models.deletion - - -class Migration(migrations.Migration): - - dependencies = [ - ('stats', '0004_auto_20190113_1239'), - ] - - operations = [ - migrations.AlterField( - model_name='event', - name='created_by', - field=models.ForeignKey(default=common.middleware.CurrentUserMiddleware.get_current_user_profile, on_delete=django.db.models.deletion.DO_NOTHING, related_name='created_event', to='account.Profile'), - ), - migrations.AlterField( - model_name='event', - name='visitors', - field=models.ManyToManyField(blank=True, null=True, related_name='events', to='account.Profile'), - ), - migrations.AlterField( - model_name='note', - name='created_by', - field=models.ForeignKey(default=common.middleware.CurrentUserMiddleware.get_current_user_profile, on_delete=django.db.models.deletion.DO_NOTHING, related_name='created_notes', to='account.Profile'), - ), - ] diff --git a/src/stats/migrations/0006_auto_20190114_1913.py b/src/stats/migrations/0006_auto_20190114_1913.py deleted file mode 100644 index 545336bafa2da40569687f026c7d855fc0abf877..0000000000000000000000000000000000000000 --- a/src/stats/migrations/0006_auto_20190114_1913.py +++ /dev/null @@ -1,18 +0,0 @@ -# Generated by Django 2.0.1 on 2019-01-14 18:13 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('stats', '0005_auto_20190114_1713'), - ] - - operations = [ - migrations.AlterField( - model_name='event', - name='visitors', - field=models.ManyToManyField(blank=True, related_name='events', to='account.Profile'), - ), - ] diff --git a/src/stats/models.py b/src/stats/models.py index ef56adf754430e076b05d9ba64be839da3934577..cf11e885fcad7924f8c9e396e7ba037977c86382 100644 --- a/src/stats/models.py +++ b/src/stats/models.py @@ -11,13 +11,13 @@ class Event(models.Model): visitors = models.ManyToManyField( Profile, related_name='events', - blank=True, + blank=True ) created_by = models.ForeignKey( Profile, related_name='created_event', on_delete=models.DO_NOTHING, - default=CurrentUserMiddleware.get_current_user_profile, + default=CurrentUserMiddleware.get_current_user_profile ) created_at = models.DateTimeField(auto_now_add=True, editable=False) updated_at = models.DateTimeField(auto_now=True, editable=False) @@ -27,14 +27,14 @@ class Event(models.Model): class Note(models.Model): - event = models.ForeignKey(Event, related_name='notes', on_delete=models.CASCADE, blank=True, null=True,) - profile = models.ForeignKey(Profile, related_name='notes', on_delete=models.CASCADE, blank=True, null=True,) + event = models.ForeignKey(Event, related_name='notes', on_delete=models.CASCADE, blank=True, null=True) + profile = models.ForeignKey(Profile, related_name='notes', on_delete=models.CASCADE, blank=True, null=True) note = models.TextField() created_by = models.ForeignKey( Profile, related_name='created_notes', on_delete=models.DO_NOTHING, - default=CurrentUserMiddleware.get_current_user_profile, + default=CurrentUserMiddleware.get_current_user_profile ) created_at = models.DateTimeField(auto_now_add=True, editable=False) updated_at = models.DateTimeField(auto_now=True, editable=False)