Beispiel #1
0
 def get(self,fid):
   user = users.get_current_user()
   data={
     'forum':models.getForum(fid),
     'author':utils.getNick(user.nickname())
   }
   self.show('topics_new',data)
Beispiel #2
0
 def get(self, fid):
     user = users.get_current_user()
     data = {
         'forum': models.getForum(fid),
         'author': utils.getNick(user.nickname())
     }
     self.show('topics_new', data)
Beispiel #3
0
def newTopic(request,fid):
  form   = Form()
  fields = request.getForm()
  user   = users.get_current_user()
  uid    = user.user_id()

  # sanitize
  title  = utils.toStr(fields.get('title',''),80)
  imp    = utils.toInt(fields.get('importance','0'))
  author = utils.toStr(fields.get('author',''),40)
  email  = fields.get('email')
  url    = fields.get('url')
  content= utils.toTxt(fields.get('content',''),9000)

  # validate
  ok=True
  warn=[]
  if email or url:
    form.ok=False
    form.redirect=True
    form.url='%s/%s'%(app.root,fid)
    return form
  if not title:
    warn.append('Title can not be empty')
    ok=False
  if title==title.upper():
    warn.append('Title can not be all caps')
    ok=False
  if not author:
    warn.append('You need to identify as the author')
    ok=False
  if author==author.upper():
    warn.append('Author can not be all caps')
    ok=False
  if not content:
    warn.append('You must enter some content')
    ok=False
  if content==content.upper():
    warn.append('Content can not be all caps')
    ok=False
  if ok:
    dat1 = {'forumid':fid,'title':title,'userid':str(uid),'author':author,'importance':imp}
    rec1 = models.newTopic(dat1)
    tid  = rec1.topicid
    dat2 = {'topicid':tid,'forumid':fid,'userid':str(uid),'author':author,'content':content}
    rec2 = models.newMessage(dat2)
    form.ok  = True
    form.url = '%s/%s/%s'%(app.root,fid,tid)
  else:
    form.ok   = False
    form.warn = warn
    form.data = {
      'forum'  :models.getForum(fid),
      'warn'   :warn,
      'title'  :title,
      'author' :author,
      'content':content
    }
  return form
Beispiel #4
0
def messages(request, fid, tid):
    form = Form()
    fields = request.getForm()
    user = users.get_current_user()
    uid = user.user_id()

    # sanitize
    author = utils.toStr(fields.get('author', 'Anonymous'), 40)
    email = fields.get('email')
    url = fields.get('url')
    content = utils.toTxt(fields.get('content', ''), 9000)

    # validate
    ok = True
    warn = []
    if email or url or 'http' in content:
        form.ok = False
        form.redirect = True
        form.url = '%s/%s/%s' % (app.root, fid, tid)
        return form
    if not author:
        warn.append('You need to identify yourself as the author')
        ok = False
    if author == author.upper():
        warn.append('Author can not be all caps')
        ok = False
    if not content:
        warn.append('You must enter some content')
        ok = False
    if content == content.upper():
        warn.append('Content can not be all caps')
        ok = False

    # process
    if ok:
        form.ok = True
        form.url = '%s/%s/%s' % (app.root, fid, tid)
        data = {
            'topicid': tid,
            'forumid': fid,
            'userid': str(uid),
            'author': author,
            'content': content
        }
        models.newMessage(data)
    else:
        form.ok = False
        form.warn = warn
        form.data = {
            'forum': models.getForum(fid),
            'topic': models.getTopic(tid),
            'list': models.getMessages(tid),
            'warn': warn,
            'author': author,
            'content': content
        }
    return form
Beispiel #5
0
def newForum(request):
    form = Form()
    fields = request.getForm()

    # sanitize
    title = utils.toStr(fields.get('title', ''), 80)
    desc = utils.toStr(fields.get('desc', ''), 120)
    url = utils.idify(fields.get('url', ''), 40)
    order = utils.toInt(fields.get('order'))

    # validate
    ok = True
    warn = []
    if not url:
        warn.append('Forum needs a permalink')
        ok = False
    if not title:
        warn.append('Title can not be empty')
        ok = False
    if title == title.upper():
        warn.append('Title can not be all caps')
        ok = False
    if not desc:
        warn.append('You must enter some description')
        ok = False
    if desc == desc.upper():
        warn.append('Description can not be all caps')
        ok = False
    if ok:
        if not order: order = models.getNextOrder()
        data = {
            'url': url,
            'title': title,
            'description': desc,
            'order': order
        }
        rec = models.newForum(data)
        form.ok = True
        form.url = '%s/admin/forum' % (app.root)
        form.redirect = True
    else:
        form.ok = False
        form.warn = warn
        form.data = {
            'forum': models.getForum(fid),
            'warn': warn,
            'title': title,
            'author': author,
            'content': content
        }
    return form
