Skip to content

Commit

Permalink
style(sage_blog): refactor code and do black, isort and pre-commit rules
Browse files Browse the repository at this point in the history
  • Loading branch information
sepehr-akbarzadeh committed Aug 28, 2024
1 parent 4a9dae9 commit cd0cc3b
Show file tree
Hide file tree
Showing 17 changed files with 150 additions and 179 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -168,4 +168,4 @@ manage.py

# Ignore all migrations files except __init__.py
**/migrations/*
!**/migrations/__init__.py
!**/migrations/__init__.py
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
# django-sage-blog
# django-sage-blog
2 changes: 1 addition & 1 deletion sage_blog/admin/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from .category import PostCategoryAdmin
from .faq import PostFaqAdmin
from .tag import PostTagAdmin
from .post import PostAdmin
from .tag import PostTagAdmin
12 changes: 6 additions & 6 deletions sage_blog/admin/category.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from django.contrib import admin
from django.utils.translation import gettext_lazy as _

from sage_blog.models import PostCategory
from sage_blog.admin.filters import PostsStatusFilter
from sage_blog.models import PostCategory


@admin.register(PostCategory)
Expand All @@ -18,11 +18,11 @@ class PostCategoryAdmin(admin.ModelAdmin):
# Display settings
admin_priority = 1
list_display = (
"title",
"slug",
"is_published",
"published_posts_count",
"modified_at"
"title",
"slug",
"is_published",
"published_posts_count",
"modified_at",
)
list_filter = (PostsStatusFilter, "is_published")
search_fields = ("title",)
Expand Down
9 changes: 3 additions & 6 deletions sage_blog/admin/post.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from django.contrib import admin
from django.utils.translation import gettext_lazy as _

from sorl.thumbnail.admin import AdminImageMixin

from sage_blog.models import Post, PostFaq
Expand Down Expand Up @@ -49,11 +48,9 @@ class PostAdmin(admin.ModelAdmin, AdminImageMixin):
ordering = ("-published_at",)
readonly_fields = ("created_at", "modified_at", "slug")
fieldsets = (
("Basic Information",
{"fields": (
"title", "slug", "category", "is_published"
)
}
(
"Basic Information",
{"fields": ("title", "slug", "category", "is_published")},
),
(
"Content Details",
Expand Down
3 changes: 1 addition & 2 deletions sage_blog/management/commands/generate_blog_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ class Command(BaseCommand):
help = "Load a list of example data into the database"

def handle(self, *args, **kwargs):

logger.info("Generate Data for Blog")
DGL = DataGeneratorLayer()

Expand All @@ -41,7 +40,7 @@ def handle(self, *args, **kwargs):
)
stop = timeit.default_timer()
self.show_success_msg("create posts finished in: " + str(stop - start))

self.show_warning_msg("create FAQ")
start = timeit.default_timer()
DGL.create_faqs(
Expand Down
4 changes: 2 additions & 2 deletions sage_blog/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from .post import Post
from .faq import PostFaq
from .category import PostCategory
from .faq import PostFaq
from .post import Post
from .tag import PostTag
2 changes: 1 addition & 1 deletion sage_blog/models/category.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from django.db import models
from django.utils.translation import gettext_lazy as _

from sage_tools.mixins.models.base import TimeStampMixin, TitleSlugMixin

from sage_blog.repository.managers import CategoryDataAccessLayer


Expand Down
1 change: 0 additions & 1 deletion sage_blog/models/faq.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

from django.db import models
from django.utils.translation import gettext_lazy as _

from sage_tools.mixins.models.base import TimeStampMixin


Expand Down
3 changes: 2 additions & 1 deletion sage_blog/models/post.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@
except ImportError:
raise ImportError("Install `readtime` package. Run `pip install readtime` ")

from sage_seo.models.mixins.seo import SEOMixin, BlogDetailJsonLdMixin
from sage_seo.models.mixins.seo import BlogDetailJsonLdMixin, SEOMixin
from sage_tools.mixins.models.abstract import PictureOperationAbstract
from sage_tools.mixins.models.base import TimeStampMixin, TitleSlugDescriptionMixin

from sage_blog.repository.managers import PostDataAccessLayer


Expand Down
2 changes: 1 addition & 1 deletion sage_blog/models/tag.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from django.db import models
from django.utils.translation import gettext_lazy as _

from sage_tools.mixins.models.base import TimeStampMixin, TitleSlugMixin

from sage_blog.repository.managers import TagDataAccessLayer


Expand Down
Loading

0 comments on commit cd0cc3b

Please sign in to comment.