def commitdel(album, req): s = DBSession() parent = album.parent s.delete(album) s.commit() return HTTPFound(location = req.resource_url(parent))
def photo_commitdel(photo, req): s = DBSession() album = photo.album s.delete(photo) s.commit() return HTTPFound(location = req.resource_url(album))
def commitdel(article, req): s = DBSession() s.delete(article) s.commit() return HTTPFound(location = req.resource_url(get_root()))
def commitedit(album, req): if not req.params.get("commit"): return HTTPFound(location = req.resource_url(album)) s = DBSession() if req.params.get("new_album"): a = Album(parent_id = album.id) s.add(a) s.commit() else: a = album a.display_name = req.params.get("title") a.descr = req.params.get("description") a.hidden = bool(req.params.get("hide_album", 0)) a.sort_by = int(req.params.get("sort_by", 1)) new_thumb = req.params.get('album_thumbnail') print new_thumb, repr(new_thumb) if type(new_thumb) is types.InstanceType: old_preview = a.preview # add preview name = new_thumb.filename.lstrip(os.sep) preview = Photo(name, a.id, new_thumb.file.read()) new_thumb.file.close() preview.hidden = True s.add(preview) s.commit() a.preview_id = preview.id if old_preview: s.delete(old_preview) s.commit() return HTTPFound(location = req.resource_url(a))