Cleanup: Replace "objectid" with "object_id" in the Python portions.
This commit is contained in:
		
							parent
							
								
									c75071ad2d
								
							
						
					
					
						commit
						3f69a2c240
					
				
					 4 changed files with 67 additions and 67 deletions
				
			
		|  | @ -229,7 +229,7 @@ class PDBAlbumMixin: | ||||||
|         ''' |         ''' | ||||||
|         Create a new album. Photos can be added now or later. |         Create a new album. Photos can be added now or later. | ||||||
|         ''' |         ''' | ||||||
|         albumid = self.generate_id('albums') |         album_id = self.generate_id('albums') | ||||||
|         title = title or '' |         title = title or '' | ||||||
|         description = description or '' |         description = description or '' | ||||||
|         if not isinstance(title, str): |         if not isinstance(title, str): | ||||||
|  | @ -242,7 +242,7 @@ class PDBAlbumMixin: | ||||||
| 
 | 
 | ||||||
|         self.log.debug('New Album: %s' % title) |         self.log.debug('New Album: %s' % title) | ||||||
|         data = { |         data = { | ||||||
|             'id': albumid, |             'id': album_id, | ||||||
|             'title': title, |             'title': title, | ||||||
|             'description': description, |             'description': description, | ||||||
|         } |         } | ||||||
|  | @ -319,8 +319,8 @@ class PDBPhotoMixin: | ||||||
|         super().__init__() |         super().__init__() | ||||||
|         self._photo_cache = cacheclass.Cache() |         self._photo_cache = cacheclass.Cache() | ||||||
| 
 | 
 | ||||||
|     def get_photo(self, photoid): |     def get_photo(self, id): | ||||||
|         return self.get_thing_by_id('photo', photoid) |         return self.get_thing_by_id('photo', id) | ||||||
| 
 | 
 | ||||||
|     def get_photo_by_path(self, filepath): |     def get_photo_by_path(self, filepath): | ||||||
|         filepath = pathclass.Path(filepath) |         filepath = pathclass.Path(filepath) | ||||||
|  | @ -394,10 +394,10 @@ class PDBPhotoMixin: | ||||||
|         author_id = self.get_user_id_or_none(author) |         author_id = self.get_user_id_or_none(author) | ||||||
| 
 | 
 | ||||||
|         created = int(helpers.now()) |         created = int(helpers.now()) | ||||||
|         photoid = self.generate_id('photos') |         photo_id = self.generate_id('photos') | ||||||
| 
 | 
 | ||||||
