Skip to content

Commit 0fbfa1d

Browse files
ms-18Marius Schulzepre-commit-ci[bot]
authored
Automatically remove orphaned grouper instances (#190)
* fix: remove orphaned grouper instances and add fallback for str() Remove a grouper instance if the last Snippet instance connected to it gets deleted. Just in case also check for empty queryset in the name method of a grouper. * chore: update translation files and add german translation * test: add model test for new deletion behaviour * fix: delete snippet before snippet group * fix: use correct manager in test * fix: make sure .delete() is also called when batch deleting in admin * fix: ruff linting error * fix: use versioning aware filter * ci: auto fixes from pre-commit hooks for more information, see https://pre-commit.ci --------- Co-authored-by: Marius Schulze <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 8ed5eda commit 0fbfa1d

File tree

151 files changed

+2841
-780
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

151 files changed

+2841
-780
lines changed

src/djangocms_snippet/admin.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,3 +186,12 @@ def has_delete_permission(self, request, obj=None):
186186
get_model_permission_codename(self.model, "add"),
187187
)
188188
return False
189+
190+
def delete_queryset(self, request, queryset):
191+
"""
192+
Override delete_queryset to ensure that the snippet grouper is deleted
193+
when the last snippet in a group is deleted.
194+
"""
195+
for obj in queryset:
196+
obj.delete()
197+
return queryset
-41 Bytes
Binary file not shown.

src/djangocms_snippet/locale/af/LC_MESSAGES/django.po

Lines changed: 35 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,48 +8,73 @@ msgid ""
88
msgstr ""
99
"Project-Id-Version: PACKAGE VERSION\n"
1010
"Report-Msgid-Bugs-To: \n"
11-
"POT-Creation-Date: 2016-09-08 10:18+0200\n"
11+
"POT-Creation-Date: 2025-08-15 13:16+0200\n"
1212
"PO-Revision-Date: 2016-09-02 05:26+0000\n"
1313
"Language-Team: Afrikaans (https://www.transifex.com/divio/teams/58664/af/)\n"
14+
"Language: af\n"
1415
"MIME-Version: 1.0\n"
1516
"Content-Type: text/plain; charset=UTF-8\n"
1617
"Content-Transfer-Encoding: 8bit\n"
17-
"Language: af\n"
1818
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
1919

20-
#: apps.py:8 models.py:54 models.py:76
20+
#: admin.py:141
21+
#, python-format
22+
msgid "View %s"
23+
msgstr ""
24+
25+
#: apps.py:7 models.py:103
2126
msgid "Snippets"
2227
msgstr ""
2328

24-
#: cms_plugins.py:18 models.py:53 models.py:75
29+
#: cms_plugins.py:18 models.py:102
2530
msgid "Snippet"
2631
msgstr ""
2732

28-
#: cms_plugins.py:39 templatetags/snippet_tags.py:98
33+
#: cms_plugins.py:43 templatetags/snippet_tags.py:101
2934
#, python-format
3035
msgid "Template %(template)s does not exist."
3136
msgstr ""
3237

33-
#: models.py:22
38+
#: forms.py:37
39+
msgid "A Snippet with this name already exists"
40+
msgstr ""
41+
42+
#: forms.py:39
43+
msgid "A Snippet with this slug already exists"
44+
msgstr ""
45+
46+
#: models.py:40
47+
msgid "Empty Snippet Grouper"
48+
msgstr ""
49+
50+
#: models.py:66
3451
msgid "Name"
3552
msgstr ""
3653

37-
#: models.py:27
54+
#: models.py:74
3855
msgid "HTML"
3956
msgstr ""
4057

41-
#: models.py:31
58+
#: models.py:78
4259
msgid "Template"
4360
msgstr ""
4461

45-
#: models.py:34
62+
#: models.py:82
4663
msgid ""
4764
"Enter a template (e.g. \"snippets/plugin_xy.html\") to be rendered. If "
4865
"\"template\" is given, the contents of field \"HTML\" will be passed as "
4966
"template variable {{ html }} to the template. Otherwise, the content of "
5067
"\"HTML\" is rendered."
5168
msgstr ""
5269

53-
#: models.py:41
70+
#: models.py:90
5471
msgid "Slug"
5572
msgstr ""
73+
74+
#: models.py:149
75+
msgid "Snippet Ptr"
76+
msgstr ""
77+
78+
#: models.py:150
79+
msgid "Snippet Ptrs"
80+
msgstr ""
-45 Bytes
Binary file not shown.

src/djangocms_snippet/locale/ar/LC_MESSAGES/django.po

