Skip to content

Commit

Permalink
Remove ClassVar type hints
Browse files Browse the repository at this point in the history
  • Loading branch information
stuartmaxwell committed Nov 26, 2024
1 parent 11f3d7c commit 2fc3320
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 19 deletions.
30 changes: 14 additions & 16 deletions src/djpress/admin.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
"""djpress admin configuration."""

from typing import ClassVar

from django.contrib import admin
from django.utils import timezone
from django.utils.html import format_html
Expand All @@ -14,21 +12,21 @@
class CategoryAdmin(admin.ModelAdmin):
"""Category admin configuration."""

list_display: ClassVar["str"] = ["title", "slug"]
list_display = ["title", "slug"]


@admin.register(Post)
class PostAdmin(admin.ModelAdmin):
"""Post admin configuration."""

list_display: ClassVar[list[str]] = ["post_type", "published_status", "title", "parent", "formatted_date", "author"]
list_display_links: ClassVar[list[str]] = ["title"]
ordering: ClassVar[list[str]] = ["post_type", "-date"] # Displays pages first, then sorted by date.
list_filter: ClassVar[list[str]] = ["post_type", "date", "author"]
prepopulated_fields: ClassVar[dict[str, str]] = {"slug": ("title",)}
search_fields: ClassVar[list[str]] = ["title", "content", "slug"]
readonly_fields: ClassVar[list[str]] = ["modified_date"]
fieldsets: ClassVar = [
list_display = ["post_type", "published_status", "title", "parent", "formatted_date", "author"]
list_display_links = ["title"]
ordering = ["post_type", "-date"] # Displays pages first, then sorted by date.
list_filter = ["post_type", "date", "author"]
prepopulated_fields = {"slug": ("title",)}
search_fields = ["title", "content", "slug"]
readonly_fields = ["modified_date"]
fieldsets = [
(
None,
{
Expand Down Expand Up @@ -93,8 +91,8 @@ def formatted_date(self, obj: Post) -> str:
class PluginStorageAdmin(admin.ModelAdmin):
"""PluginStorage admin configuration."""

list_display: ClassVar["str"] = ["plugin_name", "plugin_data"]
list_display_links: ClassVar["str"] = ["plugin_name"]
ordering: ClassVar["str"] = ["plugin_name"]
search_fields: ClassVar["str"] = ["plugin_name"]
list_filter: ClassVar["str"] = ["plugin_name"]
list_display = ["plugin_name", "plugin_data"]
list_display_links = ["plugin_name"]
ordering = ["plugin_name"]
search_fields = ["plugin_name"]
list_filter = ["plugin_name"]
5 changes: 2 additions & 3 deletions src/djpress/models/post.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"""Post model."""

import logging
from typing import ClassVar

from django.contrib.auth.models import User
from django.core.cache import cache
Expand Down Expand Up @@ -346,8 +345,8 @@ def get_published_posts_by_author(
class Post(models.Model):
"""Post model."""

STATUS_CHOICES: ClassVar = [("draft", "Draft"), ("published", "Published")]
CONTENT_TYPE_CHOICES: ClassVar = [("post", "Post"), ("page", "Page")]
STATUS_CHOICES = [("draft", "Draft"), ("published", "Published")]
CONTENT_TYPE_CHOICES = [("post", "Post"), ("page", "Page")]

title = models.CharField(max_length=200)
slug = models.SlugField(unique=True, blank=True)
Expand Down

0 comments on commit 2fc3320

Please sign in to comment.