Skip to content

Commit

Permalink
Remove content hub
Browse files Browse the repository at this point in the history
  • Loading branch information
fsbraun committed May 19, 2024
1 parent 5956498 commit b02ac4b
Show file tree
Hide file tree
Showing 16 changed files with 151 additions and 287 deletions.
1 change: 0 additions & 1 deletion changes/694.feature

This file was deleted.

21 changes: 0 additions & 21 deletions djangocms_blog/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,28 +251,7 @@ class BlogCategoryAdmin(FrontendEditableAdminMixin, ModelAppHookConfig, Translat
"parent",
"app_config",
"all_languages_column",
"priority",
]
fieldsets = (
(None, {"fields": ("parent", "app_config", "name", "meta_description")}),
(
_("Info"),
{
"fields": (
"abstract",
"priority",
),
"classes": ("collapse",),
},
),
(
_("Images"),
{
"fields": ("main_image", "main_image_thumbnail", "main_image_full"),
"classes": ("collapse",),
},
),
)

def get_prepopulated_fields(self, request, obj=None):
app_config_default = self._app_config_select(request, obj)
Expand Down
18 changes: 0 additions & 18 deletions djangocms_blog/cms_appconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
"use_placeholder": get_setting("USE_PLACEHOLDER"),
"use_abstract": get_setting("USE_ABSTRACT"),
"use_related": int(get_setting("USE_RELATED")),
"urlconf": get_setting("URLCONF") if isinstance(get_setting("URLCONF"), str) else get_setting("URLCONF")[0][0],
"set_author": get_setting("AUTHOR_DEFAULT"),
"paginate_by": get_setting("PAGINATION"),
"template_prefix": "",
Expand Down Expand Up @@ -57,7 +56,6 @@ class BlogConfig(TranslatableModel):
use_placeholder (models.BooleanField): Represents whether to use placeholder and plugins for article body.
use_abstract (models.BooleanField): Represents whether to use abstract field.
use_related (models.SmallIntegerField): Represents whether to enable related posts.
urlconf (models.CharField): Represents the URL config.
set_author (models.BooleanField): Represents whether to set author by default.
paginate_by (models.SmallIntegerField): Represents the number of articles per page for pagination.
template_prefix (models.CharField): Represents the alternative directory to load the blog templates from.
Expand Down Expand Up @@ -143,15 +141,6 @@ class Meta:
(2, _("Yes, from this site")),
),
)
#: Adjust urlconf (default: :ref:`USE_RELATED <USE_RELATED>`)
urlconf = models.CharField(
max_length=200,
verbose_name=_("URL config"),
default=config_defaults["urlconf"],
choices=(
[(get_setting("URLCONF"), "---")] if isinstance(get_setting("URLCONF"), str) else get_setting("URLCONF")
),
)
#: Set author by default (default: :ref:`AUTHOR_DEFAULT <AUTHOR_DEFAULT>`)
set_author = models.BooleanField(
verbose_name=_("Set author by default"),
Expand Down Expand Up @@ -280,13 +269,6 @@ class Meta:
help_text=_("Emits a desktop notification -if enabled- when editing a published post"),
)

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
"""Remove urlconf from form if no apphook-based url config is enabled"""
if isinstance(get_setting("URLCONF"), str):
self.fields["urlconf"].widget = forms.HiddenInput()
self.fields["urlconf"].label = "" # Admin otherwise displays label for hidden field

def get_app_title(self):
return getattr(self, "app_title", _("untitled"))

Expand Down
10 changes: 1 addition & 9 deletions djangocms_blog/cms_apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,7 @@ class BlogApp(CMSApp):

def get_urls(self, page=None, language=None, **kwargs):
urlconf = get_setting("URLCONF")
if page is None or not page.application_namespace or isinstance(urlconf, str):
return [urlconf] # Single urlconf
return [
getattr(
self.app_config.objects.get(namespace=page.application_namespace),
"urlconf",
get_setting("URLCONF")[0][0],
)
] # Default if no urlconf is configured
return [urlconf] # Single urlconf

@property
def urls(self):
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# Generated by Django 5.0 on 2023-12-19 10:35

from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
("djangocms_blog", "0001_squashed_0047_migrate_config"),
]

operations = [
migrations.AlterModelOptions(
name="blogcategory",
options={
"ordering": (models.OrderBy(models.F("priority"), nulls_last=True),),
"verbose_name": "post category",
"verbose_name_plural": "post categories",
},
),
migrations.AlterModelOptions(
name="blogcategorytranslation",
options={
"default_permissions": (),
"managed": True,
"verbose_name": "post category Translation",
},
),
migrations.AlterModelOptions(
name="post",
options={
"get_latest_by": "date_published",
"ordering": (
models.OrderBy(models.F("pinned"), nulls_last=True),
"-date_published",
"-date_created",
),
"verbose_name": "post",
"verbose_name_plural": "posts",
},
),
migrations.AlterField(
model_name="authorentriesplugin",
name="template_folder",
field=models.CharField(
choices=[("plugins", "Default template")],
default="plugins",
help_text="Select plugin layout to load for this instance",
max_length=200,
verbose_name="Plugin layout",
),
),
migrations.AlterField(
model_name="blogconfigtranslation",
name="app_title",
field=models.CharField(
default="blog", max_length=200, verbose_name="application title"
),
),
migrations.AlterField(
model_name="genericblogplugin",
name="template_folder",
field=models.CharField(
choices=[("plugins", "Default template")],
default="plugins",
help_text="Select plugin layout to load for this instance",
max_length=200,
verbose_name="Plugin layout",
),
),
migrations.AlterField(
model_name="latestpostsplugin",
name="template_folder",
field=models.CharField(
choices=[("plugins", "Default template")],
default="plugins",
help_text="Select plugin layout to load for this instance",
max_length=200,
verbose_name="Plugin layout",
),
),
]
44 changes: 2 additions & 42 deletions djangocms_blog/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,31 +102,6 @@ class BlogCategory(BlogMetaMixin, ModelMeta, TranslatableModel):
verbose_name=_("app. config"),
help_text=_("When selecting a value, the form is reloaded to get the updated default"),
)
priority = models.IntegerField(_("priority"), blank=True, null=True)
main_image = FilerImageField(
verbose_name=_("main image"),
blank=True,
null=True,
on_delete=models.SET_NULL,
related_name="djangocms_category_image",
)
main_image_thumbnail = models.ForeignKey(
thumbnail_model,
verbose_name=_("main image thumbnail"),
related_name="djangocms_category_thumbnail",
on_delete=models.SET_NULL,
blank=True,
null=True,
)
main_image_full = models.ForeignKey(
thumbnail_model,
verbose_name=_("main image full"),
related_name="djangocms_category_full",
on_delete=models.SET_NULL,
blank=True,
null=True,
)

