diff --git a/opentech/apply/determinations/__init__.py b/opentech/apply/determinations/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/opentech/apply/determinations/apps.py b/opentech/apply/determinations/apps.py new file mode 100644 index 0000000000000000000000000000000000000000..996b2a5ef3009d9399ab03399fb939758a4c69ee --- /dev/null +++ b/opentech/apply/determinations/apps.py @@ -0,0 +1,5 @@ +from django.apps import AppConfig + + +class DeterminationsConfig(AppConfig): + name = 'Determinations' diff --git a/opentech/apply/determinations/migrations/0001_initial.py b/opentech/apply/determinations/migrations/0001_initial.py new file mode 100644 index 0000000000000000000000000000000000000000..4729c5a3eec62b6af269cea09c3560fd1b7f37e0 --- /dev/null +++ b/opentech/apply/determinations/migrations/0001_initial.py @@ -0,0 +1,34 @@ +# Generated by Django 2.0.2 on 2018-06-13 15:23 + +from django.conf import settings +import django.contrib.postgres.fields.jsonb +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + migrations.swappable_dependency(settings.AUTH_USER_MODEL), + ('funds', '0032_make_reviewers_optional_in_all_instances'), + ] + + operations = [ + migrations.CreateModel( + name='Determination', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('determination_data', django.contrib.postgres.fields.jsonb.JSONField()), + ('determination', models.IntegerField(choices=[(0, 'Unapproved'), (1, 'Undetermined'), (2, 'Approved')], default=0, verbose_name='Determination')), + ('is_draft', models.BooleanField(default=False, verbose_name='Draft')), + ('author', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to=settings.AUTH_USER_MODEL)), + ('submission', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name='determination', to='funds.ApplicationSubmission')), + ], + ), + migrations.AlterUniqueTogether( + name='determination', + unique_together={('author', 'submission')}, + ), + ] diff --git a/opentech/apply/determinations/migrations/__init__.py b/opentech/apply/determinations/migrations/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/opentech/apply/determinations/models.py b/opentech/apply/determinations/models.py new file mode 100644 index 0000000000000000000000000000000000000000..2f2379bff59ea2e2de7dabc6c4e20eb3f65c2ec7 --- /dev/null +++ b/opentech/apply/determinations/models.py @@ -0,0 +1,38 @@ +from django.conf import settings +from django.contrib.postgres.fields import JSONField +from django.db import models + + +UNAPPROVED = 0 +UNDETERMINED = 1 +APPROVED = 2 + +DETERMINATION_CHOICES = ( + (UNAPPROVED, 'Unapproved'), + (UNDETERMINED, 'Undetermined'), + (APPROVED, 'Approved'), +) + + +class Determination(models.Model): + submission = models.OneToOneField( + 'funds.ApplicationSubmission', + on_delete=models.CASCADE, + related_name='determination' + ) + author = models.ForeignKey( + settings.AUTH_USER_MODEL, + on_delete=models.PROTECT, + ) + determination_data = JSONField() + determination = models.IntegerField(verbose_name="Determination", choices=DETERMINATION_CHOICES, default=0) + is_draft = models.BooleanField(default=False, verbose_name="Draft") + + class Meta: + unique_together = ('author', 'submission') + + def __str__(self): + return f'Determination for {self.submission.title} by {self.author!s}' + + def __repr__(self): + return f'<{self.__class__.__name__}: {str(self.determination_responses)}>' diff --git a/opentech/settings/base.py b/opentech/settings/base.py index df8289a9007cb67325288b6279f250b0fe1cd8cb..7dae6e7776aa76cde3fe3e50ad867e9beb8c50a8 100644 --- a/opentech/settings/base.py +++ b/opentech/settings/base.py @@ -21,6 +21,7 @@ INSTALLED_APPS = [ 'opentech.apply.home', 'opentech.apply.users', 'opentech.apply.review', + 'opentech.apply.determinations', 'opentech.apply.stream_forms', 'opentech.public.esi',