UI and Backend polish
This commit is contained in:
parent
3042ed9722
commit
a289696ad3
2
backend/.gitignore
vendored
2
backend/.gitignore
vendored
@ -13,6 +13,8 @@ media
|
||||
.idea
|
||||
deploy
|
||||
media
|
||||
static
|
||||
templates
|
||||
|
||||
# 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.
|
||||
|
||||
@ -1,11 +1,15 @@
|
||||
import os
|
||||
import shutil
|
||||
#######################Django related imports####################
|
||||
from rest_framework import generics, status
|
||||
from rest_framework.views import APIView
|
||||
from rest_framework.response import Response
|
||||
from django.conf import settings
|
||||
#################################################################
|
||||
#API related imports
|
||||
from .models import (
|
||||
Category,
|
||||
Category,
|
||||
Blog
|
||||
)
|
||||
from .serializers import (
|
||||
CategorySerializer,
|
||||
@ -27,9 +31,23 @@ class CategoryListAPIView(generics.ListAPIView):
|
||||
serializer_class = CategorySerializer
|
||||
|
||||
class CategoryDeleteAPIView(generics.DestroyAPIView):
|
||||
queryset = Category.objects.all()
|
||||
serializer_class = CategorySerializer
|
||||
lookup_field = 'category_id'
|
||||
queryset = Category.objects.all()
|
||||
serializer_class = CategorySerializer
|
||||
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):
|
||||
def get(self, request, category_id):
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
import os
|
||||
import shutil
|
||||
import random
|
||||
from rest_framework import status
|
||||
from rest_framework.views import APIView
|
||||
|
||||
@ -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+'
|
||||
|
||||
# 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']
|
||||
|
||||
|
||||
@ -37,8 +37,9 @@ from apimanager.publish_views import (
|
||||
)
|
||||
|
||||
urlpatterns = [
|
||||
|
||||
# API Views
|
||||
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/update/user-data/', UserDataUpdateAPIView.as_view(), name='user-data-update-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/publish/methods/', PublishMethods.as_view(), name='publish-methods'),
|
||||
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.STATIC_URL, document_root=settings.STATIC_ROOT)
|
||||
@ -1,4 +1,4 @@
|
||||
from django.shortcuts import render
|
||||
|
||||
def index(request):
|
||||
def index(request, website_slug=None):
|
||||
return render(request, "index.html")
|
||||
26
frontend/viewable-ui/.gitignore
vendored
Normal file
26
frontend/viewable-ui/.gitignore
vendored
Normal 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
|
||||
Loading…
Reference in New Issue
Block a user