Ejemplo n.º 1
0
 def new_thread(self, req):
     group = self.group
     thread_title = req.get_form_var("title", '').strip()
     text = req.get_form_var("update_text", '').strip()
     upload_file = req.get_form_var("update_file", None)
     error = None
     if req.get_method() == "POST" and req.user:
         if not thread_title or not text:
             error = "no_data"
         if error is None:
             filename = ''
             ftype = ''
             if upload_file:
                 filename = upload_file.tmp_filename
                 ftype = upload_file.content_type
             id = Thread.new(req.user.id, group.id, thread_title, text, filename, ftype)
             if id:
                 return req.redirect("/thread/%s/" % id)
     return st('/thread/create.html', **locals())
Ejemplo n.º 2
0
 def remove(self, req):
     if req.user and req.user.id == self.thread.user_id:
         group = self.thread.group
         Thread.remove(self.thread.id, req.user.id)
         return req.redirect("/")
     return AccessError("need permission")
Ejemplo n.º 3
0
def _q_lookup(req, id):
    thread = Thread.get(id)
    if thread:
        return ThreadUI(req, thread)
    return TraversalError("no such thread")