Exemplo n.º 1
0
 def post(request: Request):
     if not request.user.is_authenticated:
         return NotAuthenticatedResponse()
     serial = CollectionGeneralInfo(data=request.data)
     if serial.is_valid():
         serial.save()
         return OKResponse(serial.data)
     else:
         return BadRequestResponse(serial.errors)
Exemplo n.º 2
0
 def delete(request, collection_id):
     if not request.user.is_authenticated:
         return NotAuthenticatedResponse()
     if not (collection := find_collection(collection_id)):
         return NotFoundResponse("collection", collection_id.__str__())
Exemplo n.º 3
0
 def get(request, collection_id):
     if not request.user.is_authenticated:
         return NotAuthenticatedResponse()
     if not (collection := find_collection(collection_id)):
         return NotFoundResponse('collection', collection_id)
Exemplo n.º 4
0
 def get(request):
     if request.user.is_authenticated:
         serial = CollectionGeneralInfo(Collection.objects.all(), many=True)
         return OKResponse(serial.data)
     else:
         return NotAuthenticatedResponse()
Exemplo n.º 5
0
from note.responses import NotAuthenticatedResponse, OKResponse, BadRequestResponse


class __RequestToken(APIView):
    @staticmethod
    def get(request: Request):
        if (r_user := request.user).is_authenticated:
            try:
                inv_token = InvitationToken.objects.get(user=r_user)
            except:
                t = uuid.uuid4().__str__().lower()
                inv_token = InvitationToken.objects.create(token=t,
                                                           user=r_user)
            return OKResponse(data={"token": inv_token.token})
        else:
            return NotAuthenticatedResponse()


class __RegisterAPIView(APIView):
    @staticmethod
    def post(request: Request):
        try:
            inv_token: str = request.data.get('inv_code')
            errors = []
            if not inv_token:
                errors.append("invitation token not valid")

            username: str = request.data.get('username')
            if not username:
                errors.append("username not valid")