support offsetting photo dates
This commit is contained in:
parent
0789de35ff
commit
3900075ab4
|
@ -286,7 +286,7 @@ class TagView(object):
|
||||||
s = self.master.session()
|
s = self.master.session()
|
||||||
tag = s.query(Tag).filter(Tag.uuid == uuid).first()
|
tag = s.query(Tag).filter(Tag.uuid == uuid).first()
|
||||||
numphotos = s.query(func.count(Tag.id)).join(TagItem).join(PhotoSet).filter(Tag.uuid == uuid).scalar()
|
numphotos = s.query(func.count(Tag.id)).join(TagItem).join(PhotoSet).filter(Tag.uuid == uuid).scalar()
|
||||||
photos = s.query(PhotoSet).join(TagItem).join(Tag).filter(Tag.uuid == uuid).offset(page * pgsize).limit(pgsize).all()
|
photos = s.query(PhotoSet).join(TagItem).join(Tag).filter(Tag.uuid == uuid).order_by(PhotoSet.date.desc()).offset(page * pgsize).limit(pgsize).all()
|
||||||
yield self.master.render("album.html", tag=tag, images=photos, total_items=numphotos, pgsize=100, page=page)
|
yield self.master.render("album.html", tag=tag, images=photos, total_items=numphotos, pgsize=100, page=page)
|
||||||
|
|
||||||
@cherrypy.expose
|
@cherrypy.expose
|
||||||
|
|
|
@ -26,7 +26,7 @@ def get_jpg_info(fpath):
|
||||||
|
|
||||||
photo = Photo(hash=get_hash(fpath), path=fpath, format=mime, size=size,
|
photo = Photo(hash=get_hash(fpath), path=fpath, format=mime, size=size,
|
||||||
width=dimensions[0], height=dimensions[1], orientation=orientation)
|
width=dimensions[0], height=dimensions[1], orientation=orientation)
|
||||||
return PhotoSet(date=date, lat=lat, lon=lon, files=[photo])
|
return PhotoSet(date=date, date_real=date, lat=lat, lon=lon, files=[photo])
|
||||||
|
|
||||||
|
|
||||||
def get_mtime(fpath):
|
def get_mtime(fpath):
|
||||||
|
|
|
@ -80,7 +80,8 @@ def batch_ingest(library, files):
|
||||||
if foundmatch:
|
if foundmatch:
|
||||||
break
|
break
|
||||||
if not foundmatch:
|
if not foundmatch:
|
||||||
photos.append(PhotoSet(date=get_mtime(item), lat=0, lon=0, files=[itemmeta]))
|
mtime = get_mtime(item)
|
||||||
|
photos.append(PhotoSet(date=mtime, date_real=mtime, lat=0, lon=0, files=[itemmeta]))
|
||||||
done += 1
|
done += 1
|
||||||
pprogress(done, total)
|
pprogress(done, total)
|
||||||
# TODO prune any xmp without an associated regular image or cr2
|
# TODO prune any xmp without an associated regular image or cr2
|
||||||
|
@ -90,7 +91,8 @@ def batch_ingest(library, files):
|
||||||
for item in chain(*[byext[ext] for ext in files_video]):
|
for item in chain(*[byext[ext] for ext in files_video]):
|
||||||
itemmeta = Photo(hash=get_hash(item), path=item, size=os.path.getsize(item),
|
itemmeta = Photo(hash=get_hash(item), path=item, size=os.path.getsize(item),
|
||||||
format=special_magic(item))
|
format=special_magic(item))
|
||||||
photos.append(PhotoSet(date=get_mtime(item), lat=0, lon=0, files=[itemmeta]))
|
mtime = get_mtime(item)
|
||||||
|
photos.append(PhotoSet(date=mtime, date_real=mtime, lat=0, lon=0, files=[itemmeta]))
|
||||||
done += 1
|
done += 1
|
||||||
pprogress(done, total)
|
pprogress(done, total)
|
||||||
|
|
||||||
|
|
|
@ -1,20 +1,29 @@
|
||||||
from sqlalchemy import Column, Integer, String, DateTime, Unicode, DECIMAL, ForeignKey, Boolean
|
from sqlalchemy import Column, Integer, String, DateTime, Unicode, DECIMAL, ForeignKey, Boolean, Enum
|
||||||
from sqlalchemy.orm import relationship
|
from sqlalchemy.orm import relationship
|
||||||
from sqlalchemy.schema import UniqueConstraint
|
from sqlalchemy.schema import UniqueConstraint
|
||||||
from sqlalchemy.ext.declarative import declarative_base
|
from sqlalchemy.ext.declarative import declarative_base
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
import uuid
|
import uuid
|
||||||
|
import enum
|
||||||
|
|
||||||
|
|
||||||
Base = declarative_base()
|
Base = declarative_base()
|
||||||
|
|
||||||
|
|
||||||
|
class PhotoStatus(enum.Enum):
|
||||||
|
private = 0
|
||||||
|
public = 1
|
||||||
|
hidden = 2
|
||||||
|
|
||||||
|
|
||||||
class PhotoSet(Base):
|
class PhotoSet(Base):
|
||||||
__tablename__ = 'photos'
|
__tablename__ = 'photos'
|
||||||
|
|
||||||
id = Column(Integer, primary_key=True)
|
id = Column(Integer, primary_key=True)
|
||||||
uuid = Column(Unicode, unique=True, default=lambda: str(uuid.uuid4()))
|
uuid = Column(Unicode, unique=True, default=lambda: str(uuid.uuid4()))
|
||||||
date = Column(DateTime)
|
date = Column(DateTime)
|
||||||
|
date_real = Column(DateTime)
|
||||||
|
date_offset = Column(Integer, default=0) # minutes
|
||||||
lat = Column(DECIMAL(precision=11))
|
lat = Column(DECIMAL(precision=11))
|
||||||
lon = Column(DECIMAL(precision=11))
|
lon = Column(DECIMAL(precision=11))
|
||||||
|
|
||||||
|
@ -24,6 +33,8 @@ class PhotoSet(Base):
|
||||||
title = Column(String)
|
title = Column(String)
|
||||||
description = Column(String)
|
description = Column(String)
|
||||||
|
|
||||||
|
status = Column(Enum(PhotoStatus), default=PhotoStatus.private)
|
||||||
|
|
||||||
|
|
||||||
class Photo(Base):
|
class Photo(Base):
|
||||||
__tablename__ = 'files'
|
__tablename__ = 'files'
|
||||||
|
|
3
setup.py
3
setup.py
|
@ -19,7 +19,8 @@ setup(name='photoapp',
|
||||||
"photoappd = photoapp.daemon:main",
|
"photoappd = photoapp.daemon:main",
|
||||||
"photoimport = photoapp.ingest:main",
|
"photoimport = photoapp.ingest:main",
|
||||||
"photovalidate = photoapp.validate:main",
|
"photovalidate = photoapp.validate:main",
|
||||||
"photoinfo = photoapp.image:main"
|
"photoinfo = photoapp.image:main",
|
||||||
|
"photooffset = photoapp.dateoffset:main",
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
include_package_data=True,
|
include_package_data=True,
|
||||||
|
|
Loading…
Reference in New Issue