diff --git a/etiquette/helpers.py b/etiquette/helpers.py index 6a8cc51..0b70e81 100644 --- a/etiquette/helpers.py +++ b/etiquette/helpers.py @@ -16,9 +16,9 @@ def album_zip_directories(album, recursive=True): ''' directories = {} if album.title: - root_folder = '%s - %s' % (album.id, normalize_filepath(album.title)) + root_folder = 'album %s - %s' % (album.id, normalize_filepath(album.title)) else: - root_folder = '%s' % album.id + root_folder = 'album %s' % album.id directories[album] = root_folder if recursive: diff --git a/etiquette/objects.py b/etiquette/objects.py index 091f0d1..23dc2cf 100644 --- a/etiquette/objects.py +++ b/etiquette/objects.py @@ -42,6 +42,7 @@ class GroupableMixin: if not isinstance(member, type(self)): raise TypeError('Member must be of type %s' % type(self)) + self.photodb.log.debug('Adding child %s to %s' % (member, self)) # Groupables are only allowed to have 1 parent. # Unlike photos which can exist in multiple albums. cur = self.photodb.sql.cursor() @@ -192,6 +193,7 @@ class Album(ObjectBase, GroupableMixin): raise ValueError('Not the same PhotoDB') if self.has_photo(photo): return + self.photodb.log.debug('Adding photo %s to %s' % (photo, self)) cur = self.photodb.sql.cursor() cur.execute('INSERT INTO album_photo_rel VALUES(?, ?)', [self.id, photo.id]) if commit: @@ -226,6 +228,7 @@ class Album(ObjectBase, GroupableMixin): title = self.title if description is None: description = self.description + cur = self.photodb.sql.cursor() cur.execute( 'UPDATE albums SET title=?, description=? WHERE id == ?', [title, description, self.id] diff --git a/etiquette/photodb.py b/etiquette/photodb.py index 2091c3e..84a7a11 100644 --- a/etiquette/photodb.py +++ b/etiquette/photodb.py @@ -296,6 +296,7 @@ class PDBAlbumMixin: if not isinstance(description, str): raise TypeError('Description must be string, not %s' % type(description)) + self.log.debug('New Album: %s' % title) data = { 'id': albumid, 'title': title, @@ -1236,21 +1237,16 @@ class PhotoDB(PDBAlbumMixin, PDBBookmarkMixin, PDBPhotoMixin, PDBTagMixin, PDBUs commit=False, title=current_location.basename, ) - self.log.debug('Created %s' % current_album.title) albums[current_location.absolute_path] = current_album - # Add the current directory album to the parent directory album. - # Add the photos to the current album. parent = albums.get(current_location.parent.absolute_path, None) if parent is not None: try: parent.add(current_album, commit=False) - self.log.debug('Added child album to %s' % parent.title) except exceptions.GroupExists: pass - self.log.debug('Added photo to %s' % current_album) - for photo in new_photos: - current_album.add_photo(photo, commit=False) + for photo in new_photos: + current_album.add_photo(photo, commit=False) if commit: self.log.debug('Committing - digest') diff --git a/etiquette_site.py b/etiquette_site.py index cf4a6f1..81cede4 100644 --- a/etiquette_site.py +++ b/etiquette_site.py @@ -315,21 +315,23 @@ def get_album_zip(albumid): for (inner_album, directory) in directories.items(): text = [] if inner_album.title: - text.append(inner_album.title) + text.append('Title: ' + inner_album.title) if inner_album.description: - text.append(inner_album.description) + text.append('Description: ' + inner_album.description) if not text: continue text = '\r\n\r\n'.join(text) streamed_zip.writestr( - arcname=os.path.join(directory, '%s.txt' % inner_album.id), + arcname=os.path.join(directory, 'album %s.txt' % inner_album.id), data=text.encode('utf-8'), ) if album.title: - download_as = '%s - %s.zip' % (album.id, album.title) + download_as = 'album %s - %s.zip' % (album.id, album.title) else: - download_as = '%s.zip' % album.id + download_as = 'album %s.zip' % album.id + + download_as = helpers.normalize_filepath(download_as) download_as = urllib.parse.quote(download_as) outgoing_headers = { 'Content-Type': 'application/octet-stream', @@ -384,6 +386,7 @@ def get_file(photoid): else: download_as = photo.id + photo.dot_extension + download_as = helpers.normalize_filepath(download_as) download_as = urllib.parse.quote(download_as) response = flask.make_response(send_file(photo.real_filepath)) response.headers['Content-Disposition'] = 'attachment; filename*=UTF-8\'\'%s' % download_as