Lines changed: 41 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,49 +11,79 @@ msgid ""
1111
msgstr ""
1212
"Project-Id-Version: PACKAGE VERSION\n"
1313
"Report-Msgid-Bugs-To: \n"
14-
"POT-Creation-Date: 2016-09-08 10:18+0200\n"
14+
"POT-Creation-Date: 2025-08-15 13:16+0200\n"
1515
"PO-Revision-Date: 2016-09-02 05:26+0000\n"
1616
"Last-Translator: Angelo Dini <[email protected]>, 2016\n"
1717
"Language-Team: Arabic (https://www.transifex.com/divio/teams/58664/ar/)\n"
18+
"Language: ar\n"
1819
"MIME-Version: 1.0\n"
1920
"Content-Type: text/plain; charset=UTF-8\n"
2021
"Content-Transfer-Encoding: 8bit\n"
21-
"Language: ar\n"
22-
"Plural-Forms: nplurals=6; plural=n==0 ? 0 : n==1 ? 1 : n==2 ? 2 : n%100>=3 && n%100<=10 ? 3 : n%100>=11 && n%100<=99 ? 4 : 5;\n"
22+
"Plural-Forms: nplurals=6; plural=n==0 ? 0 : n==1 ? 1 : n==2 ? 2 : n%100>=3 "
23+
"&& n%100<=10 ? 3 : n%100>=11 && n%100<=99 ? 4 : 5;\n"
24+
25+
#: admin.py:141
26+
#, python-format
27+
msgid "View %s"
28+
msgstr ""
2329

24-
#: apps.py:8 models.py:54 models.py:76
30+
#: apps.py:7 models.py:103
2531
msgid "Snippets"
2632
msgstr "قصاصات"
2733

28-
#: cms_plugins.py:18 models.py:53 models.py:75
34+
#: cms_plugins.py:18 models.py:102
2935
msgid "Snippet"
3036
msgstr "قصاصات"
3137

32-
#: cms_plugins.py:39 templatetags/snippet_tags.py:98
38+
#: cms_plugins.py:43 templatetags/snippet_tags.py:101
3339
#, python-format
3440
msgid "Template %(template)s does not exist."
3541
msgstr "القالب %(template)s غير موجود."
3642

37-
#: models.py:22
43+
#: forms.py:37
44+
msgid "A Snippet with this name already exists"
45+
msgstr ""
46+
47+
#: forms.py:39
48+
msgid "A Snippet with this slug already exists"
49+
msgstr ""
50+
51+
#: models.py:40
52+
msgid "Empty Snippet Grouper"
53+
msgstr ""
54+
55+
#: models.py:66
3856
msgid "Name"
3957
msgstr ""
4058

41-
#: models.py:27
59+
#: models.py:74
4260
msgid "HTML"
4361
msgstr "HTML"
4462

45-
#: models.py:31
63+
#: models.py:78
4664
msgid "Template"
4765
msgstr ""
4866

49-
#: models.py:34
67+
#: models.py:82
5068
msgid ""
5169
"Enter a template (e.g. \"snippets/plugin_xy.html\") to be rendered. If "
5270
"\"template\" is given, the contents of field \"HTML\" will be passed as "
5371
"template variable {{ html }} to the template. Otherwise, the content of "
5472
"\"HTML\" is rendered."
5573
msgstr ""
5674

57-
#: models.py:41
75+
#: models.py:90
5876
msgid "Slug"
5977
msgstr ""
78+
79+
#: models.py:149
80+
#, fuzzy
81+
#| msgid "Snippet"
82+
msgid "Snippet Ptr"
83+
msgstr "قصاصات"
84+
85+
#: models.py:150
86+
#, fuzzy
87+
#| msgid "Snippets"
88+
msgid "Snippet Ptrs"
89+
msgstr "قصاصات"
-41 Bytes
Binary file not shown.

src/djangocms_snippet/locale/be/LC_MESSAGES/django.po

Lines changed: 38 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,48 +8,75 @@ msgid ""
88
msgstr ""
99
"Project-Id-Version: PACKAGE VERSION\n"
1010
"Report-Msgid-Bugs-To: \n"
11-
"POT-Creation-Date: 2016-09-08 10:18+0200\n"
11+
"POT-Creation-Date: 2025-08-15 13:16+0200\n"
1212
"PO-Revision-Date: 2016-09-02 05:26+0000\n"
1313
"Language-Team: Belarusian (https://www.transifex.com/divio/teams/58664/be/)\n"
14+
"Language: be\n"
1415
"MIME-Version: 1.0\n"
1516
"Content-Type: text/plain; charset=UTF-8\n"
1617
"Content-Transfer-Encoding: 8bit\n"
17-
"Language: be\n"
18-
"Plural-Forms: nplurals=4; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<12 || n%100>14) ? 1 : n%10==0 || (n%10>=5 && n%10<=9) || (n%100>=11 && n%100<=14)? 2 : 3);\n"
18+
"Plural-Forms: nplurals=4; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && "
19+
"n%10<=4 && (n%100<12 || n%100>14) ? 1 : n%10==0 || (n%10>=5 && n%10<=9) || "
20+
"(n%100>=11 && n%100<=14)? 2 : 3);\n"
21+
22+
#: admin.py:141
23+
#, python-format
24+
msgid "View %s"
25+
msgstr ""
1926

20-
#: apps.py:8 models.py:54 models.py:76
27+
#: apps.py:7 models.py:103
2128
msgid "Snippets"
2229
msgstr ""
2330

24-
#: cms_plugins.py:18 models.py:53 models.py:75
31+
#: cms_plugins.py:18 models.py:102
2532
msgid "Snippet"
2633
msgstr ""
2734

