Added request tracker support as a 'reference_number' field in the report model.

This commit is contained in:
kououken 2019-03-01 12:26:43 -08:00
parent 9658afda32
commit c94bede4be
6 changed files with 37 additions and 3 deletions

View file

@ -0,0 +1,18 @@
# Generated by Django 2.1.7 on 2019-03-01 20:17
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('backend', '0008_auto_20190214_1421'),
]
operations = [
migrations.AddField(
model_name='report',
name='reference_number',
field=models.CharField(default='', max_length=32),
),
]

View file

@ -13,6 +13,7 @@ class Report(models.Model):
date_created = models.DateTimeField('date created', default=datetime.date.today)
date_submitted = models.DateTimeField('date submitted', default=datetime.date.today)
submitted = models.BooleanField(default=False)
reference_number = models.CharField(max_length=32, default='')
def __str__(self):
"""

View file

@ -4,6 +4,7 @@
</head>
<body>
<h1>Title: {{ title }}</h1>
<p>Reference #: {{ reference_number }}</p>
{% for section in sections %}
{% if section.completed %}
<h2>{{section.title}}</h2>

View file

@ -4,6 +4,7 @@
***
Title: {{title}}
Reference #: {{reference_number}}
{% for section in sections %}
{{section.title}}
{% for field in section.fields %}

View file

@ -23,6 +23,7 @@ def get_report(report_pk):
"date_created": i.date_created,
"submitted": i.submitted,
"date_submitted": i.date_submitted,
"reference_number": i.reference_number,
}
# append the sections for each report
data.update(get_sections(i.id))
@ -120,9 +121,20 @@ def report(request):
"title": "Report Title Here"
}
"""
# Create the report
report = Report.objects.create(user_id=request.user, title=request.data['title'],
date_created=datetime.date.today())
# Create the report, with reference number if available
if 'reference_number' in request.data:
report = Report.objects.create(
user_id=request.user,
title=request.data['title'],
date_created=datetime.date.today(),
reference_number=request.data['reference_number']
)
else:
report = Report.objects.create(
user_id=request.user,
title=request.data['title'],
date_created=datetime.date.today()
)
report.save()
# Create the sections
@ -161,6 +173,7 @@ def reports(request):
"date_created": i.date_created,
"submitted": i.submitted,
"date_submitted": i.date_submitted,
"reference_number": i.reference_number,
}
# append the sections for each report
report_set["reports"].append(data.copy())

Binary file not shown.