Skip to content
This repository was archived by the owner on Jun 1, 2022. It is now read-only.

create button and open scooby in new window #401

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion vaccinate/api/submit_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from core.models import AppointmentTag, CallRequest, CallRequestReason, Location, Report
from dateutil import parser
from django.conf import settings
from django.db.models import Max
from django.http import JsonResponse
from django.utils import timezone
from django.views.decorators.csrf import csrf_exempt
Expand Down Expand Up @@ -152,7 +153,9 @@ def submit_report(request, on_request_logged):
{"error": "Report set do not call time but did not request a skip."},
status=400,
)
# Priority should match that of the original call request
# Priority group should match that of the original call request, BUT we
# use the separate priority integer to drop them to the very end of the
# queue within that priority group
CallRequest.objects.create(
location=report_data["location"],
vesting_at=report_data["do_not_call_until"],
Expand All @@ -162,6 +165,10 @@ def submit_report(request, on_request_logged):
priority_group=existing_call_request.priority_group
if existing_call_request
else 99,
priority=CallRequest.objects.filter(
priority_group=existing_call_request.priority_group
).aggregate(max=Max("priority"))["max"]
- 1,
)

def log_created_report(log):
Expand Down
1 change: 1 addition & 0 deletions vaccinate/api/test-data/submitReport/003.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"location__public_id": "rec5RXyYpi7IHQ2eN",
"vesting_at": "2021-03-07T18:35:03.742Z",
"priority_group": 2,
"priority": -1,
"call_request_reason__short_reason": "Previously skipped"
}
}
10 changes: 10 additions & 0 deletions vaccinate/core/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -639,6 +639,16 @@ def concordances_summary(self, obj):
+ "</div></div>"
)

def change_view(self, request, object_id, form_url="", extra_context=None):
extra_context = extra_context or {}
extra_context["location_id"] = object_id
return super().change_view(
request,
object_id,
form_url,
extra_context=extra_context,
)


class ReporterProviderFilter(admin.SimpleListFilter):
title = "Provider"
Expand Down
22 changes: 22 additions & 0 deletions vaccinate/core/migrations/0106_improved_priority_help_text.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Generated by Django 3.1.8 on 2021-04-27 22:36

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("core", "0105_location_import_run"),
]

operations = [
migrations.AlterField(
model_name="callrequest",
name="priority",
field=models.IntegerField(
db_index=True,
default=0,
help_text="Priority within this priority group - higher number means higher priority",
),
),
]
2 changes: 1 addition & 1 deletion vaccinate/core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -836,7 +836,7 @@ class TipType(models.TextChoices):
priority = models.IntegerField(
default=0,
db_index=True,
help_text="Priority for call queue - higher number means higher priority",
help_text="Priority within this priority group - higher number means higher priority",
)

tip_type = CharTextField(
Expand Down
18 changes: 18 additions & 0 deletions vaccinate/templates/admin/change_form.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,23 @@
div.style.fontSize = '0.9em';
div.innerText = JSON.stringify(data, null, 2);
});

function onClickSaveOpenScooby(element, locationId) {
window.open('https://help.vaccinateca.com/call/?location_id=' + locationId, '_blank');
}

</script>

{% endblock %}

{% block submit_buttons_bottom %}
{% load admin_modify %}
<input
onclick="onClickSaveOpenScooby(this, ({{ location_id }}))"
type="submit"
value="Save and open Scooby"
style="margin-bottom: 15px;"
>

{% submit_row %}
{% endblock %}