Réarrangement du code; correction css; écriture uniquement du nouveau message

This commit is contained in:
2023-12-19 11:27:18 +01:00
parent fb0f9be103
commit acba77e228
27 changed files with 166 additions and 129 deletions

View File

@ -4,6 +4,7 @@ from django.contrib.auth.models import User
from django.db.models.signals import post_save
from django.dispatch import receiver
from django.conf import settings
from django.db.models import IntegerField
def upload_to(instance, filename: str):
return f"./profiles/static/avatars/{instance.pk}.{filename.split('.')[1]}"
@ -17,4 +18,11 @@ class ProfileModel(models.Model):
def on_user_created(sender, instance, created, **kwargs):
if created:
profile: ProfileModel = ProfileModel.objects.create(pk = instance.pk, user = instance)
profile.save()
profile.save()
class BlockModel(models.Model):
blocker = IntegerField(primary_key=False)
blocked = IntegerField(primary_key=False)
def __str__(self):
return "blocker_id: " + str(self.blocker) + ", blocked_id: " + str(self.blocked)

View File

@ -3,9 +3,11 @@ from django.conf import settings
from django.conf.urls.static import static
from . import viewsets
from . import views
urlpatterns = [
path("me", viewsets.MyProfileViewSet.as_view({'patch': 'partial_update', 'get': 'retrieve'}), name="my_profile_page"),
path("<int:pk>", viewsets.ProfileViewSet.as_view({'get': 'retrieve'}), name="profile_page"),
path("", viewsets.ProfileViewSet.as_view({'get': 'list'}), name="profiles_list"),
] + static("/static/avatars/", document_root="./avatars")
path("block", views.BlockView.as_view(), name="block_page"),
] + static("/static/avatars/", document_root="./avatars")

18
profiles/views.py Normal file
View File

@ -0,0 +1,18 @@
from rest_framework.views import APIView
from rest_framework.response import Response
from rest_framework import authentication, permissions, status
from rest_framework.authentication import SessionAuthentication
from django.core import serializers
class BlockView(APIView):
permission_classes = (permissions.IsAuthenticated,)
authentication_classes = (SessionAuthentication,)
def post(self, request, pk):
pass
def get(self, request, pk):
pass
def delete(self, request, pk):
pass