django-snapnote 0.3.0__tar.gz → 0.4.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. {django_snapnote-0.3.0 → django_snapnote-0.4.0}/CHANGELOG.md +5 -0
  2. {django_snapnote-0.3.0 → django_snapnote-0.4.0}/PKG-INFO +5 -1
  3. {django_snapnote-0.3.0 → django_snapnote-0.4.0}/README.md +4 -0
  4. django_snapnote-0.4.0/src/snapnote/__init__.py +1 -0
  5. {django_snapnote-0.3.0 → django_snapnote-0.4.0}/src/snapnote/admin.py +2 -2
  6. django_snapnote-0.4.0/src/snapnote/locale/es/LC_MESSAGES/django.mo +0 -0
  7. {django_snapnote-0.3.0 → django_snapnote-0.4.0}/src/snapnote/locale/es/LC_MESSAGES/django.po +3 -0
  8. {django_snapnote-0.3.0 → django_snapnote-0.4.0}/src/snapnote/management/commands/snapnote_export.py +3 -0
  9. django_snapnote-0.4.0/src/snapnote/migrations/0002_ticket_jira_key.py +19 -0
  10. {django_snapnote-0.3.0 → django_snapnote-0.4.0}/src/snapnote/models.py +9 -1
  11. {django_snapnote-0.3.0 → django_snapnote-0.4.0}/src/snapnote/notifiers.py +3 -0
  12. {django_snapnote-0.3.0 → django_snapnote-0.4.0}/src/snapnote/templates/snapnote/ticket_detail.html +1 -0
  13. {django_snapnote-0.3.0 → django_snapnote-0.4.0}/src/snapnote/templates/snapnote/ticket_list.html +3 -2
  14. {django_snapnote-0.3.0 → django_snapnote-0.4.0}/tests/test_jira.py +33 -0
  15. django_snapnote-0.3.0/src/snapnote/__init__.py +0 -1
  16. django_snapnote-0.3.0/src/snapnote/locale/es/LC_MESSAGES/django.mo +0 -0
  17. {django_snapnote-0.3.0 → django_snapnote-0.4.0}/.gitignore +0 -0
  18. {django_snapnote-0.3.0 → django_snapnote-0.4.0}/LICENSE +0 -0
  19. {django_snapnote-0.3.0 → django_snapnote-0.4.0}/frontend/e2e/smoke.mjs +0 -0
  20. {django_snapnote-0.3.0 → django_snapnote-0.4.0}/frontend/package-lock.json +0 -0
  21. {django_snapnote-0.3.0 → django_snapnote-0.4.0}/frontend/package.json +0 -0
  22. {django_snapnote-0.3.0 → django_snapnote-0.4.0}/frontend/src/AnnotationEditor.tsx +0 -0
  23. {django_snapnote-0.3.0 → django_snapnote-0.4.0}/frontend/src/App.tsx +0 -0
  24. {django_snapnote-0.3.0 → django_snapnote-0.4.0}/frontend/src/api.test.ts +0 -0
  25. {django_snapnote-0.3.0 → django_snapnote-0.4.0}/frontend/src/api.ts +0 -0
  26. {django_snapnote-0.3.0 → django_snapnote-0.4.0}/frontend/src/capture.ts +0 -0
  27. {django_snapnote-0.3.0 → django_snapnote-0.4.0}/frontend/src/drawing.test.ts +0 -0
  28. {django_snapnote-0.3.0 → django_snapnote-0.4.0}/frontend/src/drawing.ts +0 -0
  29. {django_snapnote-0.3.0 → django_snapnote-0.4.0}/frontend/src/icons.tsx +0 -0
  30. {django_snapnote-0.3.0 → django_snapnote-0.4.0}/frontend/src/main.tsx +0 -0
  31. {django_snapnote-0.3.0 → django_snapnote-0.4.0}/frontend/src/styles.css +0 -0
  32. {django_snapnote-0.3.0 → django_snapnote-0.4.0}/frontend/src/types.ts +0 -0
  33. {django_snapnote-0.3.0 → django_snapnote-0.4.0}/frontend/src/vite-env.d.ts +0 -0
  34. {django_snapnote-0.3.0 → django_snapnote-0.4.0}/frontend/tsconfig.json +0 -0
  35. {django_snapnote-0.3.0 → django_snapnote-0.4.0}/frontend/vite.config.ts +0 -0
  36. {django_snapnote-0.3.0 → django_snapnote-0.4.0}/pyproject.toml +0 -0
  37. {django_snapnote-0.3.0 → django_snapnote-0.4.0}/src/snapnote/apps.py +0 -0
  38. {django_snapnote-0.3.0 → django_snapnote-0.4.0}/src/snapnote/checks.py +0 -0
  39. {django_snapnote-0.3.0 → django_snapnote-0.4.0}/src/snapnote/claude/ticket.md +0 -0
  40. {django_snapnote-0.3.0 → django_snapnote-0.4.0}/src/snapnote/conf.py +0 -0
  41. {django_snapnote-0.3.0 → django_snapnote-0.4.0}/src/snapnote/forms.py +0 -0
  42. {django_snapnote-0.3.0 → django_snapnote-0.4.0}/src/snapnote/management/__init__.py +0 -0
  43. {django_snapnote-0.3.0 → django_snapnote-0.4.0}/src/snapnote/management/commands/__init__.py +0 -0
  44. {django_snapnote-0.3.0 → django_snapnote-0.4.0}/src/snapnote/management/commands/snapnote_install_claude_command.py +0 -0
  45. {django_snapnote-0.3.0 → django_snapnote-0.4.0}/src/snapnote/management/commands/snapnote_purge.py +0 -0
  46. {django_snapnote-0.3.0 → django_snapnote-0.4.0}/src/snapnote/middleware.py +0 -0
  47. {django_snapnote-0.3.0 → django_snapnote-0.4.0}/src/snapnote/migrations/0001_initial.py +0 -0
  48. {django_snapnote-0.3.0 → django_snapnote-0.4.0}/src/snapnote/migrations/__init__.py +0 -0
  49. {django_snapnote-0.3.0 → django_snapnote-0.4.0}/src/snapnote/permissions.py +0 -0
  50. {django_snapnote-0.3.0 → django_snapnote-0.4.0}/src/snapnote/signals.py +0 -0
  51. {django_snapnote-0.3.0 → django_snapnote-0.4.0}/src/snapnote/static/snapnote/management.css +0 -0
  52. {django_snapnote-0.3.0 → django_snapnote-0.4.0}/src/snapnote/static/snapnote/snapnote.js +0 -0
  53. {django_snapnote-0.3.0 → django_snapnote-0.4.0}/src/snapnote/templates/snapnote/base.html +0 -0
  54. {django_snapnote-0.3.0 → django_snapnote-0.4.0}/src/snapnote/templates/snapnote/button.html +0 -0
  55. {django_snapnote-0.3.0 → django_snapnote-0.4.0}/src/snapnote/templates/snapnote/includes/status_badge.html +0 -0
  56. {django_snapnote-0.3.0 → django_snapnote-0.4.0}/src/snapnote/templates/snapnote/ticket_confirm_delete.html +0 -0
  57. {django_snapnote-0.3.0 → django_snapnote-0.4.0}/src/snapnote/templatetags/__init__.py +0 -0
  58. {django_snapnote-0.3.0 → django_snapnote-0.4.0}/src/snapnote/templatetags/snapnote_tags.py +0 -0
  59. {django_snapnote-0.3.0 → django_snapnote-0.4.0}/src/snapnote/urls.py +0 -0
  60. {django_snapnote-0.3.0 → django_snapnote-0.4.0}/src/snapnote/views.py +0 -0
  61. {django_snapnote-0.3.0 → django_snapnote-0.4.0}/tests/__init__.py +0 -0
  62. {django_snapnote-0.3.0 → django_snapnote-0.4.0}/tests/conftest.py +0 -0
  63. {django_snapnote-0.3.0 → django_snapnote-0.4.0}/tests/helpers.py +0 -0
  64. {django_snapnote-0.3.0 → django_snapnote-0.4.0}/tests/test_button.py +0 -0
  65. {django_snapnote-0.3.0 → django_snapnote-0.4.0}/tests/test_claude_command.py +0 -0
  66. {django_snapnote-0.3.0 → django_snapnote-0.4.0}/tests/test_export.py +0 -0
  67. {django_snapnote-0.3.0 → django_snapnote-0.4.0}/tests/test_management.py +0 -0
  68. {django_snapnote-0.3.0 → django_snapnote-0.4.0}/tests/test_report.py +0 -0
  69. {django_snapnote-0.3.0 → django_snapnote-0.4.0}/tests/testproject/__init__.py +0 -0
  70. {django_snapnote-0.3.0 → django_snapnote-0.4.0}/tests/testproject/hostapp/__init__.py +0 -0
  71. {django_snapnote-0.3.0 → django_snapnote-0.4.0}/tests/testproject/hostapp/apps.py +0 -0
  72. {django_snapnote-0.3.0 → django_snapnote-0.4.0}/tests/testproject/hostapp/models.py +0 -0
  73. {django_snapnote-0.3.0 → django_snapnote-0.4.0}/tests/testproject/settings.py +0 -0
  74. {django_snapnote-0.3.0 → django_snapnote-0.4.0}/tests/testproject/templates/alt_base.html +0 -0
  75. {django_snapnote-0.3.0 → django_snapnote-0.4.0}/tests/testproject/templates/host_base.html +0 -0
  76. {django_snapnote-0.3.0 → django_snapnote-0.4.0}/tests/testproject/urls.py +0 -0
