Esempio n. 1
0
	def album_del(self, aid):
		album = s.query(Album).filter(Album.id == aid).first()
		if not album:
			abort(404)

		s.delete(album)
		s.commit()

		redirect(url(controller = "album",
					action = "show_first_page", aid = album.parent_id))
Esempio n. 2
0
	def photo_del_submit(self, aid, pid):
		photo_q = s.query(Photo)
		photo_obj = photo_q.filter_by(album_id=aid, id=pid).first()
		if photo_obj is None:
			c.name = pid
			return render('/photo_not_found.mako')

		s.delete(photo_obj)
		s.commit()

		redirect(url(controller = "album",
					action = "show_first_page", aid = aid))
Esempio n. 3
0
	def album_edit_submit(self, aid):
		if request.params.get("Cancel"):
			redirect(url(controller="album"))

		if request.params.get("new_album"):
			album = Album(parent_id = aid)
			s.add(album)
			s.commit()

		else:
			album = s.query(Album).filter(Album.id == aid).first()
			if not album:
				abort(404)

		album.name = request.params.get("name")
		album.display_name = request.params.get("title")
		album.descr = request.params.get("description")
		album.hidden = bool(request.params.get("hide_album", 0))
		album.sort_by = int(request.params.get("sort_by", 1))

		new_thumb = request.params.get('album_thumbnail')
		print new_thumb, repr(new_thumb)
		if type(new_thumb) is types.InstanceType:
			old_preview = album.preview

			# add preview
			name = new_thumb.filename.lstrip(os.sep)
			preview = Photo(name, album.id, new_thumb.file.read())
			new_thumb.file.close()
			preview.hidden = True
			s.add(preview)
			s.commit()

			album.preview_id = preview.id
			if old_preview:
				s.delete(old_preview)

		s.commit()

		redirect(url(controller = "album",
				action = "show_first_page", aid = aid))