|         data = { |         data = { | ||||||
|             'id': photoid, |             'id': photo_id, | ||||||
|             'filepath': filepath.absolute_path, |             'filepath': filepath.absolute_path, | ||||||
|             'override_filename': None, |             'override_filename': None, | ||||||
|             'extension': filepath.extension, |             'extension': filepath.extension, | ||||||
|  | @ -710,7 +710,7 @@ class PDBPhotoMixin: | ||||||
|             yield parameters |             yield parameters | ||||||
| 
 | 
 | ||||||
|         if is_must_may_forbid: |         if is_must_may_forbid: | ||||||
|             mmf_results = searchhelpers.mmf_photoids( |             mmf_results = searchhelpers.mmf_photo_ids( | ||||||
|                 self, |                 self, | ||||||
|                 tag_musts, |                 tag_musts, | ||||||
|                 tag_mays, |                 tag_mays, | ||||||
|  | @ -721,7 +721,7 @@ class PDBPhotoMixin: | ||||||
|         else: |         else: | ||||||
|             mmf_results = None |             mmf_results = None | ||||||
| 
 | 
 | ||||||
|         if mmf_results is not None and mmf_results['photoids'] == set(): |         if mmf_results is not None and mmf_results['photo_ids'] == set(): | ||||||
|             generator = [] |             generator = [] | ||||||
|         else: |         else: | ||||||
|             query = searchhelpers.build_query( |             query = searchhelpers.build_query( | ||||||
|  |  | ||||||
|  | @ -120,7 +120,7 @@ def minmax(key, value, minimums, maximums, warning_bag=None): | ||||||
|     if high is not None: |     if high is not None: | ||||||
|         maximums[key] = high |         maximums[key] = high | ||||||
| 
 | 
 | ||||||
| def mmf_photoids(photodb, tag_musts, tag_mays, tag_forbids, frozen_children): | def mmf_photo_ids(photodb, tag_musts, tag_mays, tag_forbids, frozen_children): | ||||||
|     if not(tag_musts or tag_mays or tag_forbids): |     if not(tag_musts or tag_mays or tag_forbids): | ||||||
|         return None |         return None | ||||||
| 
 | 
 | ||||||
|  | @ -170,7 +170,7 @@ def mmf_photoids(photodb, tag_musts, tag_mays, tag_forbids, frozen_children): | ||||||
|             else: |             else: | ||||||
|                 results.update(photo_ids) |                 results.update(photo_ids) | ||||||
| 
 | 
 | ||||||
|     return {'operator': operator, 'photoids': results} |     return {'operator': operator, 'photo_ids': results} | ||||||
| 
 | 
 | ||||||
| def normalize_authors(authors, photodb, warning_bag=None): | def normalize_authors(authors, photodb, warning_bag=None): | ||||||
|     ''' |     ''' | ||||||
|  |  | ||||||
|  | @ -103,16 +103,16 @@ def P_wrapper(function): | ||||||
|     return P_wrapped |     return P_wrapped | ||||||
| 
 | 
 | ||||||
| @P_wrapper | @P_wrapper | ||||||
| def P_album(albumid): | def P_album(album_id): | ||||||
|     return P.get_album(albumid) |     return P.get_album(album_id) | ||||||
| 
 | 
 | ||||||
| @P_wrapper | @P_wrapper | ||||||
| def P_bookmark(bookmarkid): | def P_bookmark(bookmarkid): | ||||||
|     return P.get_bookmark(bookmarkid) |     return P.get_bookmark(bookmarkid) | ||||||
| 
 | 
 | ||||||
| @P_wrapper | @P_wrapper | ||||||
| def P_photo(photoid): | def P_photo(photo_id): | ||||||
|     return P.get_photo(photoid) |     return P.get_photo(photo_id) | ||||||
| 
 | 
 | ||||||
| @P_wrapper | @P_wrapper | ||||||
| def P_tag(tagname): | def P_tag(tagname): | ||||||
|  | @ -123,8 +123,8 @@ def P_user(username): | ||||||
|     return P.get_user(username=username) |     return P.get_user(username=username) | ||||||
| 
 | 
 | ||||||
| @P_wrapper | @P_wrapper | ||||||
| def P_user_id(userid): | def P_user_id(user_id): | ||||||
|     return P.get_user(id=userid) |     return P.get_user(id=user_id) | ||||||
| 
 | 
 | ||||||
| def send_file(filepath, override_mimetype=None): | def send_file(filepath, override_mimetype=None): | ||||||
|     ''' |     ''' | ||||||
|  | @ -206,8 +206,8 @@ def send_file(filepath, override_mimetype=None): | ||||||
| #################################################################################################### | #################################################################################################### | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| def get_album_core(albumid): | def get_album_core(album_id): | ||||||
|     album = P_album(albumid) |     album = P_album(album_id) | ||||||
|     return album |     return album | ||||||
| 
 | 
 | ||||||
| def get_albums_core(): | def get_albums_core(): | ||||||
|  | @ -355,8 +355,8 @@ def get_tags_core(specific_tag=None): | ||||||
|     tags.sort(key=lambda x: x.qualified_name()) |     tags.sort(key=lambda x: x.qualified_name()) | ||||||
|     return tags |     return tags | ||||||
| 
 | 
 | ||||||
| def post_photo_add_remove_tag_core(photoid, tagname, add_or_remove): | def post_photo_add_remove_tag_core(photo_id, tagname, add_or_remove): | ||||||
|     photo = P_photo(photoid, response_type='json') |     photo = P_photo(photo_id, response_type='json') | ||||||
|     tag = P_tag(tagname, response_type='json') |     tag = P_tag(tagname, response_type='json') | ||||||
| 
 | 
 | ||||||
|     try: |     try: | ||||||
|  | @ -397,10 +397,10 @@ def root(): | ||||||
|     session = session_manager.get(request) |     session = session_manager.get(request) | ||||||
|     return flask.render_template('root.html', motd=motd, session=session) |     return flask.render_template('root.html', motd=motd, session=session) | ||||||
| 
 | 
 | ||||||
| @site.route('/album/<albumid>') | @site.route('/album/<album_id>') | ||||||
| @session_manager.give_token | @session_manager.give_token | ||||||
| def get_album_html(albumid): | def get_album_html(album_id): | ||||||
|     album = get_album_core(albumid) |     album = get_album_core(album_id) | ||||||
|     session = session_manager.get(request) |     session = session_manager.get(request) | ||||||
|     response = flask.render_template( |     response = flask.render_template( | ||||||
|         'album.html', |         'album.html', | ||||||
|  | @ -410,19 +410,19 @@ def get_album_html(albumid): | ||||||
|     ) |     ) | ||||||
|     return response |     return response | ||||||
| 
 | 
 | ||||||
| @site.route('/album/<albumid>.json') | @site.route('/album/<album_id>.json') | ||||||
| @session_manager.give_token | @session_manager.give_token | ||||||
| def get_album_json(albumid): | def get_album_json(album_id): | ||||||
|     album = get_album_core(albumid) |     album = get_album_core(album_id) | ||||||
|     album = etiquette.jsonify.album(album) |     album = etiquette.jsonify.album(album) | ||||||
|     album['sub_albums'] = [P_album(x) for x in album['sub_albums']] |     album['sub_albums'] = [P_album(x) for x in album['sub_albums']] | ||||||
|     album['sub_albums'].sort(key=lambda x: (x.title or x.id).lower()) |     album['sub_albums'].sort(key=lambda x: (x.title or x.id).lower()) | ||||||
|     album['sub_albums'] = [etiquette.jsonify.album(x, minimal=True) for x in album['sub_albums']] |     album['sub_albums'] = [etiquette.jsonify.album(x, minimal=True) for x in album['sub_albums']] | ||||||
|     return jsonify.make_json_response(album) |     return jsonify.make_json_response(album) | ||||||
| 
 | 
 | ||||||
| @site.route('/album/<albumid>.zip') | @site.route('/album/<album_id>.zip') | ||||||
| def get_album_zip(albumid): | def get_album_zip(album_id): | ||||||
|     album = P_album(albumid) |     album = P_album(album_id) | ||||||
| 
 | 
 | ||||||
|     recursive = request.args.get('recursive', True) |     recursive = request.args.get('recursive', True) | ||||||
|     recursive = etiquette.helpers.truthystring(recursive) |     recursive = etiquette.helpers.truthystring(recursive) | ||||||
|  | @ -463,14 +463,14 @@ def get_album_zip(albumid): | ||||||
|     } |     } | ||||||
|     return flask.Response(streamed_zip, headers=outgoing_headers) |     return flask.Response(streamed_zip, headers=outgoing_headers) | ||||||
| 
 | 
 | ||||||
| @site.route('/album/<albumid>/add_tag', methods=['POST']) | @site.route('/album/<album_id>/add_tag', methods=['POST']) | ||||||
| @session_manager.give_token | @session_manager.give_token | ||||||
| def post_album_add_tag(albumid): | def post_album_add_tag(album_id): | ||||||
|     ''' |     ''' | ||||||
|     Apply a tag to every photo in the album. |     Apply a tag to every photo in the album. | ||||||
|     ''' |     ''' | ||||||
|     response = {} |     response = {} | ||||||
|     album = P_album(albumid) |     album = P_album(album_id) | ||||||
| 
 | 
 | ||||||
|     tag = request.form['tagname'].strip() |     tag = request.form['tagname'].strip() | ||||||
|     try: |     try: | ||||||
|  | @ -485,13 +485,13 @@ def post_album_add_tag(albumid): | ||||||
|     response['tagname'] = tag.name |     response['tagname'] = tag.name | ||||||
|     return jsonify.make_json_response(response) |     return jsonify.make_json_response(response) | ||||||
| 
 | 
 | ||||||
| @site.route('/album/<albumid>/edit', methods=['POST']) | @site.route('/album/<album_id>/edit', methods=['POST']) | ||||||
| @session_manager.give_token | @session_manager.give_token | ||||||
| def post_album_edit(albumid): | def post_album_edit(album_id): | ||||||
|     ''' |     ''' | ||||||
|     Edit the title / description. |     Edit the title / description. | ||||||
|     ''' |     ''' | ||||||
|     album = P_album(albumid) |     album = P_album(album_id) | ||||||
| 
 | 
 | ||||||
|     title = request.form.get('title', None) |     title = request.form.get('title', None) | ||||||
|     description = request.form.get('description', None) |     description = request.form.get('description', None) | ||||||
|  | @ -594,10 +594,10 @@ def favicon(): | ||||||
|     return flask.send_file(FAVICON_PATH.absolute_path) |     return flask.send_file(FAVICON_PATH.absolute_path) | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| @site.route('/file/<photoid>') | @site.route('/file/<photo_id>') | ||||||
| def get_file(photoid): | def get_file(photo_id): | ||||||
|     photoid = photoid.split('.')[0] |     photo_id = photo_id.split('.')[0] | ||||||
|     photo = P.get_photo(photoid) |     photo = P.get_photo(photo_id) | ||||||
| 
 | 
 | ||||||
|     do_download = request.args.get('download', False) |     do_download = request.args.get('download', False) | ||||||
|     do_download = etiquette.helpers.truthystring(do_download) |     do_download = etiquette.helpers.truthystring(do_download) | ||||||
|  | @ -663,36 +663,36 @@ def logout(): | ||||||
|     return response |     return response | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| @site.route('/photo/<photoid>', methods=['GET']) | @site.route('/photo/<photo_id>', methods=['GET']) | ||||||
| @session_manager.give_token | @session_manager.give_token | ||||||
| def get_photo_html(photoid): | def get_photo_html(photo_id): | ||||||
|     photo = P_photo(photoid, response_type='html') |     photo = P_photo(photo_id, response_type='html') | ||||||
|     session = session_manager.get(request) |     session = session_manager.get(request) | ||||||
|     return flask.render_template('photo.html', photo=photo, session=session) |     return flask.render_template('photo.html', photo=photo, session=session) | ||||||
| 
 | 
 | ||||||
| @site.route('/photo/<photoid>.json', methods=['GET']) | @site.route('/photo/<photo_id>.json', methods=['GET']) | ||||||
| @session_manager.give_token | @session_manager.give_token | ||||||
| def get_photo_json(photoid): | def get_photo_json(photo_id): | ||||||
|     photo = P_photo(photoid, response_type='json') |     photo = P_photo(photo_id, response_type='json') | ||||||
|     photo = etiquette.jsonify.photo(photo) |     photo = etiquette.jsonify.photo(photo) | ||||||
|     photo = jsonify.make_json_response(photo) |     photo = jsonify.make_json_response(photo) | ||||||
|     return photo |     return photo | ||||||
| 
 | 
 | ||||||
| @site.route('/photo/<photoid>/add_tag', methods=['POST']) | @site.route('/photo/<photo_id>/add_tag', methods=['POST']) | ||||||
| @decorators.required_fields(['tagname'], forbid_whitespace=True) | @decorators.required_fields(['tagname'], forbid_whitespace=True) | ||||||
| def post_photo_add_tag(photoid): | def post_photo_add_tag(photo_id): | ||||||
|     ''' |     ''' | ||||||
|     Add a tag to this photo. |     Add a tag to this photo. | ||||||
|     ''' |     ''' | ||||||
|     return post_photo_add_remove_tag_core(photoid, request.form['tagname'], 'add') |     return post_photo_add_remove_tag_core(photo_id, request.form['tagname'], 'add') | ||||||
| 
 | 
 | ||||||
| @site.route('/photo/<photoid>/refresh_metadata', methods=['POST']) | @site.route('/photo/<photo_id>/refresh_metadata', methods=['POST']) | ||||||
| def post_photo_refresh_metadata(photoid): | def post_photo_refresh_metadata(photo_id): | ||||||
|     ''' |     ''' | ||||||
|     Refresh the file metadata. |     Refresh the file metadata. | ||||||
|     ''' |     ''' | ||||||
|     P.caches['photo'].remove(photoid) |     P.caches['photo'].remove(photo_id) | ||||||
|     photo = P_photo(photoid, response_type='json') |     photo = P_photo(photo_id, response_type='json') | ||||||
|     try: |     try: | ||||||
|         photo.reload_metadata() |         photo.reload_metadata() | ||||||
|     except etiquette.exceptions.EtiquetteException as e: |     except etiquette.exceptions.EtiquetteException as e: | ||||||
|  | @ -707,13 +707,13 @@ def post_photo_refresh_metadata(photoid): | ||||||
| 
 | 
 | ||||||
|     return jsonify.make_json_response({}) |     return jsonify.make_json_response({}) | ||||||
| 
 | 
 | ||||||
| @site.route('/photo/<photoid>/remove_tag', methods=['POST']) | @site.route('/photo/<photo_id>/remove_tag', methods=['POST']) | ||||||
| @decorators.required_fields(['tagname'], forbid_whitespace=True) | @decorators.required_fields(['tagname'], forbid_whitespace=True) | ||||||
| def post_photo_remove_tag(photoid): | def post_photo_remove_tag(photo_id): | ||||||
|     ''' |     ''' | ||||||
|     Remove a tag from this photo. |     Remove a tag from this photo. | ||||||
|     ''' |     ''' | ||||||
|     return post_photo_add_remove_tag_core(photoid, request.form['tagname'], 'remove') |     return post_photo_add_remove_tag_core(photo_id, request.form['tagname'], 'remove') | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| @site.route('/register', methods=['GET']) | @site.route('/register', methods=['GET']) | ||||||
|  | @ -876,10 +876,10 @@ def post_tag_delete(): | ||||||
|     return post_tag_create_delete_core(request.form['tagname'], delete_tag) |     return post_tag_create_delete_core(request.form['tagname'], delete_tag) | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| @site.route('/thumbnail/<photoid>') | @site.route('/thumbnail/<photo_id>') | ||||||
| def get_thumbnail(photoid): | def get_thumbnail(photo_id): | ||||||
|     photoid = photoid.split('.')[0] |     photo_id = photo_id.split('.')[0] | ||||||
|     photo = P_photo(photoid) |     photo = P_photo(photo_id) | ||||||
|     if photo.thumbnail: |     if photo.thumbnail: | ||||||
|         path = photo.thumbnail |         path = photo.thumbnail | ||||||
|     else: |     else: | ||||||
|  | @ -901,14 +901,14 @@ def get_user_json(username): | ||||||
|     user = etiquette.jsonify.user(user) |     user = etiquette.jsonify.user(user) | ||||||
|     return jsonify.make_json_response(user) |     return jsonify.make_json_response(user) | ||||||
| 
 | 
 | ||||||
| @site.route('/userid/<userid>') | @site.route('/userid/<user_id>') | ||||||
| @site.route('/userid/<userid>.json') | @site.route('/userid/<user_id>.json') | ||||||
| def get_user_id_redirect(userid): | def get_user_id_redirect(user_id): | ||||||
|     if request.url.endswith('.json'): |     if request.url.endswith('.json'): | ||||||
|         user = P_user_id(userid, response_type='json') |         user = P_user_id(user_id, response_type='json') | ||||||
|     else: |     else: | ||||||
|         user = P_user_id(userid, response_type='html') |         user = P_user_id(user_id, response_type='html') | ||||||
|     url_from = '/userid/' + userid |     url_from = '/userid/' + user_id | ||||||
|     url_to = '/user/' + user.username |     url_to = '/user/' + user.username | ||||||
|     url = request.url.replace(url_from, url_to) |     url = request.url.replace(url_from, url_to) | ||||||
|     return flask.redirect(url) |     return flask.redirect(url) | ||||||
|  |  | ||||||
|  | @ -22,8 +22,8 @@ def easytagger(): | ||||||
|         else: |         else: | ||||||
|             P.easybake(i) |             P.easybake(i) | ||||||
| 
 | 
 | ||||||
| def photag(photoid): | def photag(photo_id): | ||||||
|     photo = P.get_photo_by_id(photoid) |     photo = P.get_photo_by_id(photo_id) | ||||||
|     print(photo.tags()) |     print(photo.tags()) | ||||||
|     while True: |     while True: | ||||||
|         photo.add_tag(input('> ')) |         photo.add_tag(input('> ')) | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue