def post(self, vanity_url=None, operation=None, key=None): provider = db.get_provider_from_vanity_url(vanity_url) service_form = ProviderServiceForm().get_form(self.request.POST) if service_form.validate(): if operation == "add": service_object = ProviderService() service_form.populate_obj(service_object) service_object.provider = provider.key service_object.put() if operation == "edit": service_object_key = ndb.Key(urlsafe=key) if service_object_key: service_object = service_object_key.get() service_form.populate_obj(service_object) service_object.put() self.redirect("/provider/profile/%s" % provider.vanity_url) else: profile_form = ProviderProfileForm().get_form(obj=provider) self.render_profile(provider, profile_form=profile_form, service_form=service_form)
def post(self, vanity_url=None, operation=None, key=None): provider = db.get_provider_from_vanity_url(vanity_url) service_form = ProviderServiceForm().get_form(self.request.POST) if service_form.validate(): if operation == 'add': service_object = ProviderService() service_form.populate_obj(service_object) service_object.provider = provider.key service_object.put() if operation == 'edit': service_object_key = ndb.Key(urlsafe=key) if service_object_key: service_object = service_object_key.get() service_form.populate_obj(service_object) service_object.put() self.redirect('/provider/profile/%s' % provider.vanity_url) else: profile_form = ProviderProfileForm().get_form(obj=provider) self.render_profile(provider, profile_form=profile_form, service_form=service_form)