parent
3e6e51e308
commit
95da4b19a1
4 changed files with 76 additions and 1 deletions
@ -0,0 +1,14 @@ |
||||
{% extends "layout.html" %} |
||||
{% block title %}Delete Album{% endblock %} |
||||
{% block content %} |
||||
|
||||
<h1>Delete Album</h1> |
||||
|
||||
<form name="delete" action="{{ url_for('photo.delete_album', album=album) }}" method="POST"> |
||||
<input type="hidden" name="token" value="{{ csrf_token() }}"> |
||||
Are you <strong>sure</strong> you want to delete the album <strong>{{ album }}</strong>?<p> |
||||
|
||||
<button type="submit">Yes, Delete This Album</button> |
||||
</form> |
||||
|
||||
{% endblock %} |
@ -0,0 +1,37 @@ |
||||
#!/usr/bin/env python |
||||
|
||||
"""Locate any orphaned photos. |
||||
|
||||
Usage: scripts/orphaned-photos.py <path/to/db> <path/to/static/photos>""" |
||||
|
||||
import sys |
||||
import os |
||||
import codecs |
||||
import json |
||||
import glob |
||||
|
||||
sys.path.append(".") |
||||
import rophako.jsondb as JsonDB |
||||
|
||||
def main(): |
||||
if len(sys.argv) == 1: |
||||
print "Usage: {} <path/to/static/photos>".format(__file__) |
||||
sys.exit(1) |
||||
|
||||
photo_root = sys.argv[1] |
||||
|
||||
db = JsonDB.get("photos/index") |
||||
photos = set() |
||||
for album in db["albums"]: |
||||
for key, data in db["albums"][album].iteritems(): |
||||
for img in ["large", "thumb", "avatar"]: |
||||
photos.add(data[img]) |
||||
|
||||
# Get all the images and compare. |
||||
for img in glob.glob("{}/*.*".format(photo_root)): |
||||
fname = img.split("/")[-1] |
||||
if not fname in photos: |
||||
print "Orphan:", fname |
||||
|
||||
if __name__ == "__main__": |
||||
main() |
Loading…
Reference in new issue