about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--gn2/wqflask/templates/wiki/history.html124
-rw-r--r--gn2/wqflask/views.py9
2 files changed, 46 insertions, 87 deletions
diff --git a/gn2/wqflask/templates/wiki/history.html b/gn2/wqflask/templates/wiki/history.html
index 32c52b55..bda802d3 100644
--- a/gn2/wqflask/templates/wiki/history.html
+++ b/gn2/wqflask/templates/wiki/history.html
@@ -5,88 +5,50 @@
         <div class="row">
             <div class="col-sm-9">
                 <h2 class="text-info">GeneWiki Entry History</h2>
-                <h3 class="text-info">
-                    <strong>Most Recent Version:</strong>
-                </h3>
-                <table class="table table-responsive table-bordered">
-                    <tbody>
-                        <tr>
-                            <th>Gene Symbol:</th>
-                            <td>{{ most_recent.symbol }}</td>
-                        </tr>
-                        <tr>
-                            <th>PubMed IDs:</th>
-                            <td>
-                                {% for id in most_recent.pubmed_ids %}
-                                    <a href="http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?cmd=Retrieve&db=PubMed&list_uids={{ id }}&dopt=Abstract">{{ id }}</a>&nbsp;
-                                {% endfor %}
-                                {% if not most_recent.pubmed_ids %}Not Available{% endif %}
-                            </td>
-                        </tr>
-                        <tr>
-                            <th>Web URL:</th>
-                            <td>{{ most_recent.web_url or "Not Available" }}</td>
-                        </tr>
-                        <tr>
-                            <th>Entry:</th>
-                            <td>{{ most_recent.comment }}</td>
-                        </tr>
-                        <tr>
-                            <th>Category:</th>
-                            <td>{{ '; '.join(most_recent.categories) or "Not Available" }}</td>
-                        </tr>
-                        <tr>
-                            <th>Add Time:</th>
-                            <td>{{ most_recent.created }}</td>
-                        </tr>
-                        <tr>
-                            <th>Reason for Modification:</th>
-                            <td>{{ most_recent.reason or "Not Available" }}</td>
-                        </tr>
-                    </tbody>
-                </table>
-                <h3 class="text-info">
-                    <strong>Previous Version:</strong>
-                </h3>
-                {% for version in previous_versions %}
+                {% for entry in entries %}
+                    <h3 class="text-info">
+                        {% if loop.index0 == 0 %}
+                            <strong>Most Recent Version:</strong>
+                        {% elif loop.index0 == 1 %}
+                            <strong>Previous Version:</strong>
+                        {% endif %}
+                    </h3>
                     <table class="table table-responsive table-bordered">
-                        <tr>
-                            <th>Gene Symbol:</th>
-                            <td>{{ version.symbol }}</td>
-                        </tr>
-                        <tr>
-                            <th>Species:</th>
-                            <td>{{ version.species or "Not Available" }}</td>
-                        </tr>
-                        <tr>
-                            <th>PubMed IDs:</th>
-                            <td>
-                                {% for id in version.pubmed_ids %}
-                                    <a href="http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?cmd=Retrieve&db=PubMed&list_uids={{ id }}&dopt=Abstract">{{ id }}</a>&nbsp;
-                                {% endfor %}
-                                {% if not most_recent.pubmed_ids %}Not Available{% endif %}
-                            </td>
-                        </tr>
-                        <tr>
-                            <th>Web URL:</th>
-                            <td>{{ version.web_url or "Not Available " }}</td>
-                        </tr>
-                        <tr>
-                            <th>Entry:</th>
-                            <td>{{ version.comment }}</td>
-                        </tr>
-                        <tr>
-                            <th>Category:</th>
-                            <td>{{ '; '.join(version.categories) or "Not Available" }}</td>
-                        </tr>
-                        <tr>
-                            <th>Add Time:</th>
-                            <td>{{ version.created }}</td>
-                        </tr>
-                        <tr>
-                            <th>Reason for Modification:</th>
-                            <td>{{ version.reason or "Not Available" }}</td>
-                        </tr>
+                        <tbody>
+                            <tr>
+                                <th>Gene Symbol:</th>
+                                <td>{{ entry.symbol }}</td>
+                            </tr>
+                            <tr>
+                                <th>PubMed IDs:</th>
+                                <td>
+                                    {% for id in entry.pubmed_ids %}
+                                        <a href="http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?cmd=Retrieve&db=PubMed&list_uids={{ id }}&dopt=Abstract">{{ id }}</a>&nbsp;
+                                    {% endfor %}
+                                    {% if not entry.pubmed_ids %}Not Available{% endif %}
+                                </td>
+                            </tr>
+                            <tr>
+                                <th>Web URL:</th>
+                                <td>{{ entry.web_url or "Not Available" }}</td>
+                            </tr>
+                            <tr>
+                                <th>Entry:</th>
+                                <td>{{ entry.comment }}</td>
+                            </tr>
+                            <tr>
+                                <th>Category:</th>
+                                <td>{{ '; '.join(entry.categories) or "Not Available" }}</td>
+                            </tr>
+                            <tr>
+                                <th>Add Time:</th>
+                                <td>{{ entry.created }}</td>
+                            </tr>
+                            <tr>
+                                <th>Reason for Modification:</th>
+                                <td>{{ entry.reason or "Not Available" }}</td>
+                            </tr>
+                        </tbody>
                     </table>
                 {% endfor %}
             </div>
diff --git a/gn2/wqflask/views.py b/gn2/wqflask/views.py
index ce221c36..7e8cd901 100644
--- a/gn2/wqflask/views.py
+++ b/gn2/wqflask/views.py
@@ -1279,8 +1279,7 @@ def display_genewiki_page(symbol: str):
 
 @app.route("/genewiki/<int:comment_id>/history")
 def display_wiki_history(comment_id: str):
-    most_recent = {}
-    previous_versions = []
+    entries = []
     try:
         entries = requests.get(
             urljoin(
@@ -1289,14 +1288,12 @@ def display_wiki_history(comment_id: str):
             )
         )
         entries.raise_for_status()
-        if entries := entries.json():
-            most_recent, previous_versions = entries[0], entries[1:]
+        entries = entries.json()
     except requests.RequestException as excp:
         flash(excp, "alert-warning")
     return render_template(
         "wiki/history.html",
-        most_recent=most_recent,
-        previous_versions=previous_versions
+        entries=entries
     )