Beispiel #6
0
def messages(request,fid,tid):
  form   = Form()
  fields = request.getForm()
  user   = users.get_current_user()
  uid    = user.user_id()

  # sanitize
  author = utils.toStr(fields.get('author','Anonymous'),40)
  email  = fields.get('email')
  url    = fields.get('url')
  content= utils.toTxt(fields.get('content',''),9000)

  # validate
  ok=True
  warn=[]
  if email or url or 'http' in content:
    form.ok=False
    form.redirect=True
    form.url='%s/%s/%s'%(app.root,fid,tid)
    return form
  if not author:
    warn.append('You need to identify yourself as the author')
    ok=False
  if author==author.upper():
    warn.append('Author can not be all caps')
    ok=False
  if not content:
    warn.append('You must enter some content')
    ok=False
  if content==content.upper():
    warn.append('Content can not be all caps')
    ok=False

  # process
  if ok:
    form.ok   = True
    form.url  = '%s/%s/%s'%(app.root,fid,tid)
    data      = {'topicid':tid,'forumid':fid,'userid':str(uid),'author':author,'content':content}
    models.newMessage(data)
  else:
    form.ok   = False
    form.warn = warn
    form.data = {
      'forum'  :models.getForum(fid),
      'topic'  :models.getTopic(tid),
      'list'   :models.getMessages(tid),
      'warn'   :warn,
      'author' :author,
      'content':content
    }
  return form
Beispiel #7
0
def newForum(request):
  form   = Form()
  fields = request.getForm()

  # sanitize
  title = utils.toStr(fields.get('title',''), 80)
  desc  = utils.toStr(fields.get('desc' ,''),120)
  url   = utils.idify(fields.get('url'  ,''), 40)
  order = utils.toInt(fields.get('order'))

  # validate
  ok=True
  warn=[]
  if not url:
    warn.append('Forum needs a permalink')
    ok=False
  if not title:
    warn.append('Title can not be empty')
    ok=False
  if title==title.upper():
    warn.append('Title can not be all caps')
    ok=False
  if not desc:
    warn.append('You must enter some description')
    ok=False
  if desc==desc.upper():
    warn.append('Description can not be all caps')
    ok=False
  if ok:
    if not order: order=models.getNextOrder()
    data = {'url':url,'title':title,'description':desc,'order':order}
    rec  = models.newForum(data)
    form.ok  = True
    form.url = '%s/admin/forum'%(app.root)
    form.redirect = True
  else:
    form.ok   = False
    form.warn = warn
    form.data = {
      'forum'  :models.getForum(fid),
      'warn'   :warn,
      'title'  :title,
      'author' :author,
      'content':content
    }
  return form
Beispiel #8
0
 def get(self,fid):
   forum  = models.getForum(fid)
   topics = models.getTopics(fid)
   data   = {'forum':forum,'list':topics}
   self.show('topics',data)
Beispiel #9
0
 def get(self, fid):
     forum = models.getForum(fid)
     topics = models.getTopics(fid)
     data = {'forum': forum, 'list': topics}
     self.show('topics', data)
Beispiel #10
0
def newTopic(request, fid):
    form = Form()
    fields = request.getForm()
    user = users.get_current_user()
    uid = user.user_id()

    # sanitize
    title = utils.toStr(fields.get('title', ''), 80)
    imp = utils.toInt(fields.get('importance', '0'))
    author = utils.toStr(fields.get('author', ''), 40)
    email = fields.get('email')
    url = fields.get('url')
    content = utils.toTxt(fields.get('content', ''), 9000)

    # validate
    ok = True
    warn = []
    if email or url:
        form.ok = False
        form.redirect = True
        form.url = '%s/%s' % (app.root, fid)
        return form
    if not title:
        warn.append('Title can not be empty')
        ok = False
    if title == title.upper():
        warn.append('Title can not be all caps')
        ok = False
    if not author:
        warn.append('You need to identify as the author')
        ok = False
    if author == author.upper():
        warn.append('Author can not be all caps')
        ok = False
    if not content:
        warn.append('You must enter some content')
        ok = False
    if content == content.upper():
        warn.append('Content can not be all caps')
        ok = False
    if ok:
        dat1 = {
            'forumid': fid,
            'title': title,
            'userid': str(uid),
            'author': author,
            'importance': imp
        }
        rec1 = models.newTopic(dat1)
        tid = rec1.topicid
        dat2 = {
            'topicid': tid,
            'forumid': fid,
            'userid': str(uid),
            'author': author,
            'content': content
        }
        rec2 = models.newMessage(dat2)
        form.ok = True
        form.url = '%s/%s/%s' % (app.root, fid, tid)
    else:
        form.ok = False
        form.warn = warn
        form.data = {
            'forum': models.getForum(fid),
            'warn': warn,
            'title': title,
            'author': author,
            'content': content
        }
    return form