@@ -1,5 +1,10 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.4.0
4
+
5
+ - The Jira notifier stores the issue key in `Ticket.jira_key` (new migration `0002`). It is shown, with a link, in the
6
+ list and detail views and the admin, is searchable, and is included in `snapnote_export`.
7
+
3
8
  ## 0.3.0
4
9
 
5
10
  - `snapnote_install_claude_command`: installs a `/ticket` command for Claude Code (fetch the ticket, fix it, open a PR).
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: django-snapnote
3
- Version: 0.3.0
3
+ Version: 0.4.0
4
4
  Summary: Report problems from any page of a Django site: screenshot, annotations and a ticket list.
5
5
  License: MIT
6
6
  License-File: LICENSE
@@ -102,6 +102,10 @@ SNAPNOTE_JIRA_PROJECT = "APP" # project key
102
102
  # SNAPNOTE_JIRA_ATTACH_IMAGES = True, SNAPNOTE_JIRA_TIMEOUT = 10
103
103
  ```
104
104
 
105
+ The issue key is saved in `Ticket.jira_key` as soon as Jira creates the issue (even if an attachment
106
+ fails later), shown with a link in the views and admin, and exported by `snapnote_export`.
107
+ Tickets created before enabling the notifier have no key.
108
+
105
109
  `manage.py check` warns (`snapnote.W002`) if a required setting is missing. Use a dedicated
106
110
  Jira account with access only to that project. Notifiers run synchronously after commit with the
107
111
  timeout above; for heavy use, wrap it in your own task queue. Screenshots may contain sensitive
@@ -82,6 +82,10 @@ SNAPNOTE_JIRA_PROJECT = "APP" # project key
82
82
  # SNAPNOTE_JIRA_ATTACH_IMAGES = True, SNAPNOTE_JIRA_TIMEOUT = 10
83
83
  ```