28-
#: cms_plugins.py:39 templatetags/snippet_tags.py:98
35+
#: cms_plugins.py:43 templatetags/snippet_tags.py:101
2936
#, python-format
3037
msgid "Template %(template)s does not exist."
3138
msgstr ""
3239

33-
#: models.py:22
40+
#: forms.py:37
41+
msgid "A Snippet with this name already exists"
42+
msgstr ""
43+
44+
#: forms.py:39
45+
msgid "A Snippet with this slug already exists"
46+
msgstr ""
47+
48+
#: models.py:40
49+
msgid "Empty Snippet Grouper"
50+
msgstr ""
51+
52+
#: models.py:66
3453
msgid "Name"
3554
msgstr ""
3655

37-
#: models.py:27
56+
#: models.py:74
3857
msgid "HTML"
3958
msgstr ""
4059

41-
#: models.py:31
60+
#: models.py:78
4261
msgid "Template"
4362
msgstr ""
4463

45-
#: models.py:34
64+
#: models.py:82
4665
msgid ""
4766
"Enter a template (e.g. \"snippets/plugin_xy.html\") to be rendered. If "
4867
"\"template\" is given, the contents of field \"HTML\" will be passed as "
4968
"template variable {{ html }} to the template. Otherwise, the content of "
5069
"\"HTML\" is rendered."
5170
msgstr ""
5271

53-
#: models.py:41
72+
#: models.py:90
5473
msgid "Slug"
5574
msgstr ""
75+
76+
#: models.py:149
77+
msgid "Snippet Ptr"
78+
msgstr ""
79+
80+
#: models.py:150
81+
msgid "Snippet Ptrs"
82+
msgstr ""
-45 Bytes
Binary file not shown.

src/djangocms_snippet/locale/bg/LC_MESSAGES/django.po

Lines changed: 39 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,49 +11,78 @@ msgid ""
1111
msgstr ""
1212
"Project-Id-Version: PACKAGE VERSION\n"
1313
"Report-Msgid-Bugs-To: \n"
14-
"POT-Creation-Date: 2016-09-08 10:18+0200\n"
14+
"POT-Creation-Date: 2025-08-15 13:16+0200\n"
1515
"PO-Revision-Date: 2016-09-02 05:26+0000\n"
1616
"Last-Translator: Angelo Dini <[email protected]>, 2016\n"
1717
"Language-Team: Bulgarian (https://www.transifex.com/divio/teams/58664/bg/)\n"
18+
"Language: bg\n"
1819
"MIME-Version: 1.0\n"
1920
"Content-Type: text/plain; charset=UTF-8\n"
2021
"Content-Transfer-Encoding: 8bit\n"
21-
"Language: bg\n"
2222
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
2323

24-
#: apps.py:8 models.py:54 models.py:76
24+
#: admin.py:141
25+
#, python-format
26+
msgid "View %s"
27+
msgstr ""
28+
29+
#: apps.py:7 models.py:103
2530
msgid "Snippets"
2631
msgstr "Изрезки"
2732

28-
#: cms_plugins.py:18 models.py:53 models.py:75
33+
#: cms_plugins.py:18 models.py:102
2934
msgid "Snippet"
3035
msgstr "Изрезка"
3136

32-
#: cms_plugins.py:39 templatetags/snippet_tags.py:98
37+
#: cms_plugins.py:43 templatetags/snippet_tags.py:101
3338
#, python-format
3439
msgid "Template %(template)s does not exist."
3540
msgstr "Шаблонът %(template)s не съществува."
3641

37-
#: models.py:22
42+
#: forms.py:37
43+
msgid "A Snippet with this name already exists"
44+
msgstr ""
45+
46+
#: forms.py:39
47+
msgid "A Snippet with this slug already exists"
48+
msgstr ""
49+
50+
#: models.py:40
51+
msgid "Empty Snippet Grouper"
52+
msgstr ""
53+
54+
#: models.py:66
3855
msgid "Name"
3956
msgstr ""
4057

41-
#: models.py:27
58+
#: models.py:74
4259
msgid "HTML"
4360
msgstr "HTML"
4461

45-
#: models.py:31
62+
#: models.py:78
4663
msgid "Template"
4764
msgstr ""
4865

49-
#: models.py:34
66+
#: models.py:82
5067
msgid ""
5168
"Enter a template (e.g. \"snippets/plugin_xy.html\") to be rendered. If "
5269
"\"template\" is given, the contents of field \"HTML\" will be passed as "
5370
"template variable {{ html }} to the template. Otherwise, the content of "
5471
"\"HTML\" is rendered."
5572
msgstr ""
5673

57-
#: models.py:41
74+
#: models.py:90
5875
msgid "Slug"
5976
msgstr ""
77+
78+
#: models.py:149
79+
#, fuzzy
80+
#| msgid "Snippet"
81+
msgid "Snippet Ptr"
82+
msgstr "Изрезка"
83+
84+
#: models.py:150
85+
#, fuzzy
86+
#| msgid "Snippets"
87+
msgid "Snippet Ptrs"
88+
msgstr "Изрезки"
-41 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)