django-snapnote 0.4.0__tar.gz → 0.6.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.
- {django_snapnote-0.4.0 → django_snapnote-0.6.0}/.gitignore +5 -0
- {django_snapnote-0.4.0 → django_snapnote-0.6.0}/CHANGELOG.md +13 -0
- {django_snapnote-0.4.0 → django_snapnote-0.6.0}/PKG-INFO +36 -2
- {django_snapnote-0.4.0 → django_snapnote-0.6.0}/README.md +35 -1
- django_snapnote-0.6.0/src/snapnote/__init__.py +1 -0
- django_snapnote-0.6.0/src/snapnote/admin.py +24 -0
- {django_snapnote-0.4.0 → django_snapnote-0.6.0}/src/snapnote/claude/ticket.md +16 -11
- django_snapnote-0.6.0/src/snapnote/conf.py +61 -0
- {django_snapnote-0.4.0 → django_snapnote-0.6.0}/src/snapnote/forms.py +12 -1
- django_snapnote-0.6.0/src/snapnote/jira.py +83 -0
- django_snapnote-0.6.0/src/snapnote/locale/es/LC_MESSAGES/django.mo +0 -0
- {django_snapnote-0.4.0 → django_snapnote-0.6.0}/src/snapnote/locale/es/LC_MESSAGES/django.po +15 -0
- {django_snapnote-0.4.0 → django_snapnote-0.6.0}/src/snapnote/management/commands/snapnote_export.py +1 -0
- django_snapnote-0.6.0/src/snapnote/management/commands/snapnote_jira_export.py +124 -0
- django_snapnote-0.6.0/src/snapnote/management/commands/snapnote_retry_jira.py +36 -0
- django_snapnote-0.6.0/src/snapnote/migrations/0003_ticket_jira_error.py +17 -0
- {django_snapnote-0.4.0 → django_snapnote-0.6.0}/src/snapnote/models.py +19 -0
- {django_snapnote-0.4.0 → django_snapnote-0.6.0}/src/snapnote/notifiers.py +41 -5
- {django_snapnote-0.4.0 → django_snapnote-0.6.0}/src/snapnote/templates/snapnote/ticket_detail.html +12 -1
- {django_snapnote-0.4.0 → django_snapnote-0.6.0}/src/snapnote/templates/snapnote/ticket_list.html +2 -2
- {django_snapnote-0.4.0 → django_snapnote-0.6.0}/src/snapnote/urls.py +1 -0
- {django_snapnote-0.4.0 → django_snapnote-0.6.0}/src/snapnote/views.py +26 -0
- django_snapnote-0.6.0/tests/test_jira.py +306 -0
- django_snapnote-0.6.0/tests/test_jira_export.py +259 -0
- django_snapnote-0.4.0/src/snapnote/__init__.py +0 -1
- django_snapnote-0.4.0/src/snapnote/admin.py +0 -12
- django_snapnote-0.4.0/src/snapnote/conf.py +0 -34
- django_snapnote-0.4.0/src/snapnote/locale/es/LC_MESSAGES/django.mo +0 -0
- django_snapnote-0.4.0/tests/test_jira.py +0 -131
- {django_snapnote-0.4.0 → django_snapnote-0.6.0}/LICENSE +0 -0
- {django_snapnote-0.4.0 → django_snapnote-0.6.0}/frontend/e2e/smoke.mjs +0 -0
- {django_snapnote-0.4.0 → django_snapnote-0.6.0}/frontend/package-lock.json +0 -0
- {django_snapnote-0.4.0 → django_snapnote-0.6.0}/frontend/package.json +0 -0
- {django_snapnote-0.4.0 → django_snapnote-0.6.0}/frontend/src/AnnotationEditor.tsx +0 -0
- {django_snapnote-0.4.0 → django_snapnote-0.6.0}/frontend/src/App.tsx +0 -0
- {django_snapnote-0.4.0 → django_snapnote-0.6.0}/frontend/src/api.test.ts +0 -0
- {django_snapnote-0.4.0 → django_snapnote-0.6.0}/frontend/src/api.ts +0 -0
- {django_snapnote-0.4.0 → django_snapnote-0.6.0}/frontend/src/capture.ts +0 -0
- {django_snapnote-0.4.0 → django_snapnote-0.6.0}/frontend/src/drawing.test.ts +0 -0
- {django_snapnote-0.4.0 → django_snapnote-0.6.0}/frontend/src/drawing.ts +0 -0
- {django_snapnote-0.4.0 → django_snapnote-0.6.0}/frontend/src/icons.tsx +0 -0
- {django_snapnote-0.4.0 → django_snapnote-0.6.0}/frontend/src/main.tsx +0 -0
- {django_snapnote-0.4.0 → django_snapnote-0.6.0}/frontend/src/styles.css +0 -0
- {django_snapnote-0.4.0 → django_snapnote-0.6.0}/frontend/src/types.ts +0 -0
- {django_snapnote-0.4.0 → django_snapnote-0.6.0}/frontend/src/vite-env.d.ts +0 -0
- {django_snapnote-0.4.0 → django_snapnote-0.6.0}/frontend/tsconfig.json +0 -0
- {django_snapnote-0.4.0 → django_snapnote-0.6.0}/frontend/vite.config.ts +0 -0
- {django_snapnote-0.4.0 → django_snapnote-0.6.0}/pyproject.toml +0 -0
- {django_snapnote-0.4.0 → django_snapnote-0.6.0}/src/snapnote/apps.py +0 -0
- {django_snapnote-0.4.0 → django_snapnote-0.6.0}/src/snapnote/checks.py +0 -0
- {django_snapnote-0.4.0 → django_snapnote-0.6.0}/src/snapnote/management/__init__.py +0 -0
- {django_snapnote-0.4.0 → django_snapnote-0.6.0}/src/snapnote/management/commands/__init__.py +0 -0
- {django_snapnote-0.4.0 → django_snapnote-0.6.0}/src/snapnote/management/commands/snapnote_install_claude_command.py +0 -0
- {django_snapnote-0.4.0 → django_snapnote-0.6.0}/src/snapnote/management/commands/snapnote_purge.py +0 -0
- {django_snapnote-0.4.0 → django_snapnote-0.6.0}/src/snapnote/middleware.py +0 -0
- {django_snapnote-0.4.0 → django_snapnote-0.6.0}/src/snapnote/migrations/0001_initial.py +0 -0
- {django_snapnote-0.4.0 → django_snapnote-0.6.0}/src/snapnote/migrations/0002_ticket_jira_key.py +0 -0
- {django_snapnote-0.4.0 → django_snapnote-0.6.0}/src/snapnote/migrations/__init__.py +0 -0
- {django_snapnote-0.4.0 → django_snapnote-0.6.0}/src/snapnote/permissions.py +0 -0
- {django_snapnote-0.4.0 → django_snapnote-0.6.0}/src/snapnote/signals.py +0 -0
- {django_snapnote-0.4.0 → django_snapnote-0.6.0}/src/snapnote/static/snapnote/management.css +0 -0
- {django_snapnote-0.4.0 → django_snapnote-0.6.0}/src/snapnote/static/snapnote/snapnote.js +0 -0
- {django_snapnote-0.4.0 → django_snapnote-0.6.0}/src/snapnote/templates/snapnote/base.html +0 -0
- {django_snapnote-0.4.0 → django_snapnote-0.6.0}/src/snapnote/templates/snapnote/button.html +0 -0
- {django_snapnote-0.4.0 → django_snapnote-0.6.0}/src/snapnote/templates/snapnote/includes/status_badge.html +0 -0
- {django_snapnote-0.4.0 → django_snapnote-0.6.0}/src/snapnote/templates/snapnote/ticket_confirm_delete.html +0 -0
- {django_snapnote-0.4.0 → django_snapnote-0.6.0}/src/snapnote/templatetags/__init__.py +0 -0
- {django_snapnote-0.4.0 → django_snapnote-0.6.0}/src/snapnote/templatetags/snapnote_tags.py +0 -0
- {django_snapnote-0.4.0 → django_snapnote-0.6.0}/tests/__init__.py +0 -0
- {django_snapnote-0.4.0 → django_snapnote-0.6.0}/tests/conftest.py +0 -0
- {django_snapnote-0.4.0 → django_snapnote-0.6.0}/tests/helpers.py +0 -0
- {django_snapnote-0.4.0 → django_snapnote-0.6.0}/tests/test_button.py +0 -0
- {django_snapnote-0.4.0 → django_snapnote-0.6.0}/tests/test_claude_command.py +0 -0
- {django_snapnote-0.4.0 → django_snapnote-0.6.0}/tests/test_export.py +0 -0
- {django_snapnote-0.4.0 → django_snapnote-0.6.0}/tests/test_management.py +0 -0
- {django_snapnote-0.4.0 → django_snapnote-0.6.0}/tests/test_report.py +0 -0
- {django_snapnote-0.4.0 → django_snapnote-0.6.0}/tests/testproject/__init__.py +0 -0
- {django_snapnote-0.4.0 → django_snapnote-0.6.0}/tests/testproject/hostapp/__init__.py +0 -0
- {django_snapnote-0.4.0 → django_snapnote-0.6.0}/tests/testproject/hostapp/apps.py +0 -0
- {django_snapnote-0.4.0 → django_snapnote-0.6.0}/tests/testproject/hostapp/models.py +0 -0
- {django_snapnote-0.4.0 → django_snapnote-0.6.0}/tests/testproject/settings.py +0 -0
- {django_snapnote-0.4.0 → django_snapnote-0.6.0}/tests/testproject/templates/alt_base.html +0 -0
- {django_snapnote-0.4.0 → django_snapnote-0.6.0}/tests/testproject/templates/host_base.html +0 -0
- {django_snapnote-0.4.0 → django_snapnote-0.6.0}/tests/testproject/urls.py +0 -0
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.6.0
|
|
4
|
+
|
|
5
|
+
- `snapnote_jira_export`: reads a Jira issue (read only, optional separate read credentials) into the same folder
|
|
6
|
+
format as `snapnote_export`, so `/ticket APP-7` works without database or SSH access.
|
|
7
|
+
- The `/ticket` template accepts a Jira key. Re-run `snapnote_install_claude_command --force` to get it
|
|
8
|
+
(your local edits to the file will be overwritten).
|
|
9
|
+
|
|
10
|
+
## 0.5.0
|
|
11
|
+
|
|
12
|
+
- Jira failures are visible: `Ticket.jira_error` (migration `0003`), a "Jira failed" badge in the list and detail,
|
|
13
|
+
a Jira filter in the list and admin, a **Retry Jira** button and `manage.py snapnote_retry_jira`.
|
|
14
|
+
- New setting `SNAPNOTE_BASE_URL`.
|
|
15
|
+
|
|
3
16
|
## 0.4.0
|
|
4
17
|
|
|
5
18
|
- The Jira notifier stores the issue key in `Ticket.jira_key` (new migration `0002`). It is shown, with a link, in the
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: django-snapnote
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.6.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
|
|
@@ -62,6 +62,8 @@ Then `python manage.py migrate`. Uploaded images use your `MEDIA_ROOT`/storage.
|
|
|
62
62
|
| `SNAPNOTE_MAX_DIMENSION` | `8000` | Max width/height in pixels |
|
|
63
63
|
| `SNAPNOTE_UPLOAD_TO` | `"snapnote/"` | Prefix in the storage |
|
|
64
64
|
| `SNAPNOTE_THROTTLE` | `"10/hour"` | Reports per user (`second`, `minute`, `hour`, `day`); uses Django's cache. `None` disables |
|
|
65
|
+
| `SNAPNOTE_JIRA_READ_EMAIL`, `SNAPNOTE_JIRA_READ_API_TOKEN` | `""` | Optional read-only credentials for `snapnote_jira_export` (default: the `SNAPNOTE_JIRA_*` ones) |
|
|
66
|
+
| `SNAPNOTE_BASE_URL` | `""` | Public site URL used to link tickets from Jira issues created by `snapnote_retry_jira` |
|
|
65
67
|
| `SNAPNOTE_AUTO_INJECT` | `False` | Also add `snapnote.middleware.AutoInjectMiddleware` to `MIDDLEWARE` to insert the button automatically. Incompatible with strict CSP and streaming responses |
|
|
66
68
|
|
|
67
69
|
Customise the look by overriding CSS variables on `#snapnote-root`
|
|
@@ -106,6 +108,20 @@ The issue key is saved in `Ticket.jira_key` as soon as Jira creates the issue (e
|
|
|
106
108
|
fails later), shown with a link in the views and admin, and exported by `snapnote_export`.
|
|
107
109
|
Tickets created before enabling the notifier have no key.
|
|
108
110
|
|
|
111
|
+
If Jira fails, the ticket is still created and the error is stored (without credentials, max 300
|
|
112
|
+
characters) in `Ticket.jira_error`: the list and detail views show a "Jira failed" badge with the
|
|
113
|
+
error, the admin has a Jira filter, and users with `change_ticket` get a **Retry Jira** button in the
|
|
114
|
+
detail view. To retry in bulk (for example after a Jira outage):
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
python manage.py snapnote_retry_jira [--dry-run]
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
Set `SNAPNOTE_BASE_URL = "https://your-site.example.com"` so those issues link back to the ticket.
|
|
121
|
+
A retry never creates a second issue for a ticket that already has a key. If the issue is created but
|
|
122
|
+
an attachment fails, the key is kept and the error is shown next to it. Failures that happened before
|
|
123
|
+
this was recorded (versions up to 0.4.0) cannot be retried automatically.
|
|
124
|
+
|
|
109
125
|
`manage.py check` warns (`snapnote.W002`) if a required setting is missing. Use a dedicated
|
|
110
126
|
Jira account with access only to that project. Notifiers run synchronously after commit with the
|
|
111
127
|
timeout above; for heavy use, wrap it in your own task queue. Screenshots may contain sensitive
|
|
@@ -130,6 +146,24 @@ The text of a ticket is written by an end user, so `ticket.md` labels it as untr
|
|
|
130
146
|
places it in code fences; still review any change an assistant proposes before merging it, and
|
|
131
147
|
do not export into a repository you will commit (screenshots can contain sensitive data).
|
|
132
148
|
|
|
149
|
+
## Export a Jira issue (no database needed)
|
|
150
|
+
|
|
151
|
+
```bash
|
|
152
|
+
python manage.py snapnote_jira_export APP-7 # one or more keys
|
|
153
|
+
python manage.py snapnote_jira_export APP-7 --comments
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
Reads the issue from Jira (read only) and writes `snapnote-export/jira-APP-7/` with `ticket.md`,
|
|
157
|
+
`ticket.json`, the image attachments and, when the Jira notifier attached them,
|
|
158
|
+
`screenshot_annotated.png`. It reuses your `SNAPNOTE_JIRA_*` settings, so the credentials stay in
|
|
159
|
+
your Django settings and an AI assistant that runs the command never needs to be given them.
|
|
160
|
+
Optionally set `SNAPNOTE_JIRA_READ_EMAIL` / `SNAPNOTE_JIRA_READ_API_TOKEN` to use a read-only account.
|
|
161
|
+
|
|
162
|
+
Only keys of `SNAPNOTE_JIRA_PROJECT` are accepted, non-image attachments are skipped and comments are
|
|
163
|
+
left out unless you pass `--comments` (anyone with access to the project can write them, so they are
|
|
164
|
+
untrusted text). Everything is labelled as untrusted data in `ticket.md`. The credentials still exist
|
|
165
|
+
on the machine where the command runs; use a read-only account and keep them out of the repository.
|
|
166
|
+
|
|
133
167
|
## `/ticket` command for Claude Code
|
|
134
168
|
|
|
135
169
|
```bash
|
|
@@ -137,7 +171,7 @@ python manage.py snapnote_install_claude_command
|
|
|
137
171
|
```
|
|
138
172
|
|
|
139
173
|
Copies a `/ticket` command into `.claude/commands/ticket.md` of your project (and adds
|
|
140
|
-
`.snapnote-tickets/` to `.gitignore`). Then, in Claude Code: `/ticket 42`. Claude exports the ticket,
|
|
174
|
+
`.snapnote-tickets/` to `.gitignore`). Then, in Claude Code: `/ticket 42`. Claude exports the ticket (`/ticket APP-7` takes a Jira key and uses `snapnote_jira_export`),
|
|
141
175
|
reads the text and the annotated screenshot, locates the code behind the page, writes a test,
|
|
142
176
|
fixes the problem, runs your tests and opens a pull request, and stops there: it never merges,
|
|
143
177
|
deploys or closes the ticket.
|
|
@@ -42,6 +42,8 @@ Then `python manage.py migrate`. Uploaded images use your `MEDIA_ROOT`/storage.
|
|
|
42
42
|
| `SNAPNOTE_MAX_DIMENSION` | `8000` | Max width/height in pixels |
|
|
43
43
|
| `SNAPNOTE_UPLOAD_TO` | `"snapnote/"` | Prefix in the storage |
|
|
44
44
|
| `SNAPNOTE_THROTTLE` | `"10/hour"` | Reports per user (`second`, `minute`, `hour`, `day`); uses Django's cache. `None` disables |
|
|
45
|
+
| `SNAPNOTE_JIRA_READ_EMAIL`, `SNAPNOTE_JIRA_READ_API_TOKEN` | `""` | Optional read-only credentials for `snapnote_jira_export` (default: the `SNAPNOTE_JIRA_*` ones) |
|
|
46
|
+
| `SNAPNOTE_BASE_URL` | `""` | Public site URL used to link tickets from Jira issues created by `snapnote_retry_jira` |
|
|
45
47
|
| `SNAPNOTE_AUTO_INJECT` | `False` | Also add `snapnote.middleware.AutoInjectMiddleware` to `MIDDLEWARE` to insert the button automatically. Incompatible with strict CSP and streaming responses |
|
|
46
48
|
|
|
47
49
|
Customise the look by overriding CSS variables on `#snapnote-root`
|
|
@@ -86,6 +88,20 @@ The issue key is saved in `Ticket.jira_key` as soon as Jira creates the issue (e
|
|
|
86
88
|
fails later), shown with a link in the views and admin, and exported by `snapnote_export`.
|
|
87
89
|
Tickets created before enabling the notifier have no key.
|
|
88
90
|
|
|
91
|
+
If Jira fails, the ticket is still created and the error is stored (without credentials, max 300
|
|
92
|
+
characters) in `Ticket.jira_error`: the list and detail views show a "Jira failed" badge with the
|
|
93
|
+
error, the admin has a Jira filter, and users with `change_ticket` get a **Retry Jira** button in the
|
|
94
|
+
detail view. To retry in bulk (for example after a Jira outage):
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
python manage.py snapnote_retry_jira [--dry-run]
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
Set `SNAPNOTE_BASE_URL = "https://your-site.example.com"` so those issues link back to the ticket.
|
|
101
|
+
A retry never creates a second issue for a ticket that already has a key. If the issue is created but
|
|
102
|
+
an attachment fails, the key is kept and the error is shown next to it. Failures that happened before
|
|
103
|
+
this was recorded (versions up to 0.4.0) cannot be retried automatically.
|
|
104
|
+
|
|
89
105
|
`manage.py check` warns (`snapnote.W002`) if a required setting is missing. Use a dedicated
|
|
90
106
|
Jira account with access only to that project. Notifiers run synchronously after commit with the
|
|
91
107
|
timeout above; for heavy use, wrap it in your own task queue. Screenshots may contain sensitive
|
|
@@ -110,6 +126,24 @@ The text of a ticket is written by an end user, so `ticket.md` labels it as untr
|
|
|
110
126
|
places it in code fences; still review any change an assistant proposes before merging it, and
|
|
111
127
|
do not export into a repository you will commit (screenshots can contain sensitive data).
|
|
112
128
|
|
|
129
|
+
## Export a Jira issue (no database needed)
|
|
130
|
+
|
|
131
|
+
```bash
|
|
132
|
+
python manage.py snapnote_jira_export APP-7 # one or more keys
|
|
133
|
+
python manage.py snapnote_jira_export APP-7 --comments
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
Reads the issue from Jira (read only) and writes `snapnote-export/jira-APP-7/` with `ticket.md`,
|
|
137
|
+
`ticket.json`, the image attachments and, when the Jira notifier attached them,
|
|
138
|
+
`screenshot_annotated.png`. It reuses your `SNAPNOTE_JIRA_*` settings, so the credentials stay in
|
|
139
|
+
your Django settings and an AI assistant that runs the command never needs to be given them.
|
|
140
|
+
Optionally set `SNAPNOTE_JIRA_READ_EMAIL` / `SNAPNOTE_JIRA_READ_API_TOKEN` to use a read-only account.
|
|
141
|
+
|
|
142
|
+
Only keys of `SNAPNOTE_JIRA_PROJECT` are accepted, non-image attachments are skipped and comments are
|
|
143
|
+
left out unless you pass `--comments` (anyone with access to the project can write them, so they are
|
|
144
|
+
untrusted text). Everything is labelled as untrusted data in `ticket.md`. The credentials still exist
|
|
145
|
+
on the machine where the command runs; use a read-only account and keep them out of the repository.
|
|
146
|
+
|
|
113
147
|
## `/ticket` command for Claude Code
|
|
114
148
|
|
|
115
149
|
```bash
|
|
@@ -117,7 +151,7 @@ python manage.py snapnote_install_claude_command
|
|
|
117
151
|
```
|
|
118
152
|
|
|
119
153
|
Copies a `/ticket` command into `.claude/commands/ticket.md` of your project (and adds
|
|
120
|
-
`.snapnote-tickets/` to `.gitignore`). Then, in Claude Code: `/ticket 42`. Claude exports the ticket,
|
|
154
|
+
`.snapnote-tickets/` to `.gitignore`). Then, in Claude Code: `/ticket 42`. Claude exports the ticket (`/ticket APP-7` takes a Jira key and uses `snapnote_jira_export`),
|
|
121
155
|
reads the text and the annotated screenshot, locates the code behind the page, writes a test,
|
|
122
156
|
fixes the problem, runs your tests and opens a pull request, and stops there: it never merges,
|
|
123
157
|
deploys or closes the ticket.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.6.0"
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
from django.contrib import admin
|
|
2
|
+
from django.utils.translation import gettext_lazy as _
|
|
3
|
+
|
|
4
|
+
from .models import Ticket
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class JiraFilter(admin.SimpleListFilter):
|
|
8
|
+
title = "Jira"
|
|
9
|
+
parameter_name = "jira"
|
|
10
|
+
|
|
11
|
+
def lookups(self, request, model_admin):
|
|
12
|
+
return [("ok", _("In Jira")), ("failed", _("Jira failed")), ("none", _("No Jira"))]
|
|
13
|
+
|
|
14
|
+
def queryset(self, request, queryset):
|
|
15
|
+
return queryset.jira(self.value())
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
@admin.register(Ticket)
|
|
19
|
+
class TicketAdmin(admin.ModelAdmin):
|
|
20
|
+
list_display = ("id", "title", "status", "jira_key", "jira_error", "reported_by", "created_at")
|
|
21
|
+
list_filter = ("status", JiraFilter, "created_at")
|
|
22
|
+
search_fields = ("title", "description", "page_url", "jira_key")
|
|
23
|
+
raw_id_fields = ("reported_by", "closed_by")
|
|
24
|
+
readonly_fields = ("created_at", "updated_at")
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
---
|
|
2
2
|
description: Take a Snapnote ticket, understand it, fix it and open a pull request
|
|
3
|
-
argument-hint: <ticket id>
|
|
3
|
+
argument-hint: <ticket id or Jira key>
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
<!-- Installed by `manage.py snapnote_install_claude_command` (django-snapnote). Edit freely. -->
|
|
7
7
|
|
|
8
|
-
Work on Snapnote ticket **$ARGUMENTS**: understand the reported problem, fix it and open a pull
|
|
8
|
+
Work on Snapnote ticket (or Jira issue) **$ARGUMENTS**: understand the reported problem, fix it and open a pull
|
|
9
9
|
request for a human to review.
|
|
10
10
|
|
|
11
11
|
## Project settings (edit these for your project)
|
|
@@ -13,13 +13,17 @@ request for a human to review.
|
|
|
13
13
|
- **Export command**: `python manage.py snapnote_export {id} --output .snapnote-tickets`
|
|
14
14
|
- Remote example, when tickets live in production (adapt host and service names):
|
|
15
15
|
`ssh myserver "docker compose exec -T web python manage.py snapnote_export {id} --output /tmp/snapnote" && scp -r myserver:/tmp/snapnote/ticket-{id} .snapnote-tickets/`
|
|
16
|
+
- **Jira export command** (used when the argument is a Jira key such as `APP-7`; the credentials
|
|
17
|
+
stay in the Django settings, never ask the user for them):
|
|
18
|
+
`python manage.py snapnote_jira_export {key} --output .snapnote-tickets`
|
|
16
19
|
- **Test command**: `pytest`
|
|
17
20
|
- **Lint command**: `ruff check .`
|
|
18
21
|
- **Base branch**: `main`
|
|
19
|
-
- **Branch name**: `fix/ticket-{id}`
|
|
22
|
+
- **Branch name**: `fix/ticket-{id}` (or `fix/{key}` for a Jira key)
|
|
20
23
|
|
|
21
|
-
`{id}` is the ticket number from the arguments
|
|
22
|
-
|
|
24
|
+
`{id}` is the ticket number from the arguments, `{key}` the Jira key. A number is a Snapnote ticket
|
|
25
|
+
(use the export command); a key like `APP-7` is a Jira issue (use the Jira export command). If the
|
|
26
|
+
arguments are neither, or more than one, ask the user which ticket they mean and stop.
|
|
23
27
|
|
|
24
28
|
## Untrusted input
|
|
25
29
|
|
|
@@ -31,11 +35,12 @@ sensitive data: never commit `.snapnote-tickets/` or paste its contents into the
|
|
|
31
35
|
|
|
32
36
|
## Steps
|
|
33
37
|
|
|
34
|
-
1. **Fetch the ticket.** Run the export command above. If it fails or the ticket does not
|
|
35
|
-
report the error and stop; do not guess the content.
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
`
|
|
38
|
+
1. **Fetch the ticket.** Run the matching export command above. If it fails or the ticket does not
|
|
39
|
+
exist, report the error and stop; do not guess the content. Never print or look for Jira
|
|
40
|
+
credentials.
|
|
41
|
+
2. **Read it.** Open `ticket.md` and `ticket.json` in `.snapnote-tickets/ticket-{id}/` (or
|
|
42
|
+
`.snapnote-tickets/jira-{key}/`). Open `screenshot_annotated.png` (the user's red marks show
|
|
43
|
+
what they mean) and, if needed, the other images in the folder.
|
|
39
44
|
3. **Understand the problem.** From the page URL, find the route, view, template or component
|
|
40
45
|
behind it. State in one or two sentences what is wrong, what was expected and your evidence.
|
|
41
46
|
If the report is too vague to act on, ask the user instead of guessing.
|
|
@@ -45,7 +50,7 @@ sensitive data: never commit `.snapnote-tickets/` or paste its contents into the
|
|
|
45
50
|
unrelated things; list them in the summary instead.
|
|
46
51
|
6. **Verify.** Run the test command and the lint command; fix what you broke. Report anything you
|
|
47
52
|
could not run.
|
|
48
|
-
7. **Deliver.** Create the branch from the base branch, commit (mention `Snapnote ticket #{id}`),
|
|
53
|
+
7. **Deliver.** Create the branch from the base branch, commit (mention `Snapnote ticket #{id}` or the Jira key),
|
|
49
54
|
push the branch and open a pull request with `gh pr create` if available (otherwise print the
|
|
50
55
|
PR title and body). The PR describes the problem, the cause, the fix and how it was verified.
|
|
51
56
|
8. **Stop.** Never push to or merge into the base branch, never deploy, never close the ticket.
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
from django.conf import settings
|
|
2
|
+
from django.utils.module_loading import import_string
|
|
3
|
+
|
|
4
|
+
DEFAULTS = {
|
|
5
|
+
"CAN_REPORT": "snapnote.permissions.is_authenticated",
|
|
6
|
+
"NOTIFIERS": ["snapnote.notifiers.email"],
|
|
7
|
+
"NOTIFY_EMAILS": [],
|
|
8
|
+
"BASE_TEMPLATE": None,
|
|
9
|
+
"ENABLE_MANAGEMENT_VIEWS": True,
|
|
10
|
+
"SEARCH_UNACCENT": False,
|
|
11
|
+
"MAX_UPLOAD_MB": 5,
|
|
12
|
+
"MAX_DIMENSION": 8000,
|
|
13
|
+
"UPLOAD_TO": "snapnote/",
|
|
14
|
+
"THROTTLE": "10/hour",
|
|
15
|
+
"AUTO_INJECT": False,
|
|
16
|
+
# Jira notifier (snapnote.notifiers.jira_issue). URL, EMAIL, API_TOKEN and PROJECT are required.
|
|
17
|
+
"JIRA_URL": "",
|
|
18
|
+
"JIRA_EMAIL": "",
|
|
19
|
+
"JIRA_API_TOKEN": "",
|
|
20
|
+
"JIRA_PROJECT": "",
|
|
21
|
+
"JIRA_ISSUE_TYPE": "Bug",
|
|
22
|
+
"JIRA_LABELS": ["snapnote"],
|
|
23
|
+
"JIRA_ATTACH_IMAGES": True,
|
|
24
|
+
"JIRA_TIMEOUT": 10,
|
|
25
|
+
# Optional read-only credentials for snapnote_jira_export; default to the JIRA_* ones above.
|
|
26
|
+
"JIRA_READ_EMAIL": "",
|
|
27
|
+
"JIRA_READ_API_TOKEN": "",
|
|
28
|
+
# Public site URL (e.g. "https://intranet.example.com"), used to link tickets from Jira issues
|
|
29
|
+
# created outside a request (snapnote_retry_jira).
|
|
30
|
+
"BASE_URL": "",
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def get(name):
|
|
35
|
+
return getattr(settings, f"SNAPNOTE_{name}", DEFAULTS[name])
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def get_callable(name):
|
|
39
|
+
value = get(name)
|
|
40
|
+
return import_string(value) if isinstance(value, str) else value
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
JIRA_NOTIFIER = "snapnote.notifiers.jira_issue"
|
|
44
|
+
JIRA_REQUIRED = ("JIRA_URL", "JIRA_EMAIL", "JIRA_API_TOKEN", "JIRA_PROJECT")
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def jira_enabled():
|
|
48
|
+
"""True if the Jira notifier is active and fully configured."""
|
|
49
|
+
return JIRA_NOTIFIER in get("NOTIFIERS") and all(get(name) for name in JIRA_REQUIRED)
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
def jira_read_credentials():
|
|
53
|
+
"""(email, token) used to read issues: the read-only pair if set, else the main one."""
|
|
54
|
+
if get("JIRA_READ_API_TOKEN"):
|
|
55
|
+
return get("JIRA_READ_EMAIL") or get("JIRA_EMAIL"), get("JIRA_READ_API_TOKEN")
|
|
56
|
+
return get("JIRA_EMAIL"), get("JIRA_API_TOKEN")
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def jira_read_configured():
|
|
60
|
+
email, token = jira_read_credentials()
|
|
61
|
+
return bool(get("JIRA_URL") and get("JIRA_PROJECT") and email and token)
|
|
@@ -74,10 +74,21 @@ class TicketFilterForm(forms.Form):
|
|
|
74
74
|
label=_("Status"), required=False, choices=[("", _("All"))] + Ticket.Status.choices
|
|
75
75
|
)
|
|
76
76
|
|
|
77
|
+
jira = forms.ChoiceField(
|
|
78
|
+
label="Jira",
|
|
79
|
+
required=False,
|
|
80
|
+
choices=[
|
|
81
|
+
("", _("All")),
|
|
82
|
+
("ok", _("In Jira")),
|
|
83
|
+
("failed", _("Jira failed")),
|
|
84
|
+
("none", _("No Jira")),
|
|
85
|
+
],
|
|
86
|
+
)
|
|
87
|
+
|
|
77
88
|
def filter(self, queryset):
|
|
78
89
|
if not self.is_valid():
|
|
79
90
|
return queryset
|
|
80
|
-
queryset = queryset.search(self.cleaned_data["q"])
|
|
91
|
+
queryset = queryset.search(self.cleaned_data["q"]).jira(self.cleaned_data["jira"])
|
|
81
92
|
if self.cleaned_data["status"]:
|
|
82
93
|
queryset = queryset.filter(status=self.cleaned_data["status"])
|
|
83
94
|
return queryset
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"""Read-only access to Jira Cloud (stdlib only), used by snapnote_jira_export."""
|
|
2
|
+
|
|
3
|
+
import base64
|
|
4
|
+
import json
|
|
5
|
+
import urllib.error
|
|
6
|
+
import urllib.request
|
|
7
|
+
from urllib.parse import urlsplit
|
|
8
|
+
|
|
9
|
+
from . import conf
|
|
10
|
+
|
|
11
|
+
MAX_ATTACHMENT_BYTES = 10 * 1024 * 1024
|
|
12
|
+
REDIRECTS = (301, 302, 303, 307, 308)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class _NoRedirect(urllib.request.HTTPRedirectHandler):
|
|
16
|
+
"""Redirects are followed by hand so credentials never travel to another host."""
|
|
17
|
+
|
|
18
|
+
def redirect_request(self, *args, **kwargs):
|
|
19
|
+
return None
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
_opener = urllib.request.build_opener(_NoRedirect)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def _open(request):
|
|
26
|
+
return _opener.open(request, timeout=conf.get("JIRA_TIMEOUT"))
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def _auth_header():
|
|
30
|
+
email, token = conf.jira_read_credentials()
|
|
31
|
+
return "Basic " + base64.b64encode(f"{email}:{token}".encode()).decode()
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def get_json(path):
|
|
35
|
+
request = urllib.request.Request(
|
|
36
|
+
f"{conf.get('JIRA_URL').rstrip('/')}{path}",
|
|
37
|
+
headers={"Authorization": _auth_header(), "Accept": "application/json"},
|
|
38
|
+
)
|
|
39
|
+
with _open(request) as response:
|
|
40
|
+
return json.loads(response.read())
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def download(url, max_bytes=None):
|
|
44
|
+
"""Downloads an attachment; returns None if it is larger than max_bytes."""
|
|
45
|
+
max_bytes = max_bytes or MAX_ATTACHMENT_BYTES
|
|
46
|
+
request = urllib.request.Request(url, headers={"Authorization": _auth_header()})
|
|
47
|
+
try:
|
|
48
|
+
response = _open(request)
|
|
49
|
+
except urllib.error.HTTPError as exc:
|
|
50
|
+
location = exc.headers.get("Location") if exc.code in REDIRECTS else None
|
|
51
|
+
if not location or urlsplit(location).scheme != "https":
|
|
52
|
+
raise
|
|
53
|
+
# Signed media URL on another host: no credentials.
|
|
54
|
+
response = _open(urllib.request.Request(location))
|
|
55
|
+
with response:
|
|
56
|
+
data = response.read(max_bytes + 1)
|
|
57
|
+
return None if len(data) > max_bytes else data
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
def adf_to_text(node):
|
|
61
|
+
"""Plain text from an Atlassian Document Format node."""
|
|
62
|
+
kind = node.get("type")
|
|
63
|
+
children = node.get("content", [])
|
|
64
|
+
if kind == "text":
|
|
65
|
+
text = node.get("text", "")
|
|
66
|
+
for mark in node.get("marks", []):
|
|
67
|
+
href = mark.get("attrs", {}).get("href")
|
|
68
|
+
if mark.get("type") == "link" and href and href != text:
|
|
69
|
+
return f"{text} ({href})"
|
|
70
|
+
return text
|
|
71
|
+
if kind == "hardBreak":
|
|
72
|
+
return "\n"
|
|
73
|
+
if kind in ("mention", "emoji"):
|
|
74
|
+
return node.get("attrs", {}).get("text", "")
|
|
75
|
+
if kind == "inlineCard":
|
|
76
|
+
return node.get("attrs", {}).get("url", "")
|
|
77
|
+
if kind in ("bulletList", "orderedList"):
|
|
78
|
+
return "\n".join(f"- {adf_to_text(item)}" for item in children)
|
|
79
|
+
if kind == "listItem":
|
|
80
|
+
return "\n".join(adf_to_text(child) for child in children)
|
|
81
|
+
if kind in ("doc", "blockquote"):
|
|
82
|
+
return "\n\n".join(adf_to_text(child) for child in children)
|
|
83
|
+
return "".join(adf_to_text(child) for child in children)
|
|
Binary file
|
{django_snapnote-0.4.0 → django_snapnote-0.6.0}/src/snapnote/locale/es/LC_MESSAGES/django.po
RENAMED
|
@@ -187,3 +187,18 @@ msgstr "¿Seguro que quieres eliminar \"%(object)s\"?"
|
|
|
187
187
|
|
|
188
188
|
msgid "Jira key"
|
|
189
189
|
msgstr "Clave de Jira"
|
|
190
|
+
|
|
191
|
+
msgid "Jira error"
|
|
192
|
+
msgstr "Error de Jira"
|
|
193
|
+
|
|
194
|
+
msgid "In Jira"
|
|
195
|
+
msgstr "En Jira"
|
|
196
|
+
|
|
197
|
+
msgid "Jira failed"
|
|
198
|
+
msgstr "Jira falló"
|
|
199
|
+
|
|
200
|
+
msgid "No Jira"
|
|
201
|
+
msgstr "Sin Jira"
|
|
202
|
+
|
|
203
|
+
msgid "Retry Jira"
|
|
204
|
+
msgstr "Reintentar Jira"
|
{django_snapnote-0.4.0 → django_snapnote-0.6.0}/src/snapnote/management/commands/snapnote_export.py
RENAMED
|
@@ -78,6 +78,7 @@ class Command(BaseCommand):
|
|
|
78
78
|
"status": ticket.status,
|
|
79
79
|
"page_url": ticket.page_url,
|
|
80
80
|
"jira_key": ticket.jira_key or None,
|
|
81
|
+
"jira_error": ticket.jira_error or None,
|
|
81
82
|
"reported_by": str(ticket.reported_by) if ticket.reported_by_id else None,
|
|
82
83
|
"created_at": ticket.created_at.isoformat(),
|
|
83
84
|
"closed_at": ticket.closed_at.isoformat() if ticket.closed_at else None,
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import json
|
|
2
|
+
import re
|
|
3
|
+
import urllib.error
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
|
|
6
|
+
from django.core.management.base import BaseCommand, CommandError
|
|
7
|
+
|
|
8
|
+
from snapnote import conf, jira
|
|
9
|
+
from snapnote.notifiers import short_error
|
|
10
|
+
|
|
11
|
+
from .snapnote_export import NOTICE, composite, fence
|
|
12
|
+
|
|
13
|
+
KEY_RE = re.compile(r"^[A-Z][A-Z0-9]+-\d+$")
|
|
14
|
+
FIELDS = "summary,description,status,issuetype,reporter,created,labels,attachment"
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def safe_name(name):
|
|
18
|
+
return re.sub(r"[^A-Za-z0-9._-]", "_", Path(name).name)[:80] or "file"
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class Command(BaseCommand):
|
|
22
|
+
help = (
|
|
23
|
+
"Exports a Jira issue (read only) to a folder with ticket.md, ticket.json and its images, "
|
|
24
|
+
"so an AI coding assistant can read it without being given Jira credentials."
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
def add_arguments(self, parser):
|
|
28
|
+
parser.add_argument("keys", nargs="+", metavar="KEY", help="issue key, e.g. APP-7")
|
|
29
|
+
parser.add_argument("--output", default="snapnote-export", help="parent directory")
|
|
30
|
+
parser.add_argument(
|
|
31
|
+
"--comments", action="store_true", help="also export comments (untrusted text)"
|
|
32
|
+
)
|
|
33
|
+
|
|
34
|
+
def handle(self, *args, keys, output, comments, **options):
|
|
35
|
+
if not conf.jira_read_configured():
|
|
36
|
+
raise CommandError(
|
|
37
|
+
"Jira is not configured: set SNAPNOTE_JIRA_URL, SNAPNOTE_JIRA_PROJECT and "
|
|
38
|
+
"credentials (SNAPNOTE_JIRA_EMAIL/SNAPNOTE_JIRA_API_TOKEN, or the *_READ_* pair)."
|
|
39
|
+
)
|
|
40
|
+
project = conf.get("JIRA_PROJECT")
|
|
41
|
+
keys = [key.upper() for key in keys]
|
|
42
|
+
for key in keys:
|
|
43
|
+
if not KEY_RE.match(key):
|
|
44
|
+
raise CommandError(f"{key!r} is not a Jira issue key (expected e.g. {project}-7).")
|
|
45
|
+
if key.rsplit("-", 1)[0] != project:
|
|
46
|
+
raise CommandError(f"{key} is not in the configured project {project}.")
|
|
47
|
+
for key in keys:
|
|
48
|
+
self.stdout.write(str(self.export(key, Path(output) / f"jira-{key}", comments)))
|
|
49
|
+
|
|
50
|
+
def export(self, key, folder, with_comments):
|
|
51
|
+
fields = FIELDS + (",comment" if with_comments else "")
|
|
52
|
+
try:
|
|
53
|
+
issue = jira.get_json(f"/rest/api/3/issue/{key}?fields={fields}")
|
|
54
|
+
except Exception as exc:
|
|
55
|
+
raise CommandError(f"Could not read {key}: {short_error(exc)}") from None
|
|
56
|
+
data = issue["fields"]
|
|
57
|
+
|
|
58
|
+
folder.mkdir(parents=True, exist_ok=True)
|
|
59
|
+
images, skipped = {}, []
|
|
60
|
+
for attachment in data.get("attachment") or []:
|
|
61
|
+
name = safe_name(attachment.get("filename", ""))
|
|
62
|
+
if not attachment.get("mimeType", "").startswith("image/"):
|
|
63
|
+
skipped.append(f"{name} (not an image)")
|
|
64
|
+
continue
|
|
65
|
+
try:
|
|
66
|
+
content = jira.download(attachment["content"])
|
|
67
|
+
except (urllib.error.URLError, OSError) as exc:
|
|
68
|
+
skipped.append(f"{name} ({short_error(exc)})")
|
|
69
|
+
continue
|
|
70
|
+
if content is None:
|
|
71
|
+
skipped.append(f"{name} (too large)")
|
|
72
|
+
continue
|
|
73
|
+
target = folder / f"{attachment['id']}-{name}"
|
|
74
|
+
target.write_bytes(content)
|
|
75
|
+
images[name] = target
|
|
76
|
+
|
|
77
|
+
annotated = self.composite_pair(images, folder)
|
|
78
|
+
description = jira.adf_to_text(data["description"]) if data.get("description") else ""
|
|
79
|
+
reporter = (data.get("reporter") or {}).get("displayName")
|
|
80
|
+
url = f"{conf.get('JIRA_URL').rstrip('/')}/browse/{key}"
|
|
81
|
+
meta = {
|
|
82
|
+
"key": key,
|
|
83
|
+
"url": url,
|
|
84
|
+
"summary": data.get("summary"),
|
|
85
|
+
"status": (data.get("status") or {}).get("name"),
|
|
86
|
+
"issue_type": (data.get("issuetype") or {}).get("name"),
|
|
87
|
+
"reporter": reporter,
|
|
88
|
+
"created": data.get("created"),
|
|
89
|
+
"labels": data.get("labels") or [],
|
|
90
|
+
"images": sorted(path.name for path in images.values())
|
|
91
|
+
+ (["screenshot_annotated.png"] if annotated else []),
|
|
92
|
+
"skipped_attachments": skipped,
|
|
93
|
+
}
|
|
94
|
+
(folder / "ticket.json").write_text(json.dumps(meta, indent=2, ensure_ascii=False) + "\n")
|
|
95
|
+
|
|
96
|
+
lines = [f"# Jira issue {key}", "", NOTICE, "---", "", f"- URL: {url}"]
|
|
97
|
+
lines += [f"- Status: {meta['status']}", f"- Type: {meta['issue_type']}"]
|
|
98
|
+
lines += [f"- Reporter: {reporter or '-'}", f"- Created: {meta['created']}", ""]
|
|
99
|
+
lines += ["## Summary", "", fence(meta["summary"] or ""), "", "## Description", ""]
|
|
100
|
+
lines += [fence(description) if description else "(none)", ""]
|
|
101
|
+
if with_comments:
|
|
102
|
+
lines += ["## Comments (untrusted)", ""]
|
|
103
|
+
for comment in (data.get("comment") or {}).get("comments", []):
|
|
104
|
+
author = (comment.get("author") or {}).get("displayName", "?")
|
|
105
|
+
lines += [f"### {author} - {comment.get('created')}", ""]
|
|
106
|
+
lines += [fence(jira.adf_to_text(comment.get("body") or {})), ""]
|
|
107
|
+
if meta["images"]:
|
|
108
|
+
lines += ["## Images", ""] + [f"- `{name}`" for name in meta["images"]] + [""]
|
|
109
|
+
if skipped:
|
|
110
|
+
lines += ["## Attachments not downloaded", ""] + [f"- {item}" for item in skipped]
|
|
111
|
+
(folder / "ticket.md").write_text("\n".join(lines) + "\n")
|
|
112
|
+
return folder
|
|
113
|
+
|
|
114
|
+
def composite_pair(self, images, folder):
|
|
115
|
+
"""Merges the screenshot and annotation layer that the Jira notifier attaches."""
|
|
116
|
+
shot = next((p for n, p in images.items() if n.startswith("screenshot-")), None)
|
|
117
|
+
layer = next((p for n, p in images.items() if n.startswith("annotations-")), None)
|
|
118
|
+
if not (shot and layer):
|
|
119
|
+
return False
|
|
120
|
+
try:
|
|
121
|
+
composite(shot, layer, folder / "screenshot_annotated.png")
|
|
122
|
+
except Exception:
|
|
123
|
+
return False
|
|
124
|
+
return True
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
from django.core.management.base import BaseCommand, CommandError
|
|
2
|
+
|
|
3
|
+
from snapnote import conf
|
|
4
|
+
from snapnote.models import Ticket
|
|
5
|
+
from snapnote.notifiers import jira_issue
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class Command(BaseCommand):
|
|
9
|
+
help = "Retries creating the Jira issue of tickets whose creation failed (see the Jira column)."
|
|
10
|
+
|
|
11
|
+
def add_arguments(self, parser):
|
|
12
|
+
parser.add_argument("--dry-run", action="store_true")
|
|
13
|
+
|
|
14
|
+
def handle(self, *args, dry_run, **options):
|
|
15
|
+
if not conf.jira_enabled():
|
|
16
|
+
raise CommandError(
|
|
17
|
+
"The Jira notifier is not enabled or not fully configured "
|
|
18
|
+
"(SNAPNOTE_NOTIFIERS and SNAPNOTE_JIRA_* settings)."
|
|
19
|
+
)
|
|
20
|
+
base = conf.get("BASE_URL").rstrip("/")
|
|
21
|
+
done = failed = 0
|
|
22
|
+
for ticket in Ticket.objects.jira("failed").order_by("pk"):
|
|
23
|
+
if dry_run:
|
|
24
|
+
self.stdout.write(f"Would retry ticket {ticket.pk}: {ticket.jira_error}")
|
|
25
|
+
continue
|
|
26
|
+
path = ticket.get_absolute_url() if conf.get("ENABLE_MANAGEMENT_VIEWS") else ""
|
|
27
|
+
try:
|
|
28
|
+
key = jira_issue(ticket, f"{base}{path}" if base and path else "")
|
|
29
|
+
except Exception:
|
|
30
|
+
failed += 1
|
|
31
|
+
self.stderr.write(f"Ticket {ticket.pk} failed again: {ticket.jira_error}")
|
|
32
|
+
else:
|
|
33
|
+
done += 1
|
|
34
|
+
self.stdout.write(f"Ticket {ticket.pk} -> {key}")
|
|
35
|
+
if not dry_run:
|
|
36
|
+
self.stdout.write(f"Created {done} issue(s), {failed} failed.")
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Generated by Django 5.2.19 on 2026-11-13 13:52
|
|
2
|
+
|
|
3
|
+
from django.db import migrations, models
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class Migration(migrations.Migration):
|
|
7
|
+
dependencies = [
|
|
8
|
+
("snapnote", "0002_ticket_jira_key"),
|
|
9
|
+
]
|
|
10
|
+
|
|
11
|
+
operations = [
|
|
12
|
+
migrations.AddField(
|
|
13
|
+
model_name="ticket",
|
|
14
|
+
name="jira_error",
|
|
15
|
+
field=models.CharField(blank=True, max_length=300, verbose_name="Jira error"),
|
|
16
|
+
),
|
|
17
|
+
]
|