Fixed up the API a lil bit

This commit is contained in:
root 2021-08-14 14:17:11 +00:00
parent bb221f7ee0
commit bfbf4fe5f7
64 changed files with 145 additions and 12 deletions

View File

@ -6,8 +6,15 @@ from users.models import Balance
from upload.models import Media from upload.models import Media
from .serializers import BalanceSerializer, ImageSerializer from .serializers import BalanceSerializer, ImageSerializer
class AllBalance(viewsets.ModelViewSet):
serializer_class = BalanceSerializer
http_method_names = ['get']
def get_queryset(self):
return Balance.objects.all()
class BalanceView(viewsets.ModelViewSet): class BalanceView(viewsets.ModelViewSet):
permission_classes = [permissions.IsAuthenticated]
serializer_class = BalanceSerializer serializer_class = BalanceSerializer
http_method_names = ['get'] http_method_names = ['get']
@ -16,7 +23,6 @@ class BalanceView(viewsets.ModelViewSet):
class ImageView(viewsets.ModelViewSet): class ImageView(viewsets.ModelViewSet):
permission_classes = [permissions.IsAuthenticated]
serializer_class = ImageSerializer serializer_class = ImageSerializer
http_method_names = ['get','post'] http_method_names = ['get','post']

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

View File

@ -0,0 +1,134 @@
.popup{
width: 900px;
margin: auto;
text-align: center
}
.popup img{
width: 200px;
height: 200px;
cursor: pointer
}
.show{
z-index: 999;
display: none;
}
.show .overlay{
width: 100%;
height: 100%;
background: rgba(0,0,0,.66);
position: absolute;
top: 0;
left: 0;
}
.show .img-show{
width: 600px;
height: 400px;
background: #FFF;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%,-50%);
overflow: hidden
}
.img-show span{
position: absolute;
top: 10px;
right: 10px;
z-index: 99;
cursor: pointer;
}
.img-show img{
width: 100%;
height: 100%;
position: absolute;
top: 0;
left: 0;
}
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
body {
font-family: Raleway;
background-color: #202125;
}
.heading {
text-align: center;
font-size: 2.0em;
letter-spacing: 1px;
padding: 40px;
color: white;
}
.gallery-image {
padding: 20px;
display: flex;
flex-wrap: wrap;
justify-content: center;
}
.gallery-image img {
height: 250px;
width: 350px;
transform: scale(1.0);
transition: transform 0.4s ease;
}
.img-box {
box-sizing: content-box;
margin: 10px;
height: 250px;
width: 350px;
overflow: hidden;
display: inline-block;
color: white;
position: relative;
background-color: white;
}
.caption {
position: absolute;
bottom: 5px;
left: 20px;
opacity: 0.0;
transition: transform 0.3s ease, opacity 0.3s ease;
}
.transparent-box {
height: 250px;
width: 350px;
background-color:rgba(0, 0, 0, 0);
position: absolute;
top: 0;
left: 0;
transition: background-color 0.3s ease;
}
.img-box:hover img {
transform: scale(1.1);
}
.img-box:hover .transparent-box {
background-color:rgba(0, 0, 0, 0.5);
}
.img-box:hover .caption {
transform: translateY(-20px);
opacity: 1.0;
}
.img-box:hover {
cursor: pointer;
}
.caption > p:nth-child(2) {
font-size: 0.8em;
}
.opacity-low {
opacity: 0.5;
}

View File

@ -26,7 +26,7 @@ BASE_DIR = Path(__file__).resolve().parent.parent
SECRET_KEY = '&(v*@m-bz2n9kki!2y)qo5ipp-v+!vfpb4cj=l6n93y&18jht*' SECRET_KEY = '&(v*@m-bz2n9kki!2y)qo5ipp-v+!vfpb4cj=l6n93y&18jht*'
# SECURITY WARNING: don't run with debug turned on in production! # SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True DEBUG = False
ALLOWED_HOSTS = [ ALLOWED_HOSTS = [
"cleener.xyz", "cleener.xyz",
@ -150,13 +150,7 @@ os.environ["DJANGO_ALLOW_ASYNC_UNSAFE"] = "true"
REST_FRAMEWORK = { REST_FRAMEWORK = {
'DEFAULT_PERMISSION_CLASSES': [
'rest_framework.permissions.IsAuthenticated',
],
'DEFAULT_AUTHENTICATION_CLASSES': [ 'DEFAULT_AUTHENTICATION_CLASSES': [
'rest_framework.authentication.BasicAuthentication',
'rest_framework.authentication.SessionAuthentication',
'rest_framework.authentication.TokenAuthentication', 'rest_framework.authentication.TokenAuthentication',
] ]

View File

@ -17,7 +17,7 @@ from django.contrib import admin
from django.urls import path, include from django.urls import path, include
from home.views import homePage, leaderboard from home.views import homePage, leaderboard
from rest_framework import routers, urls from rest_framework import routers, urls
from api.views import BalanceView, ImageView from api.views import BalanceView, ImageView, AllBalance
from django.conf import settings from django.conf import settings
from django.conf.urls.static import static from django.conf.urls.static import static
from django.contrib.auth import views from django.contrib.auth import views
@ -29,7 +29,7 @@ from users.views import getBalance, addToBalance, adminView, removeBalance
router = routers.DefaultRouter() router = routers.DefaultRouter()
router.register("balance", BalanceView, basename="balance") router.register("balance", BalanceView, basename="balance")
router.register("images", ImageView, basename="image") router.register("images", ImageView, basename="image")
router.register("every_balance", AllBalance, basename="all_balance")
urlpatterns = [ urlpatterns = [
path("", homePage, name='home'), path("", homePage, name='home'),

View File

@ -1,6 +1,5 @@
asgiref==3.3.1 asgiref==3.3.1
Django==3.1.6 Django==3.1.6
django-menus==1.1.2
django-qr-code==2.2.0 django-qr-code==2.2.0
djangorestframework==3.12.4 djangorestframework==3.12.4
Pillow==8.1.0 Pillow==8.1.0