Ejemplo n.º 1
0
def edit_business_contact_profile_data(request):
    business = request.user.business
    data = querydict_to_dict(request.POST)
    print(data)
    edit_business_profile_contact(business=business, data=data)
    return Response(
        {"message": "Profile business contact has been edited successfuly"},
        status=200)
Ejemplo n.º 2
0
def edit_offer(request, offer_id: str):
    data = querydict_to_dict(request.POST)
    image = request.FILES.get("image")
    business = request.user.business
    print(data)
    try:
        offer = edit_offer_by_id_secured(data=data,
                                         image=image,
                                         offer_id=offer_id,
                                         business=business)
    except Offer.DoesNotExist:
        return Response(
            {"message": f"Offer with id-{offer_id} does not exist"},
            status=404)
    except PermissionError:
        return Response({"message": "You are not allowed to edit this offer"},
                        status=403)

    return Response({"message": "You have edited your offer"}, status=200)
Ejemplo n.º 3
0
def register_account(request):
    account_type = request.POST.get("accountType")
    print(request.POST)
    print(request.FILES)
    print(account_type)
    data = querydict_to_dict(request.POST)
    if account_type == "blogger":
        register_blogger(data=data, image=request.FILES.get("image"))
        return Response(
            {"message": "Blogger account was created successfully"},
            status=201)
    elif account_type == "business":
        register_business(data=data, image=request.FILES.get("image"))
        return Response(
            {"message": "Business account was created successfully"},
            status=201)
    else:
        return Response(
            {"message": "Specify type of account you want to register"},
            status=404)
Ejemplo n.º 4
0
def create_offer(request):
    data = querydict_to_dict(request.POST)
    image = request.FILES.get("image")
    business = request.user.business
    create_new_offer(data=data, image=image, business=business)
    return Response({"message": "You have created new offer"}, 201)