Updated frontend to send reference number when creating report.

This commit is contained in:
kououken 2019-03-01 12:53:57 -08:00
parent c94bede4be
commit 4dee825973
6 changed files with 17 additions and 19 deletions

1
.gitignore vendored
View file

@ -2,6 +2,7 @@
# Edit at https://www.gitignore.io/?templates=linux,macos,python,django,windows,pycharm,intellij,visualstudio
### Django ###
*.env
*.log
*.pot
*.pyc

View file

@ -1,4 +1,4 @@
EMAIL_HOST_USER=accountemail@yourmail.com
EMAIL_HOST_PASSWORD=accountpasswordhere
SUBMIT_REPORT_DESTINATION_EMAIL=to-address@yourmail.com
EMAIL_HOST_USER=reimbursinator@gmail.com
EMAIL_HOST_PASSWORD=Frank12345
SUBMIT_REPORT_DESTINATION_EMAIL=kououken@gmail.com
SUBMIT_REPORT_FROM_EMAIL=from-address@yourmail.com

View file

@ -121,20 +121,13 @@ def report(request):
"title": "Report Title Here"
}
"""
# 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()
)
# Create the report
report = Report.objects.create(
user_id=request.user,
title=request.data['title'],
date_created=datetime.date.today(),
reference_number=request.data['reference']
)
report.save()
# Create the sections
@ -399,7 +392,7 @@ def send_report_to_admin(request, report_pk):
msg_html = render_to_string('backend/email.html', params)
msg_plain = render_to_string('backend/email.txt', params)
message = EmailMultiAlternatives(
"Reimbursinator - {}".format(params['title']),
"[RT - Request Tracker #{}] {}".format(params['reference_number'], params['title']),
msg_plain,
from_email,
[to_email],

Binary file not shown.

View file

@ -560,7 +560,7 @@ if (newReportForm) {
newReportForm.addEventListener("submit", function(event) {
event.preventDefault();
const url = getEndpointDomain() + "api/v1/report";
const payload = JSON.stringify({ "title": event.target.elements.title.value });
const payload = JSON.stringify({ "title": event.target.elements.title.value, "reference": event.target.elements.reference.value });
console.log("Payload:\n" + payload);
const type = reportType.NEW;
makeAjaxRequest("POST", url, createReportForm, type, payload);

View file

@ -51,6 +51,10 @@
<label for="title">Report title:</label>
<input type="text" class="form-control" name="title" id="title" autofocus>
</div>
<div class="form-group">
<label for="reference">Ticket number (if available):</label>
<input type="text" class="form-control" name="reference" id="reference">
</div>
<button type="submit" class="btn btn-primary" data-toggle="modal" data-target="#newReportModal">Create</button>
</form>
</div>