|
|
|
@ -1,4 +1,3 @@ |
|
|
|
from django.contrib.auth.models import User |
|
|
|
from django.contrib import admin |
|
|
|
from django.db import models |
|
|
|
from django.utils import timezone |
|
|
|
@ -61,60 +60,6 @@ class Question(models.Model): |
|
|
|
return '%s: %s' % (self.key, self.name) |
|
|
|
|
|
|
|
|
|
|
|
@python_2_unicode_compatible |
|
|
|
class LegalForm(models.Model): |
|
|
|
""" |
|
|
|
A defined legal filing composed of a template and mapped response values |
|
|
|
""" |
|
|
|
|
|
|
|
key = models.TextField(primary_key=True) |
|
|
|
""" Form ID (e.g., 'f1') """ |
|
|
|
|
|
|
|
name = models.TextField() |
|
|
|
""" Full name of form (e.g., 'Notice of Joint Family Claim') """ |
|
|
|
|
|
|
|
questions = models.ManyToManyField(Question, through='FormQuestions') |
|
|
|
""" Responses needed to complete the form, mapped through the question """ |
|
|
|
|
|
|
|
order = models.PositiveIntegerField(default=0) |
|
|
|
""" Convenience for listing these in the admin """ |
|
|
|
|
|
|
|
class Meta: |
|
|
|
verbose_name_plural = 'Legal Forms' |
|
|
|
ordering = ('order', ) |
|
|
|
|
|
|
|
def __str__(self): |
|
|
|
return '%s: %s' % (str(self.key).upper(), self.name) |
|
|
|
|
|
|
|
|
|
|
|
@python_2_unicode_compatible |
|
|
|
class FormQuestions(models.Model): |
|
|
|
""" |
|
|
|
Through class mapping questions to forms using their responses. |
|
|
|
|
|
|
|
This is an explicitly defined through model mainly to provide an opening |
|
|
|
for a transformational step on rendering per form. The presence of a |
|
|
|
mapping here is for including the user's data during template rendering, |
|
|
|
not to logically connect/require the question be present or used. |
|
|
|
""" |
|
|
|
|
|
|
|
legal_form = models.ForeignKey(LegalForm) |
|
|
|
""" The LegalForm """ |
|
|
|
|
|
|
|
question = models.ForeignKey(Question) |
|
|
|
""" The Question """ |
|
|
|
|
|
|
|
transformation = models.TextField() |
|
|
|
""" Transformations done on the value as part of rendering it in a form """ |
|
|
|
# placeholder for code or flags need to modified to fit into a form |
|
|
|
|
|
|
|
class Meta: |
|
|
|
verbose_name_plural = 'Form Questions' |
|
|
|
|
|
|
|
def __str__(self): |
|
|
|
return '%s -> %s' % (self.legal_form.key.upper(), self.question.key) |
|
|
|
|
|
|
|
|
|
|
|
@python_2_unicode_compatible |
|
|
|
class UserResponse(models.Model): |
|
|
|
""" |
|
|
|
@ -139,6 +84,4 @@ class UserResponse(models.Model): |
|
|
|
|
|
|
|
admin.site.register(BceidUser) |
|
|
|
admin.site.register(Question) |
|
|
|
admin.site.register(LegalForm) |
|
|
|
admin.site.register(UserResponse) |
|
|
|
admin.site.register(FormQuestions) |