def post(self): # dateOfEntry = request.form['dateOfEntry'] # form = CreateOfferForm(data=request.get_json()) if not isSuperUser(): return notAuthorizedResponse() jsonData = request.get_json() offerForm = CreateOfferForm(data=jsonData) serviceOfferList = [] # return jsonData if "serviceOffers" in jsonData: for serviceOfferDict in jsonData["serviceOffers"]: servcieOfferForm = CreateServiceOfferForm() servcieOfferForm.process(data=serviceOfferDict); if servcieOfferForm.validate(): serviceOfferList.append( ServiceOffer(**servcieOfferForm.data) ) else: return unableToProcessResponse(servcieOfferForm.errors) # return [serviceOffer.price for serviceOffer in serviceOfferList], 400 # return jsonData["serviceOffers"], 400 if offerForm.validate() : entity = Offer(name=offerForm.data["name"], startDate=offerForm.data["startDate"], endDate= offerForm.data["endDate"], active=offerForm.data["active"], serviceOffers=serviceOfferList) offerRepo.save(entity) return createdResponseWithPayload(marshal(entity, offer_fields)) return unableToProcessResponse(offerForm.errors)
def post(self): return unableToProcessResponse(["NOT IMPLEMENTED YET"]) form = CreateOfferForm() if form.validate(): entity = Offer(**form.data) # serviceOfferRepo.save(entity) return createdResponseWithPayload(marshal(entity, serviceOffer_fields)) return unableToProcessResponse(form.errors)