about summary refs log tree commit diff
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2026-04-16 13:28:36 -0500
committerFrederick Muriuki Muriithi2026-04-16 13:28:36 -0500
commitc11ac9acfbdc0dbcd3105cf7cfc7be8a017e0615 (patch)
tree2daf258545aac6ba7bfd822b717c9cea71094ce5
parentdbe33a9dc6a19106d86532eb0cd35c26607ac85d (diff)
downloadgn-uploader-c11ac9acfbdc0dbcd3105cf7cfc7be8a017e0615.tar.gz
Provide defaults for Year and Month.
Year is a required field, but we provide the month too.
-rw-r--r--uploader/publications/views.py6
-rw-r--r--uploader/templates/publications/create-publication.html31
2 files changed, 22 insertions, 15 deletions
diff --git a/uploader/publications/views.py b/uploader/publications/views.py
index d9eb294..89e9f5d 100644
--- a/uploader/publications/views.py
+++ b/uploader/publications/views.py
@@ -1,5 +1,6 @@
 """Endpoints for publications"""
 import json
+import datetime
 
 from gn_libs.mysqldb import database_connection
 from flask import (
@@ -89,9 +90,12 @@ def create_publication():
     }
 
     if request.method == "GET":
+        now = datetime.datetime.now()
         return render_template(
             "publications/create-publication.html",
-            get_args=_get_args)
+            get_args=_get_args,
+            current_year=now.year,
+            current_month=now.strftime("%B"))
     form = request.form
     authors = form.get("publication-authors").encode("utf8")
     if authors is None or authors == "":
diff --git a/uploader/templates/publications/create-publication.html b/uploader/templates/publications/create-publication.html
index fb0127d..da5889e 100644
--- a/uploader/templates/publications/create-publication.html
+++ b/uploader/templates/publications/create-publication.html
@@ -91,22 +91,22 @@
              class="col-sm-2 col-form-label">
         Month</label>
       <div class="col-sm-4">
-        <select class="form-control"
+        <select class="form-select"
                 id="select-publication-month"
                 name="publication-month">
           <option value="">Select a month</option>
-          <option value="january">January</option>
-          <option value="february">February</option>
-          <option value="march">March</option>
-          <option value="april">April</option>
-          <option value="may">May</option>
-          <option value="june">June</option>
-          <option value="july">July</option>
-          <option value="august">August</option>
-          <option value="september">September</option>
-          <option value="october">October</option>
-          <option value="november">November</option>
-          <option value="december">December</option>
+          <option {%if current_month | lower == "january"%}selected="selected"{%endif%}value="january">January</option>
+          <option {%if current_month | lower == "february"%}selected="selected"{%endif%}value="february">February</option>
+          <option {%if current_month | lower == "march"%}selected="selected"{%endif%}value="march">March</option>
+          <option {%if current_month | lower == "april"%}selected="selected"{%endif%}value="april">April</option>
+          <option {%if current_month | lower == "may"%}selected="selected"{%endif%}value="may">May</option>
+          <option {%if current_month | lower == "june"%}selected="selected"{%endif%}value="june">June</option>
+          <option {%if current_month | lower == "july"%}selected="selected"{%endif%}value="july">July</option>
+          <option {%if current_month | lower == "august"%}selected="selected"{%endif%}value="august">August</option>
+          <option {%if current_month | lower == "september"%}selected="selected"{%endif%}value="september">September</option>
+          <option {%if current_month | lower == "october"%}selected="selected"{%endif%}value="october">October</option>
+          <option {%if current_month | lower == "november"%}selected="selected"{%endif%}value="november">November</option>
+          <option {%if current_month | lower == "december"%}selected="selected"{%endif%}value="december">December</option>
         </select>
         <span class="form-text text-muted">Month of publication</span>
       </div>
@@ -119,7 +119,10 @@
                id="txt-publication-year"
                name="publication-year"
                class="form-control"
-               min="1960" />
+               min="1960"
+               max="{{current_year}}"
+               value="{{current_year or ''}}"
+               required="required" />
         <span class="form-text text-muted">Year of publication</span>
       </div>
     </div>