Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ## Model
- db.define_table('staff_photographs',
- Field('created_on', 'datetime', default=request.now, readable=False, writable=False),
- Field('created_by', db.auth_user, default=auth.user_id, readable=False, writable=False),
- Field('staff_id', db.staff, readable=False, writable=False),
- Field('image','upload', uploadfolder=os.path.join(request.folder, 'staff_images')),
- Field('file_name', 'string', default='', readable=False, writable=False),
- Field('default_image', 'boolean', default=False),
- Field('tags', 'list:string'),
- )
- ## Controller
- def add_photograph():
- """
- Display a form asking for the path to upload, add photograph and then return
- to the index page
- """
- person=None
- staff_img_form=None
- if request.vars.has_key('staff_id'):
- person=db.staff(request.vars.staff_id)
- url=URL('default', 'download')
- staff_img_form=crud.create(db.staff_photographs)
- staff_img_form.vars.staff_id=person.id
- if staff_img_form.accepts(request.vars, session):
- img_id=staff_img_form.vars.id
- response.flash="%d updated" % img_id
- return dict(staff_img_form=staff_img_form, person=person)
Add Comment
Please, Sign In to add comment