コード例 #1
0
def todo_done(request, pk):

    #Retrieve, update or delete a code snippet.
    key_idsession_f = request.GET.get("idsession")

    try:
        company = CompanyName.objects.get(name=pk)
    except CompanyName.DoesNotExist:
        return Response(status=status.HTTP_404_NOT_FOUND)

    try:
        due_date_f = request.GET.get("due_date")
        task_f = request.GET.get("task")
        desks = Desks.objects.get(due_date=due_date_f, task=task_f)
    except Desks.DoesNotExist:
        return Response(status=status.HTTP_404_NOT_FOUND)

    if myfunctions.check_auth(key_idsession_f, company.name):
        if request.method == 'PUT':
            modProfile = Profile.objects.get(idsession=key_idsession_f)
            user_obj = User.objects.get(username=modProfile.user)

            desks.done = True
            desks.executor = user_obj.username
            desks.save()

            serializer = DesksSerializer(desks)
            return Response(serializer.data)

    else:
        return Response('You must log in to this company',
                        status=status.HTTP_400_BAD_REQUEST)
コード例 #2
0
def todo_detail(request, pk):

    #Retrieve, update or delete a code snippet.
    key_idsession_f = request.GET.get("idsession")

    try:
        company = CompanyName.objects.get(name=pk)
    except CompanyName.DoesNotExist:
        return Response(status=status.HTTP_404_NOT_FOUND)

    try:
        due_date_f = request.GET.get("due_date")
        desks = Desks.objects.filter(due_date=due_date_f)
    except Desks.DoesNotExist:
        return Response(status=status.HTTP_404_NOT_FOUND)

    if myfunctions.check_auth(key_idsession_f, company.name):
        if request.method == 'GET':

            desks = Desks.objects.filter(company_name=company.id,
                                         due_date=due_date_f)
            serializer = DesksSerializer(desks, many=True)
            return Response(serializer.data)

    else:
        return Response('You must log in to this company',
                        status=status.HTTP_400_BAD_REQUEST)
コード例 #3
0
def company_todo(request, pk):

    try:
        company = CompanyName.objects.get(name=pk)
    except CompanyName.DoesNotExist:
        return Response(status=status.HTTP_404_NOT_FOUND)

    if request.method == 'GET':
        key_idsession_f = request.GET.get("idsession")

        if myfunctions.check_auth(key_idsession_f, company.name):
            desks = Desks.objects.filter(company_name=company.id)
            serializer = DesksSerializer(desks, many=True)
            return Response(serializer.data)
        else:
            return Response('You must log in to this company',
                            status=status.HTTP_400_BAD_REQUEST)