Skip to content

Commit

Permalink
Merge pull request #38 from NumanIbnMazid/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
NumanIbnMazid committed Jul 9, 2023
2 parents d92df8d + 68a9dd4 commit 48b5686
Show file tree
Hide file tree
Showing 300 changed files with 66,811 additions and 26,451 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# numanibnmazid.com
# nim23.com

```diff
- [N:B: This site is under construction]
Expand Down
30 changes: 27 additions & 3 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# TODO List

- Refine Project
- (DONE) Refine Project

- Remove all templates and static files
- Remove django unicorn dependency
- Remove all unnecessary dependencies from requirements

- Update Master and Dev Branch with refined project
- (DONE) Update Master and Dev Branch with refined project

- Design Starter Template
- (DONE) Design Starter Template

- Design starter template using tailwind CSS official documentation
- Minimum Requirements
Expand All @@ -18,6 +18,30 @@
- A demo body element
- Footer

- Utilities

- (DONE) Configure EmailJS (Contact Form). Better if mail would send via backend api.
- (REMOVED) Fix Utilities Page.
- Fix Every page's meta option.
- (DONE) Fix Snippets, (REMOVED) Newsletter, (REMOVED) RSS, (REMOVED) dev.to.
- (DONE) Fix footer.
- Fix Visitor Count.
- Fix Bar code Scanner.
- Fix Spotify.
- Implement Youtube Stats.
- Add YouTube Videos Page.
- Implement `generate_order` pre_save signal as a decorator and use in all django models where order is used.
- Implement Loader in All pages.
- Create and Update Site Logo.
- Remove all custom model manager as these are not needed in this project scope.
- (DONE) Fix blog slug page.
- (DONE) Generate auto token after expiration or make token to expire never.
- Test Rich Text Editor Image or File Upload and keeo only Tinymce, remove others.
- Implement Tailwind Documentation Page's Background Color.
- Implement Blog Comment, Reply, Like Features.
- Add PDF Reader or Modal on Project Details.
- Implemet Full Text Search.

## Bug Fix

-
Expand Down
15 changes: 15 additions & 0 deletions UTILS.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,18 @@
Generate without hashes

$ poetry export -f requirements.txt --output requirements.txt --without-hashes

## Demo User Authentication Token for Development

```json
{
"expiry": "2023-07-05T03:53:01.757821Z",
"token": "c012a83914869d906fc34e514d1c101e9175c652975f48372e731d72091c9bd3",
"user": {
"email": "admin@admin.com"
}
}
```

Usage:
Token 9ae5f0396f6b504f493e51f5c9bc77b80812cddad973f0b27e7de50ae70f83fa
2 changes: 1 addition & 1 deletion project/Dockerfile → backend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ FROM python:3.9.12-alpine3.15
ENV PYTHONUNBUFFERED 1

# Install required dependencies
RUN apk update && apk add gcc musl-dev libffi-dev
RUN apk update && apk add gcc musl-dev build-essential libssl-dev libffi-dev

RUN mkdir /app
WORKDIR /app
Expand Down
File renamed without changes.
73 changes: 73 additions & 0 deletions backend/blogs/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
from django.contrib import admin
from django.db import models
from blogs.models import BlogCategory,Blog, BlogViewIP, BlogComment
from utils.mixins import CustomModelAdminMixin
from tinymce.widgets import TinyMCE


# ----------------------------------------------------
# *** BlogCategory ***
# ----------------------------------------------------

class BlogCategoryAdmin(CustomModelAdminMixin, admin.ModelAdmin):
class Meta:
model = BlogCategory

admin.site.register(BlogCategory, BlogCategoryAdmin)


# ----------------------------------------------------
# *** Blog ***
# ----------------------------------------------------

class BlogAdmin(admin.ModelAdmin):
formfield_overrides = {
models.TextField: {'widget': TinyMCE()},
}

list_display = (
'title', 'category', 'image', 'overview', 'author', 'tags', 'get_reading_time',
'get_total_words', 'status', 'order', 'get_table_of_contents'
)

def get_reading_time(self, obj):
return obj.get_reading_time()

get_reading_time.short_description = 'Reading Time'

def get_total_words(self, obj):
return obj.get_total_words()

get_total_words.short_description = 'Total Words'

def get_table_of_contents(self, obj):
return obj.get_table_of_contents()

get_table_of_contents.short_description = 'Table of Contents'

class Meta:
model = Blog

admin.site.register(Blog, BlogAdmin)


# ----------------------------------------------------
# *** BlogViewIP ***
# ----------------------------------------------------

class BlogViewIPAdmin(CustomModelAdminMixin, admin.ModelAdmin):
class Meta:
model = BlogViewIP

admin.site.register(BlogViewIP, BlogViewIPAdmin)


# ----------------------------------------------------
# *** BlogComment ***
# ----------------------------------------------------

class BlogCommentAdmin(CustomModelAdminMixin, admin.ModelAdmin):
class Meta:
model = BlogComment

admin.site.register(BlogComment, BlogCommentAdmin)
5 changes: 5 additions & 0 deletions backend/blogs/api/routers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from config.router import router
from blogs.api.views import BlogViewset


router.register("blogs", BlogViewset, basename="code_snippets")
33 changes: 33 additions & 0 deletions backend/blogs/api/serializers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
from rest_framework import serializers
from blogs.models import Blog, BlogCategory


class BlogCategorySerializer(serializers.ModelSerializer):
class Meta:
model = BlogCategory
fields = "__all__"


class BlogSerializer(serializers.ModelSerializer):
category = BlogCategorySerializer()
image = serializers.SerializerMethodField()
reading_time = serializers.SerializerMethodField()
total_words = serializers.SerializerMethodField()
table_of_contents = serializers.SerializerMethodField()

class Meta:
model = Blog
fields = "__all__"
read_only_fields = ("id", "slug", "created_at", "updated_at")

def get_image(self, obj):
return obj.get_image()

def get_reading_time(self, obj):
return obj.get_reading_time()

def get_total_words(self, obj):
return obj.get_total_words()

def get_table_of_contents(self, obj):
return obj.get_table_of_contents()
27 changes: 27 additions & 0 deletions backend/blogs/api/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
from rest_framework import permissions
from rest_framework.viewsets import GenericViewSet
from rest_framework.mixins import ListModelMixin, RetrieveModelMixin
from utils.helpers import custom_response_wrapper
from blogs.models import Blog
from blogs.api.serializers import BlogSerializer


@custom_response_wrapper
class BlogViewset(GenericViewSet, ListModelMixin, RetrieveModelMixin):
permission_classes = (permissions.IsAuthenticated,)
queryset = Blog.objects.filter(status="Published")
serializer_class = BlogSerializer
lookup_field = 'slug'

def get_queryset(self):
queryset = super().get_queryset()
limit = self.request.query_params.get('_limit')

if limit:
try:
limit = int(limit)
queryset = queryset[:limit]
except ValueError:
pass

return queryset
6 changes: 6 additions & 0 deletions backend/blogs/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from django.apps import AppConfig


class BlogsConfig(AppConfig):
default_auto_field = "django.db.models.BigAutoField"
name = "blogs"
Loading

0 comments on commit 48b5686

Please sign in to comment.