Guest User

Untitled

a guest
Jun 14th, 2018
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. def index():
  2. redirect(URL(r=request, f='shouts'))
  3.  
  4.  
  5. def shouts():
  6.  
  7. form = SQLFORM(db.shout, fields=['body','category'])
  8.  
  9. if form.accepts(request.vars, session):
  10. redirect(URL(r=request, f='shouts'))
  11.  
  12. if form.errors: response.flash = 'Oops! Try that again'
  13.  
  14. rows = db().select(db.shout.ALL)
  15.  
  16. return dict(form=form, shouts=rows)
  17.  
  18. def show():
  19. id = request.vars.id
  20. rows = db(db.shout.id==id).select()
  21.  
  22. if len(rows)==0:
  23. redirect(URL(r=request, f='shouts'))
  24. return dict(shout=rows[0])
  25.  
  26.  
  27. ##NEW SHOUT
  28. @auth.requires_login()
  29. def newshout():
  30.  
  31. form = SQLFORM(db.shout, fields=['body','category'])
  32.  
  33. if form.accepts(request.vars, session):
  34. redirect(URL(r=request, f='shouts'))
  35.  
  36. if form.errors: response.flash = 'Oops! Try that again'
  37.  
  38. return dict(form=form)
  39.  
  40.  
  41. # # uncomment the following if you have defined "auth" and "crud" in models
  42. def user(): return dict(form=auth())
  43. def data(): return dict(form=crud())
  44. # def download(): return response.download(request,db)
  45. # # tip: use @auth.requires
Add Comment
Please, Sign In to add comment