def get(self): models.newForum({ 'url' :'lobby', 'order' :1, 'title' :'Lobby', 'description':'Here you can ask any question or make any comment about the forum.' }) models.newForum({ 'url' :'events', 'order' :2, 'title' :'Events & Meetings', 'description':'Lets get together, gatherings, reunions or just for beers.' }) models.newForum({ 'url' :'developers', 'order' :3, 'title' :'Developers Hack', 'description':'Here we talk about code, programming techniques and everything hackish.' }) models.newForum({ 'url' :'designers', 'order' :4, 'title' :'Designers Den', 'description':'Themes, colors, palettes, tips and tricks for the creative minds.' }) self.redirect(app.root)
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
def get(self): models.newForum({ 'url': 'lobby', 'order': 1, 'title': 'Lobby', 'description': 'Here you can ask any question or make any comment about the forum.' }) models.newForum({ 'url': 'events', 'order': 2, 'title': 'Events & Meetings', 'description': 'Lets get together, gatherings, reunions or just for beers.' }) models.newForum({ 'url': 'developers', 'order': 3, 'title': 'Developers Hack', 'description': 'Here we talk about code, programming techniques and everything hackish.' }) models.newForum({ 'url': 'designers', 'order': 4, 'title': 'Designers Den', 'description': 'Themes, colors, palettes, tips and tricks for the creative minds.' }) self.redirect(app.root)
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