|
|
|
@ -17,7 +17,7 @@ from photoapp.utils import auth, require_auth, photoset_auth_filter, slugify, ch
|
|
|
|
|
from photoapp.storage import uri_to_storage
|
|
|
|
|
from photoapp.webutils import validate_password, serve_thumbnail_placeholder
|
|
|
|
|
from jinja2 import Environment, FileSystemLoader, select_autoescape
|
|
|
|
|
from sqlalchemy import desc, func, and_, or_
|
|
|
|
|
from sqlalchemy import desc, asc, func, and_, or_
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class PhotosWeb(object):
|
|
|
|
@ -322,7 +322,30 @@ class PhotoView(object):
|
|
|
|
|
PhotoSet.slug == uuid)).first()
|
|
|
|
|
if not photo:
|
|
|
|
|
raise cherrypy.HTTPError(404)
|
|
|
|
|
yield self.master.render("photo.html", image=photo)
|
|
|
|
|
|
|
|
|
|
if photo.lat:
|
|
|
|
|
nearby_photos = photoset_auth_filter(db.query(PhotoSet)) \
|
|
|
|
|
.filter(PhotoSet.lat.isnot(None)) \
|
|
|
|
|
.filter(PhotoSet.lon.isnot(None)) \
|
|
|
|
|
.filter(PhotoSet.id != photo.id) \
|
|
|
|
|
.order_by(func.sqrt(func.pow(PhotoSet.lat - photo.lat, 2) +
|
|
|
|
|
func.pow(PhotoSet.lon - photo.lon, 2))) \
|
|
|
|
|
.limit(25).all()
|
|
|
|
|
else:
|
|
|
|
|
nearby_photos = []
|
|
|
|
|
|
|
|
|
|
before = photoset_auth_filter(db.query(PhotoSet)) \
|
|
|
|
|
.filter(PhotoSet.date > photo.date) \
|
|
|
|
|
.order_by(PhotoSet.date.asc()) \
|
|
|
|
|
.limit(13).all()
|
|
|
|
|
before.reverse()
|
|
|
|
|
recent_photos = before + \
|
|
|
|
|
photoset_auth_filter(db.query(PhotoSet)) \
|
|
|
|
|
.filter(PhotoSet.date <= photo.date) \
|
|
|
|
|
.order_by(PhotoSet.date.desc()) \
|
|
|
|
|
.limit(12).all()
|
|
|
|
|
|
|
|
|
|
yield self.master.render("photo.html", image=photo, nearby=nearby_photos, recent=recent_photos)
|
|
|
|
|
|
|
|
|
|
@cherrypy.expose
|
|
|
|
|
@require_auth
|
|
|
|
|