Ejemplo n.º 1
0
 def post_page(self):
     import_members_form = ImportMembersForm(data=self.request.POST, files=self.request.FILES)
     try:
         imported, ignored, failed = issue = import_members_form.import_members()
         message = "Imported %s members, %s entries ignored, %s entries failed." \
                 % (imported, ignored, failed)
         logging.info(message)
         prompt = Prompt(info=message)
         redirect_url = "%s?%s" % (self.get_page_url(), prompt.urlencode())
         return HttpResponseRedirect(redirect_url)
     except Exception, exc:
         message = "Failed to import members: %s" % exc
         logging.error(message)
         logging.exception(exc)
         data = {"import_members_form": import_members_form}
         data = self.update_data(data)
         return render_to_response(self.get_page_template(), data, RequestContext(self.request))
Ejemplo n.º 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))