From d04b7cb89b3fbaa1689f8f6525a2740eda7c3be3 Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Thu, 18 Dec 2025 10:54:27 -0600 Subject: Provide new streamlined UI for publications. --- uploader/publications/views.py | 29 ++- uploader/route_utils.py | 20 +- uploader/static/css/theme.css | 5 + .../templates/phenotypes/sui-view-dataset.html | 8 - uploader/templates/publications/sui-base.html | 9 + .../publications/sui-create-publication.html | 200 ++++++++++++++++++++ .../publications/sui-delete-publication.html | 95 ++++++++++ .../publications/sui-edit-publication.html | 203 +++++++++++++++++++++ uploader/templates/publications/sui-index.html | 109 +++++++++++ .../publications/sui-view-publication.html | 80 ++++++++ uploader/templates/sui-index.html | 200 ++++++++++++-------- 11 files changed, 851 insertions(+), 107 deletions(-) create mode 100644 uploader/templates/publications/sui-base.html create mode 100644 uploader/templates/publications/sui-create-publication.html create mode 100644 uploader/templates/publications/sui-delete-publication.html create mode 100644 uploader/templates/publications/sui-edit-publication.html create mode 100644 uploader/templates/publications/sui-index.html create mode 100644 uploader/templates/publications/sui-view-publication.html diff --git a/uploader/publications/views.py b/uploader/publications/views.py index 4ec832f..f0ec95a 100644 --- a/uploader/publications/views.py +++ b/uploader/publications/views.py @@ -10,6 +10,8 @@ from flask import ( render_template, current_app as app) +from uploader.sui import sui_template + from uploader.flask_extensions import url_for from uploader.authorisation import require_login from uploader.route_utils import redirect_to_next @@ -30,7 +32,7 @@ pubbp = Blueprint("publications", __name__) @require_login def index(): """Index page for publications.""" - return render_template("publications/index.html") + return render_template(sui_template("publications/index.html")) @pubbp.route("/list", methods=["GET"]) @@ -72,7 +74,7 @@ def view_publication(publication_id: int): return redirect(url_for('publications.index')) return render_template( - "publications/view-publication.html", + sui_template("publications/view-publication.html"), publication=publication, linked_phenotypes=tuple(fetch_publication_phenotypes( conn, publication_id))) @@ -82,13 +84,21 @@ def view_publication(publication_id: int): @require_login def create_publication(): """Create a new publication.""" + _get_args = { + key: request.args[key] + for key in ("species_id", "population_id", "dataset_id", "return_to") + if bool(request.args.get(key)) + } + if request.method == "GET": - return render_template("publications/create-publication.html") + return render_template( + sui_template("publications/create-publication.html"), + get_args=_get_args) form = request.form authors = form.get("publication-authors").encode("utf8") if authors is None or authors == "": flash("The publication's author(s) MUST be provided!", "alert alert-danger") - return redirect(url_for("publications.create", **request.args)) + return redirect(url_for("publications.create")) with database_connection(app.config["SQL_URI"]) as conn: publications = create_new_publications(conn, ({ @@ -106,7 +116,7 @@ def create_publication(): return redirect(url_for( request.args.get("return_to") or "publications.view_publication", publication_id=publications[0]["publication_id"], - **request.args)) + **_get_args)) flash("Publication creation failed!", "alert alert-danger") app.logger.debug("Failed to create the new publication.", exc_info=True) @@ -120,7 +130,7 @@ def edit_publication(publication_id: int): with database_connection(app.config["SQL_URI"]) as conn: if request.method == "GET": return render_template( - "publications/edit-publication.html", + sui_template("publications/edit-publication.html"), publication=fetch_publication_by_id(conn, publication_id), linked_phenotypes=tuple(fetch_publication_phenotypes( conn, publication_id)), @@ -171,15 +181,16 @@ def delete_publication(publication_id: int): flash("Cannot delete publication with linked phenotypes!", "alert-warning") return redirect(url_for( - "publications.view_publication", publication_id=publication_id)) + sui_template("publications.view_publication"), + publication_id=publication_id)) if request.method == "GET": return render_template( - "publications/delete-publication.html", + sui_template("publications/delete-publication.html"), publication=publication, linked_phenotypes=linked_phenotypes, publication_id=publication_id) delete_publications(conn, (publication,)) flash("Deleted the publication successfully.", "alert-success") - return render_template("publications/delete-publication-success.html") + return redirect(url_for("publications.index")) diff --git a/uploader/route_utils.py b/uploader/route_utils.py index 4449475..fa63233 100644 --- a/uploader/route_utils.py +++ b/uploader/route_utils.py @@ -56,15 +56,17 @@ def generic_select_population( def redirect_to_next(default: dict): """Redirect to the next uri if specified, else redirect to default.""" assert "uri" in default, "You must provide at least the 'uri' value." - try: - next_page = base64_decode_to_dict(request.args.get("next")) - _uri = next_page["uri"] - next_page.pop("uri") - return redirect(url_for(_uri, **next_page)) - except (TypeError, JSONDecodeError) as _err: - logger.debug("We could not decode the next value '%s'", - next_page, - exc_info=True) + _next = request.args.get("next") + if bool(_next): + try: + next_page = base64_decode_to_dict(_next) + _uri = next_page["uri"] + next_page.pop("uri") + return redirect(url_for(_uri, **next_page)) + except (TypeError, JSONDecodeError) as _err: + logger.debug("We could not decode the next value '%s'", + next_page, + exc_info=True) return redirect(url_for( default["uri"], diff --git a/uploader/static/css/theme.css b/uploader/static/css/theme.css index 99b7af3..bdac745 100644 --- a/uploader/static/css/theme.css +++ b/uploader/static/css/theme.css @@ -83,3 +83,8 @@ table.dataTable tbody tr.selected td { padding-bottom: 0.2em; border-bottom: solid gray 1px; } + + +.breadcrumb-item { + text-transform: Capitalize; +} diff --git a/uploader/templates/phenotypes/sui-view-dataset.html b/uploader/templates/phenotypes/sui-view-dataset.html index 6a26004..f858c4e 100644 --- a/uploader/templates/phenotypes/sui-view-dataset.html +++ b/uploader/templates/phenotypes/sui-view-dataset.html @@ -53,14 +53,6 @@ title="Add a bunch of phenotypes" class="btn btn-primary">Add phenotypes - -
- view publications - - -
+ +{%endblock%} + + +{%block javascript%} + + +{%endblock%} diff --git a/uploader/templates/publications/sui-delete-publication.html b/uploader/templates/publications/sui-delete-publication.html new file mode 100644 index 0000000..436f2c1 --- /dev/null +++ b/uploader/templates/publications/sui-delete-publication.html @@ -0,0 +1,95 @@ +{%extends "publications/sui-base.html"%} +{%from "flash_messages.html" import flash_all_messages%} + +{%block title%}Delete Publication{%endblock%} + +{%block breadcrumbs%} +{{super()}} + +{%endblock%} + + +{%block contents%} +{{flash_all_messages()}} +
+

You are about to delete the publication with the following details:

+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Linked Phenotypes{{linked_phenotypes | count}}
PubMed + {%if publication.PubMed_ID%} + {{publication.PubMed_ID}} + {%else%} + — + {%endif%} +
Title{{publication.Title or "—"}}
Authors{{publication.Authors or "—"}}
Journal{{publication.Journal or "—"}}
Published{{publication.Month or ""}} {{publication.Year or "—"}}
Volume{{publication.Volume or "—"}}
Pages{{publication.Pages or "—"}}
Abstract + {%for line in (publication.Abstract or "—").replace("\r\n", "
").replace("\n", "
").split("
")%} +

{{line}}

+ {%endfor%} +
+
+ +
+

If you are sure that is what you want, click the button below to delete the + publication

+

+ You will not be able to recover the data if you click + delete below.

+ +
+
+ +
+
+
+{%endblock%} + + +{%block javascript%} + +{%endblock%} diff --git a/uploader/templates/publications/sui-edit-publication.html b/uploader/templates/publications/sui-edit-publication.html new file mode 100644 index 0000000..847b020 --- /dev/null +++ b/uploader/templates/publications/sui-edit-publication.html @@ -0,0 +1,203 @@ +{%extends "publications/sui-base.html"%} +{%from "flash_messages.html" import flash_all_messages%} + +{%block title%}Edit Publication{%endblock%} + +{%block breadcrumbs%} +{{super()}} + +{%endblock%} + + +{%block contents%} +{{flash_all_messages()}} + +
+
+ +
+ +
+
+ +
+ +
+
+ + + This is the publication's ID on + NCBI's Pubmed Service + +
+
+ +
+ +
+ + Provide the publication's title here. +
+
+ +
+ +
+ + + A publication MUST have an author. You must + provide a value for the authors field. + +
+
+ +
+ +
+ + Provide the name journal where the + publication was done, here. +
+
+ +
+ +
+ + Month of publication +
+ + +
+ + Year of publication +
+
+ +
+ +
+ + Journal volume +
+ + +
+ + Journal pages for the publication +
+
+ +
+ +
+ +
+
+ +
+
+
+ + +
+
+ +
+
+ +{%endblock%} + + +{%block javascript%} + + +{%endblock%} diff --git a/uploader/templates/publications/sui-index.html b/uploader/templates/publications/sui-index.html new file mode 100644 index 0000000..e405dd1 --- /dev/null +++ b/uploader/templates/publications/sui-index.html @@ -0,0 +1,109 @@ +{%extends "publications/sui-base.html"%} +{%from "flash_messages.html" import flash_all_messages%} + +{%block title%}Publications{%endblock%} + + +{%block contents%} +{{flash_all_messages()}} + +
+ +
+ +
+

Click on title to view more details and to edit details for that + publication.

+
+ +
+ + + + + + + + + + + +
#PubMed IDTitleAuthors
+
+{%endblock%} + + +{%block javascript%} + + + +{%endblock%} diff --git a/uploader/templates/publications/sui-view-publication.html b/uploader/templates/publications/sui-view-publication.html new file mode 100644 index 0000000..740fc37 --- /dev/null +++ b/uploader/templates/publications/sui-view-publication.html @@ -0,0 +1,80 @@ +{%extends "publications/sui-base.html"%} +{%from "flash_messages.html" import flash_all_messages%} + +{%block title%}View Publication{%endblock%} + + +{%block contents%} +{{flash_all_messages()}} + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Linked Phenotypes{{linked_phenotypes | count}}
PubMed + {%if publication.PubMed_ID%} + {{publication.PubMed_ID}} + {%else%} + — + {%endif%} +
Title{{publication.Title or "—"}}
Authors{{publication.Authors or "—"}}
Journal{{publication.Journal or "—"}}
Published{{publication.Month or ""}} {{publication.Year or "—"}}
Volume{{publication.Volume or "—"}}
Pages{{publication.Pages or "—"}}
Abstract + {%for line in (publication.Abstract or "—").replace("\r\n", "
").replace("\n", "
").split("
")%} +

{{line}}

+ {%endfor%} +
+
+ +
+
+ Edit + {%if linked_phenotypes | length == 0%} + delete + {%endif%} +
+
+{%endblock%} + + +{%block javascript%} + +{%endblock%} diff --git a/uploader/templates/sui-index.html b/uploader/templates/sui-index.html index 888823f..b93bf40 100644 --- a/uploader/templates/sui-index.html +++ b/uploader/templates/sui-index.html @@ -13,16 +13,16 @@ {%macro add_form_buttons()%}
-
- -
- +
+ +
+
{%endmacro%} @@ -31,93 +31,131 @@ {%if user_logged_in()%}
-
-

Species

- -

Select the species you want to work with.

-
+
-
- {{add_http_feature_flags()}} - - {{add_form_buttons()}} - - {%if species | length != 0%} -
- - - - - - - - - -
Species Name
-
+
+
+

Species

- {%else%} +

Select the species you want to work with.

- + + {{add_http_feature_flags()}} -
- -
+ {{add_form_buttons()}} - {%endif%} + {%if species | length != 0%} +
+ + + + + + + - {{add_form_buttons()}} + +
Species Name
+
- -
+ {%else%} -{%else%} + -
-

The Genenetwork Uploader (gn-uploader) enables upload of new data - into the Genenetwork System. It provides Quality Control over data, and - guidance in case you data does not meet the standards for acceptance.

-

- Sign in - to get started.

-
-{%endif%} +
+ +
-{%endblock%} + {%endif%} + {{add_form_buttons()}} + +
-{%block sidebarcontents%} -
-

The data in Genenetwork is related to one species or another. Use the form - provided to select from existing species, or click on the - "Create a New Species" button if you cannot find the species you want to - work with.

-
-
-
- Quick Navigation -
- - +
+

View, edit and delete existing publications, and add new + publications by clicking on the button below.

+ + manage publications
- +
-{%endblock%} + + {%else%} + +
+

The Genenetwork Uploader (gn-uploader) enables upload of new data + into the Genenetwork System. It provides Quality Control over data, and + guidance in case you data does not meet the standards for acceptance.

+

+ Sign in + to get started.

+
+ {%endif%} + + {%endblock%} + + + + {%block sidebarcontents%} +
+

The data in Genenetwork is related to one species or another. Use the form + provided to select from existing species, or click on the + "Create a New Species" button if you cannot find the species you want to + work with.

+
+
+
+ Quick Navigation +
+ + +
+
+
+ {%endblock%} -{%block javascript%} - -{%endblock%} + {%block javascript%} + + {%endblock%} -- cgit 1.4.1