UI and Backend polish

This commit is contained in:
Barunes Padhy 2024-06-12 14:24:54 +03:00
parent 3042ed9722
commit a289696ad3
8 changed files with 61 additions and 7 deletions

2
backend/.gitignore vendored
View File

@ -13,6 +13,8 @@ media
.idea .idea
deploy deploy
media media
static
templates
# If your build process includes running collectstatic, then you probably don't need or want to include staticfiles/ # If your build process includes running collectstatic, then you probably don't need or want to include staticfiles/
# in your Git repository. Update and uncomment the following line accordingly. # in your Git repository. Update and uncomment the following line accordingly.

View File

@ -1,11 +1,15 @@
import os
import shutil
#######################Django related imports#################### #######################Django related imports####################
from rest_framework import generics, status from rest_framework import generics, status
from rest_framework.views import APIView from rest_framework.views import APIView
from rest_framework.response import Response from rest_framework.response import Response
from django.conf import settings
################################################################# #################################################################
#API related imports #API related imports
from .models import ( from .models import (
Category, Category,
Blog
) )
from .serializers import ( from .serializers import (
CategorySerializer, CategorySerializer,
@ -31,6 +35,20 @@ class CategoryDeleteAPIView(generics.DestroyAPIView):
serializer_class = CategorySerializer serializer_class = CategorySerializer
lookup_field = 'category_id' lookup_field = 'category_id'
def delete(self, request, *args, **kwargs):
instance = self.get_object()
media_folder = os.path.join(settings.MEDIA_ROOT, 'data', 'category', str(instance.category_id))
if os.path.exists(media_folder):
shutil.rmtree(media_folder)
if hasattr(instance, 'blogs'): # Ensuring the related_name is 'blogs'
for blog in instance.blogs.all():
blog_media_folder = os.path.join(settings.MEDIA_ROOT, 'data', 'blog', str(blog.blog_id))
if os.path.exists(blog_media_folder):
shutil.rmtree(blog_media_folder)
return super().delete(request, *args, **kwargs)
class BlogsByCategoryAPIView(APIView): class BlogsByCategoryAPIView(APIView):
def get(self, request, category_id): def get(self, request, category_id):
try: try:

View File

@ -1,4 +1,5 @@
import os import os
import shutil
import random import random
from rest_framework import status from rest_framework import status
from rest_framework.views import APIView from rest_framework.views import APIView

View File

@ -24,7 +24,7 @@ BASE_DIR = Path(__file__).resolve().parent.parent
SECRET_KEY = 'django-insecure-2qks!5e#imys-r@tp2t#%cc3!*apkfu9f-(a7t)bn%sm@@3aq+' SECRET_KEY = 'django-insecure-2qks!5e#imys-r@tp2t#%cc3!*apkfu9f-(a7t)bn%sm@@3aq+'
# SECURITY WARNING: don't run with debug turned on in production! # SECURITY WARNING: don't run with debug turned on in production!
DEBUG = False DEBUG = True
ALLOWED_HOSTS = ['localhost', '127.0.0.1', '0.0.0.0'] ALLOWED_HOSTS = ['localhost', '127.0.0.1', '0.0.0.0']

View File

@ -37,8 +37,9 @@ from apimanager.publish_views import (
) )
urlpatterns = [ urlpatterns = [
# API Views
path('admin/', admin.site.urls), path('admin/', admin.site.urls),
path('', views.index, name='index'),
path('data/shared/user-data/', UserDataListAPIView.as_view(), name='user-data-list-view'), path('data/shared/user-data/', UserDataListAPIView.as_view(), name='user-data-list-view'),
path('data/shared/update/user-data/', UserDataUpdateAPIView.as_view(), name='user-data-update-view'), path('data/shared/update/user-data/', UserDataUpdateAPIView.as_view(), name='user-data-update-view'),
path('data/shared/theme-config/', ThemeDataListAPIView.as_view(), name='theme-data-list-view'), path('data/shared/theme-config/', ThemeDataListAPIView.as_view(), name='theme-data-list-view'),
@ -56,6 +57,12 @@ urlpatterns = [
path('data/media/<str:resource_type>/<str:resource_id>/', ListMedia.as_view(), name='list-media'), path('data/media/<str:resource_type>/<str:resource_id>/', ListMedia.as_view(), name='list-media'),
path('data/publish/methods/', PublishMethods.as_view(), name='publish-methods'), path('data/publish/methods/', PublishMethods.as_view(), name='publish-methods'),
path('data/publish/<str:deploy_type>/', Publish.as_view(), name='publish'), path('data/publish/<str:deploy_type>/', Publish.as_view(), name='publish'),
# Frontend Views
path('', views.index, name='index'),
path('categories', views.index, name='index'),
path('categories/<str:website_slug>', views.index, name='index'),
path('blog/<str:website_slug>', views.index, name='index'),
] ]
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT) urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)

View File

@ -1,4 +1,4 @@
from django.shortcuts import render from django.shortcuts import render
def index(request): def index(request, website_slug=None):
return render(request, "index.html") return render(request, "index.html")

26
frontend/viewable-ui/.gitignore vendored Normal file
View File

@ -0,0 +1,26 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*
node_modules
dist
public/data/*
dist-ssr
*.local
# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
public/data