translations = TranslatedFields(
name=models.CharField(_("name"), max_length=752),
slug=models.SlugField(
Expand Down Expand Up @@ -165,7 +140,6 @@ class BlogCategory(BlogMetaMixin, ModelMeta, TranslatableModel):
class Meta:
verbose_name = _("post category")
verbose_name_plural = _("post categories")
ordering = (F("priority").asc(nulls_last=True),)

def descendants(self):
children = []
Expand All @@ -180,11 +154,6 @@ def linked_posts(self):
"""returns all linked posts in the same appconfig namespace"""
return self.blog_posts.filter(app_config=self.app_config)

@cached_property
def pinned_posts(self):
"""returns all linked posts which have a pinned value of at least 1"""
return self.linked_posts.filter(pinned__gt=0)

@cached_property
def count(self):
return self.linked_posts.filter(Q(sites__isnull=True) | Q(sites=Site.objects.get_current())).count()
Expand Down Expand Up @@ -246,14 +215,6 @@ class Post(KnockerModel, models.Model):
date_published = models.DateTimeField(_("published since"), null=True, blank=True)
date_published_end = models.DateTimeField(_("published until"), null=True, blank=True)
date_featured = models.DateTimeField(_("featured date"), null=True, blank=True)
pinned = models.IntegerField(
_("pinning priority"),
blank=True,
null=True,
help_text=_(
"Pinned posts are shown in ascending order before unpinned ones. " "Leave blank for regular order by date."
),
)
publish = models.BooleanField(_("publish"), default=False)
include_in_rss = models.BooleanField(_("include in RSS feed"), default=True)
categories = models.ManyToManyField(
Expand Down Expand Up @@ -345,7 +306,6 @@ class Post(KnockerModel, models.Model):
class Meta:
verbose_name = _("post")
verbose_name_plural = _("posts")
ordering = (F("pinned").asc(nulls_last=True), "-date_published", "-date_created")
get_latest_by = "date_published"

def __init__(self, *args, **kwargs):
Expand All @@ -359,7 +319,7 @@ def __str__(self):

@admin.display(boolean=True)
def featured(self):
return bool(self.pinned) or self.date_featured >= now()
return self.date_featured >= now()

def get_content(self, language=None, show_draft_content=False):
if not language:
Expand Down Expand Up @@ -546,7 +506,7 @@ class PostContent(BlogMetaMixin, ModelMeta, models.Model):
class Meta:
verbose_name = _("article content")
verbose_name_plural = _("article contents")
ordering = (F("post__pinned").asc(nulls_last=True), "-post__date_published", "-post__date_created")
ordering = ("-post__date_published", "-post__date_created")
get_latest_by = "date_published"

# Gruping fields
Expand Down
16 changes: 2 additions & 14 deletions djangocms_blog/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,10 @@
it's a dictionary with ``size``, ``crop`` and ``upscale`` keys.
"""

BLOG_URLCONF = (
("djangocms_blog.urls", _("Blog: Blog list at root url of blog")),
("djangocms_blog.urls_hub", _("Content hub: Category list at root url of blog")),
)
BLOG_URLCONF = "djangocms_blog.urls"
"""
.. _URLCONF:
List of alternative URL configurations which can be set per app hook.
Standard Apphook URLConf.
"""

BLOG_PAGINATION = 10
Expand Down Expand Up @@ -607,14 +603,6 @@
Name of the plugin field to add wizard text.
"""

BLOG_STRUCTURE = 0
"""
.. _STRUCTURE:
Default structure of blog: 0 for a list of posts ordered by publication date. 1 for a set of categories ordered by
priority.
"""

params = {param: value for param, value in locals().items() if param.startswith("BLOG_")}

"""
Expand Down
31 changes: 0 additions & 31 deletions djangocms_blog/templates/djangocms_blog/category_list.html

This file was deleted.

This file was deleted.

5 changes: 0 additions & 5 deletions djangocms_blog/templates/djangocms_blog/post_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,6 @@ <h2>
{% elif tagged_entries %}{% trans "Tag" %} &ndash; {{ tagged_entries|capfirst }}
{% elif category %}{% trans "Category" %} &ndash; {% render_model category "name" %}{% endif %}
</h2>
{% if category.abstract %}
<div class="category-abstract">
{% render_model category "abstract" %}
</div>
{% endif %}
</header>
{% endblock %}
{% for postcontent in postcontent_list %}
Expand Down
Loading

0 comments on commit b02ac4b

Please sign in to comment.