Skip to content

Commit

Permalink
✨ add color and donation banner to category
Browse files Browse the repository at this point in the history
  • Loading branch information
krmax44 committed May 13, 2024
1 parent e9e627f commit e37e089
Show file tree
Hide file tree
Showing 5 changed files with 120 additions and 8 deletions.
7 changes: 1 addition & 6 deletions fragdenstaat_de/fds_blog/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,7 @@ def queryset(self, request, queryset):


class CategoryAdmin(SortableAdminMixin, TranslatableAdmin):
fields = (
"title",
"description",
"slug",
"order",
)
fields = ("title", "description", "slug", "order", "color", "donation_banner")
list_display = ("title",)
search_fields = ("translations__title", "translations__description")

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
# Generated by Django 4.2.4 on 2024-05-13 17:49

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


class Migration(migrations.Migration):
dependencies = [
("djangocms_alias", "0004_alter_aliascontent_language"),
("fds_blog", "0018_remove_slider_template"),
]

operations = [
migrations.RemoveField(
model_name="article",
name="content_placeholder",
),
migrations.AddField(
model_name="category",
name="color",
field=models.CharField(
blank=True,
choices=[
("", "None"),
("callout", "Callout"),
("highlight", "Highlight"),
("body", "Default Body"),
("body-secondary", "Body Secondary"),
("body-tertiary", "Body Tertiary"),
("dark-subtle", "Dark Subtle"),
("light-subtle", "Light Subtle"),
("primary", "Primary"),
("primary-subtle", "Primary Subtle"),
("secondary", "Secondary"),
("secondary-subtle", "Secondary Subtle"),
("info", "Info"),
("info-subtle", "Info Subtle"),
("success", "Success"),
("success-subtle", "Success Subtle"),
("warning", "Warning"),
("warning-subtle", "Warning Subtle"),
("danger", "Danger"),
("danger-subtle", "Danger Subtle"),
("purple", "Purple"),
("pink", "Pink"),
("yellow", "Yellow"),
("cyan", "Cyan"),
("gray", "Gray"),
("gray-dark", "Gray Dark"),
("white", "White"),
("light", "Light"),
("dark", "Dark"),
("transparent", "Transparent"),
("gray-100", "Gray 100"),
("gray-200", "Gray 200"),
("gray-300", "Gray 300"),
("gray-400", "Gray 400"),
("gray-500", "Gray 500"),
("gray-600", "Gray 600"),
("gray-700", "Gray 700"),
("gray-800", "Gray 800"),
("gray-900", "Gray 900"),
("blue-10", "Blue 10"),
("blue-20", "Blue 20"),
("blue-30", "Blue 30"),
("blue-100", "Blue 100"),
("blue-200", "Blue 200"),
("blue-300", "Blue 300"),
("blue-400", "Blue 400"),
("blue-500", "Blue 500"),
("blue-600", "Blue 600"),
("blue-700", "Blue 700"),
("blue-800", "Blue 800"),
("yellow-100", "Yellow 100"),
("yellow-200", "Yellow 200"),
("yellow-300", "Yellow 300"),
],
default="",
help_text="Will be visible as the breadcrumb background.",
max_length=50,
verbose_name="Category color",
),
),
migrations.AddField(
model_name="category",
name="donation_banner",
field=models.ForeignKey(
default=None,
help_text="Inserted after a couple of paragraphs on the article page.",
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="donation_banner",
to="djangocms_alias.alias",
verbose_name="Donation banner",
),
),
]
21 changes: 21 additions & 0 deletions fragdenstaat_de/fds_blog/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@
from cms.toolbar.utils import get_object_edit_url
from cms.utils.placeholder import get_placeholder_from_slot
from cms.utils.plugins import get_plugins
from djangocms_alias.models import Alias
from filer.fields.image import FilerImageField
from fragdenstaat_de.fds_cms.utils import get_request
from fragdenstaat_de.theme.colors import BACKGROUND
from parler.models import TranslatableModel, TranslatedFields
from taggit.managers import TaggableManager
from taggit.models import TagBase, TaggedItemBase
Expand Down Expand Up @@ -184,6 +186,25 @@ class Category(TranslatableModel):
)
order = models.PositiveIntegerField(default=0)

color = models.CharField(
_("Category color"),
choices=BACKGROUND,
default="",
max_length=50,
blank=True,
help_text=_("Will be visible as the breadcrumb background."),
)

donation_banner = models.ForeignKey(
Alias,
on_delete=models.SET_NULL,
null=True,
default=None,
related_name="donation_banner",
verbose_name=_("Donation banner"),
help_text=_("Inserted after a couple of paragraphs on the article page."),
)

objects = CategoryManager()
published = RelatedPublishedManager()

Expand Down
3 changes: 1 addition & 2 deletions fragdenstaat_de/fds_cms/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,13 @@
from filer.fields.file import FilerFileField
from filer.fields.image import FilerImageField
from filingcabinet.models import DocumentPortal, PageAnnotation
from fragdenstaat_de.theme.colors import BACKDROP, BACKGROUND, get_css_color_variable
from taggit.models import Tag

from froide.document.models import Document, DocumentCollection
from froide.foirequest.models import FoiProject, FoiRequest
from froide.publicbody.models import Category, Classification, Jurisdiction, PublicBody

from .colors import BACKDROP, BACKGROUND, get_css_color_variable


@extension_pool.register
class FdsPageExtension(PageExtension):
Expand Down
File renamed without changes.

0 comments on commit e37e089

Please sign in to comment.