84
84
 
85
+ The issue key is saved in `Ticket.jira_key` as soon as Jira creates the issue (even if an attachment
86
+ fails later), shown with a link in the views and admin, and exported by `snapnote_export`.
87
+ Tickets created before enabling the notifier have no key.
88
+
85
89
  `manage.py check` warns (`snapnote.W002`) if a required setting is missing. Use a dedicated
86
90
  Jira account with access only to that project. Notifiers run synchronously after commit with the
87
91
  timeout above; for heavy use, wrap it in your own task queue. Screenshots may contain sensitive
@@ -0,0 +1 @@
1
+ __version__ = "0.4.0"
@@ -5,8 +5,8 @@ from .models import Ticket
5
5
 
6
6
  @admin.register(Ticket)
7
7
  class TicketAdmin(admin.ModelAdmin):
8
- list_display = ("id", "title", "status", "reported_by", "created_at")
8
+ list_display = ("id", "title", "status", "jira_key", "reported_by", "created_at")
9
9
  list_filter = ("status", "created_at")
10
- search_fields = ("title", "description", "page_url")
10
+ search_fields = ("title", "description", "page_url", "jira_key")
11
11
  raw_id_fields = ("reported_by", "closed_by")
12
12
  readonly_fields = ("created_at", "updated_at")
@@ -184,3 +184,6 @@ msgstr "Confirmar"
184
184
 
185
185
  msgid "Are you sure you want to delete \"%(object)s\"?"
186
186
  msgstr "¿Seguro que quieres eliminar \"%(object)s\"?"
187
+
188
+ msgid "Jira key"
189
+ msgstr "Clave de Jira"
@@ -77,6 +77,7 @@ class Command(BaseCommand):
77
77
  "title": ticket.title,
78
78
  "status": ticket.status,
79
79
  "page_url": ticket.page_url,
80
+ "jira_key": ticket.jira_key or None,
80
81
  "reported_by": str(ticket.reported_by) if ticket.reported_by_id else None,
81
82
  "created_at": ticket.created_at.isoformat(),
82
83
  "closed_at": ticket.closed_at.isoformat() if ticket.closed_at else None,
@@ -87,6 +88,8 @@ class Command(BaseCommand):
87
88
 
