예제 #1
0
 def post_page(self):
     self._check_create_access()
     resto_form = RestoForm(data=self.request.POST)
     try:
         resto = resto_form.create(submitter=self.current_user)
         redirect_url = ViewResto.get_page_url(resto_id=resto.id)
         return HttpResponseRedirect(redirect_url)
     except Exception, exc:
         message = "Failed to create resto in datastore: %s" % exc
         logging.error(message)
         logging.exception(exc)
         data = {"resto_form": resto_form, "prompt": Prompt(error=message)}
         data = self.update_data(data)
         return render_to_response(self.get_page_template(), data, RequestContext(self.request))
예제 #2
0
 def post_page(self):
     self._check_edit_access()
     resto_form = RestoForm(data=self.request.POST, instance=self.get_resto())
     try:
         resto = resto_form.update(updater=self.current_user)
         message = "Resto %s has been updated successfully." % resto.id
         logging.info(message)
         redirect_url = ViewResto.get_page_url(resto_id=resto.id)
         return HttpResponseRedirect(redirect_url)
     except Exception, exc:
         message = "Failed to update resto in datastore: %s" % exc
         logging.error(message)
         logging.exception(exc)
         data = {"resto_form": resto_form, "prompt": Prompt(error=message)}
         data = self.update_data(data)
         return render_to_response(self.get_page_template(), data, RequestContext(self.request))