diff --git a/issues/templates/issues/history.html b/issues/templates/issues/history.html
index 148ec09..36e974f 100644
--- a/issues/templates/issues/history.html
+++ b/issues/templates/issues/history.html
@@ -64,7 +64,17 @@
+
+ {% if turningpoint.kind == 100 %}
+
+
+
+
+
+ {% endif %}
{% endif %}
@@ -155,4 +165,7 @@
{% block extra_js %}
+
{% endblock %}
diff --git a/issues/urls.py b/issues/urls.py
index 8294f8d..e760816 100644
--- a/issues/urls.py
+++ b/issues/urls.py
@@ -2,7 +2,8 @@ from django.urls import path
from .views import (
issue_list, issue_event_stacktrace, issue_event_details, issue_last_event, issue_event_list, issue_history,
- issue_grouping, issue_event_breadcrumbs, event_by_internal_id, history_comment_new, history_comment_edit)
+ issue_grouping, issue_event_breadcrumbs, event_by_internal_id, history_comment_new, history_comment_edit,
+ history_comment_delete)
urlpatterns = [
path('/', issue_list, {"state_filter": "open"}, name="issue_list_open"),
@@ -29,4 +30,6 @@ urlpatterns = [
path('event//', event_by_internal_id, name="event_by_internal_id"),
path('issue//history/comment/', history_comment_new, name="history_comment_new"),
path('issue//history/comment//', history_comment_edit, name="history_comment_edit"),
+ path('issue//history/comment//delete/', history_comment_delete,
+ name="history_comment_delete"),
]
diff --git a/issues/views.py b/issues/views.py
index 931e7fd..c0997c4 100644
--- a/issues/views.py
+++ b/issues/views.py
@@ -445,4 +445,20 @@ def history_comment_edit(request, issue, comment_pk):
form.save()
return redirect(reverse(issue_history, kwargs={'issue_pk': issue.pk}) + f"#comment-{ comment_pk }")
+
+@issue_membership_required
+def history_comment_delete(request, issue, comment_pk):
+ comment = get_object_or_404(TurningPoint, pk=comment_pk, issue_id=issue.pk)
+
+ if comment.user_id != request.user.id:
+ raise PermissionDenied("You can only delete your own comments")
+
+ if comment.kind != TurningPointKind.MANUAL_ANNOTATION:
+ # I'm taking the 'allow almost nothing' path first
+ raise PermissionDenied("You can only delete manual annotations")
+
+ if request.method == "POST":
+ comment.delete()
+ return redirect(reverse(issue_history, kwargs={'issue_pk': issue.pk}))
+
return HttpResponseNotAllowed(["POST"])
diff --git a/static/js/issue_history.js b/static/js/issue_history.js
index 8df3129..8b45711 100644
--- a/static/js/issue_history.js
+++ b/static/js/issue_history.js
@@ -5,3 +5,18 @@ function toggleCommentEditable(element) {
balloon.querySelector(".js-comment-editable").classList.toggle("hidden");
balloon.querySelector(".js-comment-plain").classList.toggle("hidden");
}
+
+function deleteComment(deleteUrl) {
+ if (window.confirm("Are you sure you want to delete this comment?")) {
+ fetch(deleteUrl, {
+ method: 'POST',
+ headers: { "X-CSRFToken": csrftoken },
+ }).then((response) => {
+ // yes this is super-indirect, but it "works for now" and we might revisit this whole bit anyway (e.g. use HTMX)
+ // if we revisit this and figure out we want to do what we do here, but more directly (i.e. just post a form) read this one:
+ // https://stackoverflow.com/questions/133925/javascript-post-request-like-a-form-submit
+ // in other words, in that case the simplest way forward is probably just to create that form and post it instead of using the fetch API
+ window.location.reload();
+ })
+ }
+}
diff --git a/theme/static/css/dist/styles.css b/theme/static/css/dist/styles.css
index 3eca2e3..2138473 100644
--- a/theme/static/css/dist/styles.css
+++ b/theme/static/css/dist/styles.css
@@ -886,6 +886,10 @@ select {
margin-top: 1.5rem;
}
+.mb-1 {
+ margin-bottom: 0.25rem;
+}
+
.block {
display: block;
}