88
89
  lines = [f"# Ticket #{ticket.pk}", "", NOTICE, "---", ""]
89
90
  lines += [f"- Status: {ticket.status}", f"- Page: {ticket.page_url}"]
91
+ if ticket.jira_key:
92
+ lines += [f"- Jira: {ticket.jira_key}"]
90
93
  lines += [
91
94
  f"- Reported by: {meta['reported_by'] or '-'}",
92
95
  f"- Created: {meta['created_at']}",
@@ -0,0 +1,19 @@
1
+ # Generated by Django 5.2.19 on 2026-11-13 13:29
2
+
3
+ from django.db import migrations, models
4
+
5
+
6
+ class Migration(migrations.Migration):
7
+ dependencies = [
8
+ ("snapnote", "0001_initial"),
9
+ ]
10
+
11
+ operations = [
12
+ migrations.AddField(
13
+ model_name="ticket",
14
+ name="jira_key",
15
+ field=models.CharField(
16
+ blank=True, db_index=True, max_length=50, verbose_name="Jira key"
17
+ ),
18
+ ),
19
+ ]
@@ -32,7 +32,7 @@ class TicketQuerySet(models.QuerySet):
32
32
  ):
33
33
  lookup = "unaccent__icontains"
34
34
  query = models.Q()
35
- for field in ("title", "description", "page_url"):
35
+ for field in ("title", "description", "page_url", "jira_key"):
36
36
  query |= models.Q(**{f"{field}__{lookup}": term})
37
37
  return self.filter(query)
38
38
 
@@ -75,6 +75,8 @@ class Ticket(models.Model):
75
75
  blank=True,
76
76
  related_name="+",
77
77
  )
78
+ # Key of the Jira issue created by snapnote.notifiers.jira_issue (e.g. "APP-7").
79
+ jira_key = models.CharField(_("Jira key"), max_length=50, blank=True, db_index=True)
78
80
  created_at = models.DateTimeField(_("created at"), auto_now_add=True)
79
81
  updated_at = models.DateTimeField(_("updated at"), auto_now=True)
80
82
 
@@ -100,6 +102,12 @@ class Ticket(models.Model):
100
102
  path = parts.path or "/"
101
103
  return f"{path}?{parts.query}" if parts.query else path
102
104
 
105
+ @property
106
+ def jira_url(self):
107
+ """Link to the Jira issue, or "" if there is none or Jira is not configured."""
108
+ base = conf.get("JIRA_URL").rstrip("/")
109
+ return f"{base}/browse/{self.jira_key}" if self.jira_key and base else ""
110
+
103
111
  @property
104
112
  def safe_page_url(self):
105
113
  """page_url if its scheme is http(s), else empty (never render javascript: links)."""
@@ -111,6 +111,9 @@ def jira_issue(ticket, absolute_url):
111
111
  }
112
112
  issue = _jira_request("/rest/api/3/issue", json.dumps(payload).encode(), "application/json")
113
113
  key = issue["key"]
114
+ # Saved right away: the attachments below are best effort and must not lose the key.
115
+ ticket.jira_key = key
116
+ ticket.save(update_fields=["jira_key"])
114
117
  if conf.get("JIRA_ATTACH_IMAGES"):
115
118
  for name in ("screenshot", "annotations"):
116
119
  image = getattr(ticket, name)
@@ -23,6 +23,7 @@
23
23
  <tr><th>{% trans "Reported by" %}</th><td>{{ ticket.reported_by|default:"-" }}</td></tr>
24
24
  <tr><th>{% trans "Created at" %}</th><td>{{ ticket.created_at }}</td></tr>
25
25
  {% if ticket.closed_at %}<tr><th>{% trans "Closed" %}</th><td>{{ ticket.closed_at }} ({{ ticket.closed_by|default:"-" }})</td></tr>{% endif %}
26
+ {% if ticket.jira_key %}<tr><th>Jira</th><td>{% if ticket.jira_url %}<a href="{{ ticket.jira_url }}" rel="noopener noreferrer">{{ ticket.jira_key }}</a>{% else %}{{ ticket.jira_key }}{% endif %}</td></tr>{% endif %}
26
27
  <tr><th>{% trans "Page" %}</th><td>{% if ticket.safe_page_url %}<a href="{{ ticket.safe_page_url }}" rel="noopener noreferrer">{{ ticket.page_url }}</a>{% else %}{{ ticket.page_url }}{% endif %}</td></tr>
27
28
  <tr><th>{% trans "Description" %}</th><td>{{ ticket.description|linebreaksbr|default:"-" }}</td></tr>
28
29
  </table>
