示例#1
0
def photo_commitdel(photo, req):
	s = DBSession()

	album = photo.album
	s.delete(photo)
	s.commit()
	return HTTPFound(location = req.resource_url(album))
示例#2
0
def commitdel(album, req):
	s = DBSession()

	parent = album.parent
	s.delete(album)
	s.commit()
	return HTTPFound(location = req.resource_url(parent))
def commitdel(article, req):
	s = DBSession()

	s.delete(article)
	s.commit()

	return HTTPFound(location = req.resource_url(get_root()))
示例#4
0
def photo_commitedit(photo, req):
	if not req.params.get("commit"):
		return HTTPFound(location = req.resource_url(photo.album))

	s = DBSession()
	photo.display_name = req.params.get("title")
	photo.hidden = bool(req.params.get("hide_photo", 0))
	s.commit()

	return HTTPFound(location = req.resource_url(photo.album))
def commitedit(context, req):
	s = DBSession()

	if not req.params.get("commit"):
		return HTTPFound(location = req.resource_url(get_root()))

	if req.params.get("new_article"):
		a = Article()
		s.add(a)
	else:
		a = context
	a.title = req.params.get("title", "")
	a.body = req.params.get("body", "")
	s.commit()

	return HTTPFound(location = req.resource_url(a))
示例#6
0
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))