-
Notifications
You must be signed in to change notification settings - Fork 15
Add "fake" ticket page that DummyPlugin links to when autocreating tickets #1488
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1488 +/- ##
==========================================
- Coverage 78.97% 78.93% -0.04%
==========================================
Files 120 120
Lines 5294 5308 +14
==========================================
+ Hits 4181 4190 +9
- Misses 1113 1118 +5 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
bd50714
to
ed7a5a5
Compare
ed7a5a5
to
c83949f
Compare
|
"Demo ticket" might be another option for showing that it is not a real ticket |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would also like to see an additional test along the lines that the dummy plugin returns a valid url and that the result of following that url is a site containing some details of the incident
src/argus/htmx/incident/views.py
Outdated
from django.utils.timezone import now as tznow | ||
from django.urls import reverse |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
from django.utils.timezone import now as tznow | |
from django.urls import reverse | |
from django.urls import reverse | |
from django.utils.timezone import now as tznow |
src/argus/htmx/incident/views.py
Outdated
from argus.incident.ticket.utils import get_ticket_plugin_path | ||
from argus.incident.ticket.base import TicketPluginException | ||
from argus.incident.serializers import IncidentSerializer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
from argus.incident.ticket.utils import get_ticket_plugin_path | |
from argus.incident.ticket.base import TicketPluginException | |
from argus.incident.serializers import IncidentSerializer | |
from argus.incident.serializers import IncidentSerializer | |
from argus.incident.ticket.utils import get_ticket_plugin_path | |
from argus.incident.ticket.base import TicketPluginException |
context = IncidentSerializer(incident).data | ||
argus_url = urljoin( | ||
getattr(settings, "FRONTEND_URL", ""), | ||
reverse("htmx:incident-detail", kwargs={"pk": pk}), | ||
) | ||
context["argus_url"] = argus_url |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you could use
Argus/src/argus/incident/ticket/utils.py
Lines 64 to 72 in 4fc7811
def serialize_incident_for_ticket_autocreation(incident: Incident, actor: User): | |
serialized_incident = IncidentSerializer(incident).data | |
# TODO: ensure argus_url ends with "/" on HTMx frontend | |
serialized_incident["argus_url"] = urljoin( | |
getattr(settings, "FRONTEND_URL", ""), | |
f"incidents/{incident.pk}", | |
) | |
serialized_incident["user"] = actor.get_full_name() | |
return serialized_incident |
url = urljoin( | ||
getattr(settings, "FRONTEND_URL", ""), | ||
reverse("htmx:incident-detail", kwargs={"pk": serialized_incident["pk"]}), | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could move this into the create
function, just to keep the concern of "creating a ticket" separate for demonstration purposes on how to write a ticket plugin
url = urljoin( | ||
getattr(settings, "FRONTEND_URL", ""), | ||
reverse("htmx:incident-detail", kwargs={"pk": serialized_incident["pk"]}), | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This returns the link to the incident detail page, not the fake ticket system page
url = urljoin( | |
getattr(settings, "FRONTEND_URL", ""), | |
reverse("htmx:incident-detail", kwargs={"pk": serialized_incident["pk"]}), | |
) | |
url = reverse("htmx:fake-ticket", kwargs={"pk": serialized_incident["pk"]}) |
I will hand-check this when I can, no merging or approves before that. |
Scope and purpose
Fixes #1194.
Adds a page with information from an incident that kinda simulates what a real ticket could look like on a ticket site (very basic page). DummyPlugin will return a URL to this page when you use the "Create ticket" function.
Example of the basic page (uses a ticket html file that already existed):

The url has the format
/incidents/fake_ticket/<pk>/
. I'll happily take suggestions for URL names and such, or potentially other ways to generate a page like this. I kinda just went with the "fake" naming scheme, but maybe it should be called something else. Maybe/incidents/dummy_ticket/<pk>/
instead?Contributor Checklist
Every pull request should have this checklist filled out, no matter how small it is.
More information about contributing to Argus can be found in the
Development docs.