@@ -11,7 +11,7 @@
11
11
  <table class="snapnote-table">
12
12
  <thead><tr>
13
13
  <th>#</th><th>{% trans "Title" %}</th><th>{% trans "Page" %}</th>
14
- <th>{% trans "Reported by" %}</th><th>{% trans "Status" %}</th><th>{% trans "Created at" %}</th>
14
+ <th>Jira</th><th>{% trans "Reported by" %}</th><th>{% trans "Status" %}</th><th>{% trans "Created at" %}</th>
15
15
  </tr></thead>
16
16
  <tbody>
17
17
  {% for ticket in object_list %}
@@ -19,12 +19,13 @@
19
19
  <td>{{ ticket.pk }}</td>
20
20
  <td><a href="{{ ticket.get_absolute_url }}">{{ ticket.title }}</a></td>
21
21
  <td>{{ ticket.page_path }}</td>
22
+ <td>{% if ticket.jira_url %}<a href="{{ ticket.jira_url }}" rel="noopener noreferrer">{{ ticket.jira_key }}</a>{% else %}{{ ticket.jira_key|default:"-" }}{% endif %}</td>
22
23
  <td>{{ ticket.reported_by|default:"-" }}</td>
23
24
  <td>{% include "snapnote/includes/status_badge.html" %}</td>
24
25
  <td>{{ ticket.created_at }}</td>
25
26
  </tr>
26
27
  {% empty %}
27
- <tr><td colspan="6" class="snapnote-empty">{% trans "No tickets found." %}</td></tr>
28
+ <tr><td colspan="7" class="snapnote-empty">{% trans "No tickets found." %}</td></tr>
28
29
  {% endfor %}
29
30
  </tbody>
30
31
  </table>
@@ -47,6 +47,9 @@ def test_creates_issue_and_attaches_images(jira, make_ticket, png):
47
47
  with mock.patch("urllib.request.urlopen", fake_urlopen(calls)):
48
48
  key = notifiers.jira_issue(ticket, "http://testserver/snapnote/1/")
49
49
  assert key == "APP-7"
50
+ ticket.refresh_from_db()
51
+ assert ticket.jira_key == "APP-7"
52
+ assert ticket.jira_url == "https://acme.atlassian.net/browse/APP-7"
50
53
  create, shot, ann = calls
51
54
  assert create.full_url == "https://acme.atlassian.net/rest/api/3/issue"
52
55
  assert create.get_header("Authorization").startswith("Basic ")
@@ -96,3 +99,33 @@ def test_check_warns_when_misconfigured(settings):
96
99
  def test_check_silent_when_configured(jira, settings):
97
100
  settings.SNAPNOTE_NOTIFIERS = ["snapnote.notifiers.jira_issue"]
98
101
  assert not [m for m in run_checks() if m.id == "snapnote.W002"]
102
+
103
+
104
+ def test_key_is_saved_even_if_attachments_fail(jira, make_ticket, png):
105
+ ticket = make_ticket(screenshot=png())
106
+ with mock.patch("urllib.request.urlopen", fake_urlopen([], fail_attachments=True)):
107
+ notifiers.jira_issue(ticket, "")
108
+ ticket.refresh_from_db()
109
+ assert ticket.jira_key == "APP-7"
110
+
111
+
112
+ def test_no_key_when_jira_fails(jira, make_ticket):
113
+ ticket = make_ticket()
114
+ with mock.patch("urllib.request.urlopen", side_effect=OSError("down")):
115
+ notifiers.run_notifiers(None, ticket, "")
116
+ ticket.refresh_from_db()
117
+ assert ticket.jira_key == "" and ticket.jira_url == ""
118
+
119
+
120
+ def test_key_shown_in_views_admin_and_export(jira, manager_client, make_ticket, tmp_path):
121
+ from django.core.management import call_command
122
+
123
+ ticket = make_ticket(jira_key="APP-7")
124
+ link = 'href="https://acme.atlassian.net/browse/APP-7"'
125
+ assert link in manager_client.get(ticket.get_absolute_url()).content.decode()
126
+ assert link in manager_client.get("/snapnote/").content.decode()
127
+ assert list(type(ticket).objects.search("APP-7")) == [ticket]
128
+ call_command("snapnote_export", ticket.pk, output=str(tmp_path))
129
+ folder = tmp_path / f"ticket-{ticket.pk}"
130
+ assert "APP-7" in (folder / "ticket.md").read_text()
131
+ assert '"jira_key": "APP-7"' in (folder / "ticket.json").read_text()
@@ -1 +0,0 @@
1
- __version__ = "0.3.0"
File without changes