Example #1
0
 def post_page(self):
     self._check_edit_access()
     activity_form = ActivityForm(data=self.request.POST, instance=self.get_activity())
     try:
         activity = activity_form.update()
         message = "Activity #%s has been updated successfully." % activity.id
         logging.info(message)
         redirect_url = ViewActivity.get_page_url(
             group_uid=activity.group.uid,
             activity_id=activity.id
         )
         return HttpResponseRedirect(redirect_url)
     except Exception, exc:
         message = "Failed to update activity in datastore: %s" % exc
         logging.error(message)
         logging.exception(exc)
         data = {"activity_form": activity_form, "prompt": Prompt(error=message)}
         data = self.update_data(data)
         return render_to_response(self.get_page_template(), data, RequestContext(self.request))
Example #2
0
 def post_page(self):
     self._check_create_access()
     activity_form = ActivityForm(data=self.request.POST)
     try:
         activity = activity_form.create(group=self.get_group(), submitter=self.current_user)
         message = "Activity #%d has been created successfully." % activity.id
         logging.info(message)
         activity_created(activity)
         prompt = Prompt(info=message)
         redirect_url = ViewActivity.get_page_url(
             group_uid=self.get_group().uid,
             activity_id=activity.id
         )
         redirect_url += "?" + prompt.urlencode()
         return HttpResponseRedirect(redirect_url)
     except Exception, exc:
         message = "Failed to create activity in datastore: %s" % exc
         logging.error(message)
         logging.exception(exc)
         data = {"activity_form": activity_form, "prompt": Prompt(error=message)}
         data = self.update_data(data)
         return render_to_response(self.get_page_template(), data, RequestContext(self.request))