Skip to content
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

Added site field in models n site filter in admin #159

2 changes: 2 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ Changelog

Unreleased
==========
* feat: Added site field in Snippet model
vipulnarang95 marked this conversation as resolved.
Show resolved Hide resolved
* feat: Added site filter in Snippet Admin
* add support for python 3.10
* add support for django 4.2
* drop support for django < 3.2
Expand Down
1 change: 1 addition & 0 deletions djangocms_snippet/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
@admin.register(Snippet)
class SnippetAdmin(*snippet_admin_classes):
list_display = ('name',)
list_filter = ['site']
search_fields = ['name']
change_form_template = 'djangocms_snippet/admin/change_form.html'
text_area_attrs = {
Expand Down
1 change: 1 addition & 0 deletions djangocms_snippet/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class Meta:
"slug",
"snippet_grouper",
"template",
"site",
)

def __init__(self, *args, **kwargs):
Expand Down
20 changes: 20 additions & 0 deletions djangocms_snippet/migrations/0013_snippet_site.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Generated by Django 4.2.11 on 2024-05-07 03:43

import django.db.models.deletion
from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('sites', '0002_alter_domain_unique'),
('djangocms_snippet', '0012_auto_20210915_0721'),
]

operations = [
migrations.AddField(
model_name='snippet',
name='site',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='sites.site'),
),
]
2 changes: 2 additions & 0 deletions djangocms_snippet/models.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from django.conf import settings
from django.contrib.sites.models import Site
from django.db import models
from django.shortcuts import reverse
from django.utils.translation import gettext_lazy as _
Expand Down Expand Up @@ -70,6 +71,7 @@ class Snippet(models.Model):
default='',
max_length=255,
)
site = models.ForeignKey(Site, on_delete=models.CASCADE, null=True, blank=True)

def __str__(self):
return self.name
Expand Down
2 changes: 1 addition & 1 deletion tests/requirements/dj42_cms40.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ Django>=4.2,<5.0

# Unreleased django 4.2 & django-cms 4.0.x compatible packages
https://github.com/django-cms/django-cms/tarball/release/4.0.1.x#egg=django-cms
https://github.com/joshyu/djangocms-versioning/tarball/feat/django-42-compatible#egg=djangocms-versioning
https://github.com/django-cms/djangocms-versioning/tarball/support/django-cms-4.0.x#egg=djangocms-versioning
Loading