diff --git a/frontends/etiquette_flask/etiquette_flask/endpoints/album_endpoints.py b/frontends/etiquette_flask/etiquette_flask/endpoints/album_endpoints.py index e30687c..94ab804 100644 --- a/frontends/etiquette_flask/etiquette_flask/endpoints/album_endpoints.py +++ b/frontends/etiquette_flask/etiquette_flask/endpoints/album_endpoints.py @@ -166,7 +166,7 @@ def get_albums_core(): def get_albums_html(): albums = get_albums_core() session = session_manager.get(request) - return flask.render_template('albums.html', albums=albums, session=session) + return flask.render_template('album.html', albums=albums, session=session) @site.route('/albums.json') @session_manager.give_token @@ -178,18 +178,19 @@ def get_albums_json(): # Album create and delete ########################################################################## @site.route('/albums/create_album', methods=['POST']) +@session_manager.give_token @decorators.catch_etiquette_exception def post_albums_create(): title = request.form.get('title', None) description = request.form.get('description', None) - parent = request.form.get('parent', None) - if parent is not None: - parent = common.P_album(parent) + parent_id = request.form.get('parent_id', None) + if parent_id is not None: + parent = common.P_album(parent_id) user = session_manager.get(request).user album = common.P.new_album(title=title, description=description, author=user) - if parent is not None: + if parent_id is not None: parent.add_child(album) response = etiquette.jsonify.album(album, minimal=False) diff --git a/frontends/etiquette_flask/static/js/albums.js b/frontends/etiquette_flask/static/js/albums.js deleted file mode 100644 index 66233dd..0000000 --- a/frontends/etiquette_flask/static/js/albums.js +++ /dev/null @@ -1,76 +0,0 @@ -var albums = {}; - -albums.create_child_prompt_button = null; -albums.create_child_title_entry = null; -albums.create_child_submit_button = null; -albums.create_child_cancel_button = null; - -albums.open_creator_prompt = -function open_creator_prompt(event) -{ - albums.create_child_prompt_button.classList.add("hidden"); - albums.create_child_title_entry.classList.remove("hidden"); - albums.create_child_title_entry.focus(); - albums.create_child_submit_button.classList.remove("hidden"); - albums.create_child_cancel_button.classList.remove("hidden"); -} - -albums.cancel_create_child = -function cancel_create_child(event) -{ - albums.create_child_prompt_button.classList.remove("hidden"); - albums.create_child_title_entry.value = ""; - albums.create_child_title_entry.classList.add("hidden"); - albums.create_child_submit_button.classList.add("hidden"); - albums.create_child_cancel_button.classList.add("hidden"); -} - -albums.create_album_and_follow = -function create_album_and_follow(title, parent) -{ - var url = "/albums/create_album"; - var data = new FormData(); - if (title !== undefined) - { - data.append("title", title); - } - if (parent !== undefined) - { - data.append("parent", parent); - } - function receive_callback(response) - { - if (response["meta"]["status"] == 200 && response["data"]["id"]) - { - window.location.href = "/album/" + response["data"]["id"]; - } - else - { - console.log(response); - } - } - common.post(url, data, receive_callback); -} - -albums.submit_create_child = -function submit_create_child(event) -{ - var title = document.getElementById("create_child_title_entry").value; - if (! title) - { - title = undefined; - } - var parent_id = ALBUM_ID; - albums.create_album_and_follow(title, parent_id); -} - -albums.on_pageload = -function on_pageload() -{ - albums.create_child_prompt_button = document.getElementById("create_child_prompt_button"); - albums.create_child_title_entry = document.getElementById("create_child_title_entry"); - albums.create_child_submit_button = document.getElementById("create_child_submit_button"); - albums.create_child_cancel_button = document.getElementById("create_child_cancel_button"); - common.bind_box_to_button(albums.create_child_title_entry, albums.create_child_submit_button); -} -document.addEventListener("DOMContentLoaded", albums.on_pageload); diff --git a/frontends/etiquette_flask/templates/album.html b/frontends/etiquette_flask/templates/album.html index 4c7a6bd..2f4d92e 100644 --- a/frontends/etiquette_flask/templates/album.html +++ b/frontends/etiquette_flask/templates/album.html @@ -1,5 +1,53 @@ + +{% if album is not defined %} {## Album listing ###################################################} + +
+ {% import "header.html" as header %} +- {{-album.description-}} -+
+ {{-album.description-}} ++ +
- Download: + Download: {% if has_local_photos %} - - These files ({{album.sum_bytes(recurse=False)|bytestring }}) - - {% if has_child_photos %}—{% endif %} + These files ({{album.sum_bytes(recurse=False)|bytestring }}) + {% if has_child_photos %}—{% endif %} {% endif %} {% if has_child_photos %} - - Include children ({{album.sum_bytes(recurse=True)|bytestring }}) - + Include children ({{album.sum_bytes(recurse=True)|bytestring }}) {% endif %}
{% endif %} + + {{clipboard_tray.clipboard_tray()}} +