Added request tracker support as a 'reference_number' field in the report model.
This commit is contained in:
parent
9658afda32
commit
c94bede4be
6 changed files with 37 additions and 3 deletions
18
back/backend/migrations/0009_report_reference_number.py
Normal file
18
back/backend/migrations/0009_report_reference_number.py
Normal 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),
|
||||||
|
),
|
||||||
|
]
|
|
@ -13,6 +13,7 @@ class Report(models.Model):
|
||||||
date_created = models.DateTimeField('date created', default=datetime.date.today)
|
date_created = models.DateTimeField('date created', default=datetime.date.today)
|
||||||
date_submitted = models.DateTimeField('date submitted', default=datetime.date.today)
|
date_submitted = models.DateTimeField('date submitted', default=datetime.date.today)
|
||||||
submitted = models.BooleanField(default=False)
|
submitted = models.BooleanField(default=False)
|
||||||
|
reference_number = models.CharField(max_length=32, default='')
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<h1>Title: {{ title }}</h1>
|
<h1>Title: {{ title }}</h1>
|
||||||
|
<p>Reference #: {{ reference_number }}</p>
|
||||||
{% for section in sections %}
|
{% for section in sections %}
|
||||||
{% if section.completed %}
|
{% if section.completed %}
|
||||||
<h2>{{section.title}}</h2>
|
<h2>{{section.title}}</h2>
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
***
|
***
|
||||||
|
|
||||||
Title: {{title}}
|
Title: {{title}}
|
||||||
|
Reference #: {{reference_number}}
|
||||||
{% for section in sections %}
|
{% for section in sections %}
|
||||||
{{section.title}}
|
{{section.title}}
|
||||||
{% for field in section.fields %}
|
{% for field in section.fields %}
|
||||||
|
|
|
@ -23,6 +23,7 @@ def get_report(report_pk):
|
||||||
"date_created": i.date_created,
|
"date_created": i.date_created,
|
||||||
"submitted": i.submitted,
|
"submitted": i.submitted,
|
||||||
"date_submitted": i.date_submitted,
|
"date_submitted": i.date_submitted,
|
||||||
|
"reference_number": i.reference_number,
|
||||||
}
|
}
|
||||||
# append the sections for each report
|
# append the sections for each report
|
||||||
data.update(get_sections(i.id))
|
data.update(get_sections(i.id))
|
||||||
|
@ -120,9 +121,20 @@ def report(request):
|
||||||
"title": "Report Title Here"
|
"title": "Report Title Here"
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
# Create the report
|
# Create the report, with reference number if available
|
||||||
report = Report.objects.create(user_id=request.user, title=request.data['title'],
|
if 'reference_number' in request.data:
|
||||||
date_created=datetime.date.today())
|
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()
|
report.save()
|
||||||
|
|
||||||
# Create the sections
|
# Create the sections
|
||||||
|
@ -161,6 +173,7 @@ def reports(request):
|
||||||
"date_created": i.date_created,
|
"date_created": i.date_created,
|
||||||
"submitted": i.submitted,
|
"submitted": i.submitted,
|
||||||
"date_submitted": i.date_submitted,
|
"date_submitted": i.date_submitted,
|
||||||
|
"reference_number": i.reference_number,
|
||||||
}
|
}
|
||||||
# append the sections for each report
|
# append the sections for each report
|
||||||
report_set["reports"].append(data.copy())
|
report_set["reports"].append(data.copy())
|
||||||
|
|
BIN
back/db.sqlite3
BIN
back/db.sqlite3
Binary file not shown.
Loading…
Reference in a new issue