From d0495ff48275552fc9a8e9f9cc1f1fbc18c48b52 Mon Sep 17 00:00:00 2001 From: Long Yang Date: Mon, 30 Nov 2020 00:26:38 -0500 Subject: [PATCH 1/8] ENH: add finish milestone option. --- regolith/helpers/u_milestonehelper.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/regolith/helpers/u_milestonehelper.py b/regolith/helpers/u_milestonehelper.py index df1d2e068..1e0c5ef96 100644 --- a/regolith/helpers/u_milestonehelper.py +++ b/regolith/helpers/u_milestonehelper.py @@ -7,6 +7,8 @@ from regolith.tools import all_docs_from_collection, fragment_retrieval from regolith.dates import get_due_date from itertools import chain +import datetime as dt + TARGET_COLL = "projecta" ALLOWED_TYPES = {"m":"meeting", "r":"release", "p":"pull request", "o":"other"} @@ -42,6 +44,11 @@ def subparser(subpi): help="Audience of the milestone. " "Defaults to ['lead', 'pi', 'group_members'] for a new milestone.", ) + subpi.add_argument("-f", "--finish", + help="Finish milestone. " + "It takes a string argument for `report_summary` field.", + type = str, + ) # Do not delete --database arg subpi.add_argument("--database", help="The database that will be updated. Defaults to " @@ -171,6 +178,11 @@ def db_updater(self): doc.update({'type': ALLOWED_TYPES.get(rc.type)}) else: doc.update({'type': rc.type}) + if rc.finish: + now = dt.date.today() + rc.status = "f" + doc.update({'end_date': now}) + doc.update({'report_summary': rc.finish}) if rc.status: if rc.status in ALLOWED_STATI: doc.update({'status': ALLOWED_STATI.get(rc.status)}) From 65e2886105930fb8504a506cff9bd2e0abcce5fd Mon Sep 17 00:00:00 2001 From: Long Yang Date: Sun, 6 Dec 2020 05:15:28 -0500 Subject: [PATCH 2/8] ENH: make finish milestone option as store_true. --- regolith/helpers/u_milestonehelper.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/regolith/helpers/u_milestonehelper.py b/regolith/helpers/u_milestonehelper.py index 1e0c5ef96..81c77e5a2 100644 --- a/regolith/helpers/u_milestonehelper.py +++ b/regolith/helpers/u_milestonehelper.py @@ -44,10 +44,8 @@ def subparser(subpi): help="Audience of the milestone. " "Defaults to ['lead', 'pi', 'group_members'] for a new milestone.", ) - subpi.add_argument("-f", "--finish", + subpi.add_argument("-f", "--finish", action="store_true", help="Finish milestone. " - "It takes a string argument for `report_summary` field.", - type = str, ) # Do not delete --database arg subpi.add_argument("--database", @@ -182,7 +180,6 @@ def db_updater(self): now = dt.date.today() rc.status = "f" doc.update({'end_date': now}) - doc.update({'report_summary': rc.finish}) if rc.status: if rc.status in ALLOWED_STATI: doc.update({'status': ALLOWED_STATI.get(rc.status)}) From b2c09e7ab61d7fbe897d86567bd4ee7c1abf538c Mon Sep 17 00:00:00 2001 From: Simon Billinge Date: Mon, 7 Dec 2020 12:27:11 -0500 Subject: [PATCH 3/8] alphabetize prums --- regolith/helper.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/regolith/helper.py b/regolith/helper.py index d29e3dfa5..d16c890fb 100644 --- a/regolith/helper.py +++ b/regolith/helper.py @@ -30,6 +30,7 @@ "a_expense": (a_expense.ExpenseAdderHelper, a_expense.subparser), "a_grppub_readlist": (a_gprl.GrpPubReadListAdderHelper, a_gprl.subparser), "a_manurev": (a_manurev.ManuRevAdderHelper, a_manurev.subparser), + "a_presentation": (a_presentation.PresentationAdderHelper, a_presentation.subparser), "a_projectum": (a_projectum.ProjectumAdderHelper, a_projectum.subparser), "a_proposal": (a_proposal.ProposalAdderHelper, a_proposal.subparser), "a_proprev": (a_proprev.PropRevAdderHelper, a_proprev.subparser), @@ -37,24 +38,20 @@ "f_prum": (u_finishprum.FinishprumUpdaterHelper, u_finishprum.subparser), "f_todo": (f_todo.TodoFinisherHelper, f_todo.subparser), "l_contacts": (l_contacts.ContactsListerHelper, l_contacts.subparser), - "a_expense": (a_expense.ExpenseAdderHelper, a_expense.subparser), - "a_presentation": (a_presentation.PresentationAdderHelper, a_presentation.subparser), - "l_milestones": (l_milestone.MilestonesListerHelper, l_milestone.subparser), - "l_progress": (l_progress.ProgressReportHelper, l_progress.subparser), - "l_projecta": (l_projecta.ProjectaListerHelper, l_projecta.subparser), "l_grants": (l_grants.GrantsListerHelper, l_grants.subparser), "l_members": (l_members.MembersListerHelper, l_members.subparser), "l_milestones": (l_milestone.MilestonesListerHelper, l_milestone.subparser), + "l_progress": (l_progress.ProgressReportHelper, l_progress.subparser), "l_projecta": (l_projecta.ProjectaListerHelper, l_projecta.subparser), "l_todo": (l_todo.TodoListerHelper, l_todo.subparser), - "lister": (l_general.GeneralListerHelper, l_general.subparser), - "makeappointments": (makeappointments.MakeAppointmentsHelper, makeappointments.subparser), "u_contact": (u_contact.ContactUpdaterHelper, u_contact.subparser), "u_institution": (u_institutions.InstitutionsUpdaterHelper, u_institutions.subparser), "u_logurl": (u_logurl.LogUrlUpdaterHelper, u_logurl.subparser), "u_milestone": (u_milestone.MilestoneUpdaterHelper, u_milestone.subparser), - "v_meetings": (v_meetings.MeetingsValidatorHelper, v_meetings.subparser), "u_todo": (u_todo.TodoUpdaterHelper, u_todo.subparser), + "v_meetings": (v_meetings.MeetingsValidatorHelper, v_meetings.subparser), + "lister": (l_general.GeneralListerHelper, l_general.subparser), + "makeappointments": (makeappointments.MakeAppointmentsHelper, makeappointments.subparser), } From 24b4b8d9ba0b009de6e836ad60102c8def6abd4c Mon Sep 17 00:00:00 2001 From: Long Yang Date: Tue, 8 Dec 2020 02:36:22 -0500 Subject: [PATCH 4/8] ENH: allow comma or dash to enter a list of indexes. --- regolith/helpers/u_milestonehelper.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/regolith/helpers/u_milestonehelper.py b/regolith/helpers/u_milestonehelper.py index 81c77e5a2..0587bf4fc 100644 --- a/regolith/helpers/u_milestonehelper.py +++ b/regolith/helpers/u_milestonehelper.py @@ -18,10 +18,10 @@ def subparser(subpi): subpi.add_argument("projectum_id", help="The id of the projectum.") subpi.add_argument("-v", "--verbose", action="store_true", help="Increases the verbosity of the output.") - subpi.add_argument("-i", "--index", nargs='+', + subpi.add_argument("-i", "--index", help="Index of the item in the enumerated list to update. " - "If multiple indexes, separate by space", - type = int) + "Please enter in the format of `2,5,7` or `3-7`", + type = str) subpi.add_argument("-d", "--due_date", help="New due date of the milestone in ISO format(YYYY-MM-DD). " "Required for a new milestone.") @@ -135,7 +135,13 @@ def db_updater(self): raise KeyError(f"please rerun specifying --type with a value from {ALLOWED_TYPES}") if rc.status and rc.status not in (list(chain.from_iterable((k, v) for k, v in ALLOWED_STATI.items()))): raise KeyError(f"please rerun specifying --status with a value from {ALLOWED_STATI}") - for idx in rc.index: + if "-" in rc.index: + idx_parsed = [i for i in range(int(rc.index.split('-')[0]), int(rc.index.split('-')[1])+1)] + elif "," in rc.index: + idx_parsed = [int(i) for i in rc.index.split(',')] + else: + idx_parsed = [int(rc.index)] + for idx in idx_parsed: pdoc = {} if idx == 1: mil = {} From 8dc40430087ade9e981413c6458afa1d75330939 Mon Sep 17 00:00:00 2001 From: Long Yang Date: Tue, 8 Dec 2020 02:59:10 -0500 Subject: [PATCH 5/8] DOC: print one line to show the milestone as finished. --- regolith/helpers/u_milestonehelper.py | 1 + 1 file changed, 1 insertion(+) diff --git a/regolith/helpers/u_milestonehelper.py b/regolith/helpers/u_milestonehelper.py index 0587bf4fc..5f439ccec 100644 --- a/regolith/helpers/u_milestonehelper.py +++ b/regolith/helpers/u_milestonehelper.py @@ -186,6 +186,7 @@ def db_updater(self): now = dt.date.today() rc.status = "f" doc.update({'end_date': now}) + print("The milestone {} has been marked as finished in prum {}".format(doc['name'],key)) if rc.status: if rc.status in ALLOWED_STATI: doc.update({'status': ALLOWED_STATI.get(rc.status)}) From d4dcca10765ab0275d3b8189ca2364ea5a639029 Mon Sep 17 00:00:00 2001 From: Long Yang Date: Tue, 8 Dec 2020 08:29:35 -0500 Subject: [PATCH 6/8] DOC: add news for finish argument and list indexes. --- news/helper_f_milestone.rst | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 news/helper_f_milestone.rst diff --git a/news/helper_f_milestone.rst b/news/helper_f_milestone.rst new file mode 100644 index 000000000..8c0071393 --- /dev/null +++ b/news/helper_f_milestone.rst @@ -0,0 +1,13 @@ +**Added:** None + * A finish argument to finish milestone and record the end datetime. + * A list of indexes can be specified for the u_milestone helper. + +**Changed:** None + +**Deprecated:** None + +**Removed:** None + +**Fixed:** None + +**Security:** None \ No newline at end of file From b87da48a333053332988fdcb11d73e64992c7fdb Mon Sep 17 00:00:00 2001 From: Long Yang Date: Tue, 8 Dec 2020 23:10:34 -0500 Subject: [PATCH 7/8] DOC: update news for finish argument and list indices. --- news/helper_f_milestone.rst | 4 ++-- regolith/helpers/u_milestonehelper.py | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/news/helper_f_milestone.rst b/news/helper_f_milestone.rst index 8c0071393..fc6f3624c 100644 --- a/news/helper_f_milestone.rst +++ b/news/helper_f_milestone.rst @@ -1,6 +1,6 @@ -**Added:** None +**Added:** * A finish argument to finish milestone and record the end datetime. - * A list of indexes can be specified for the u_milestone helper. + * Multiple indices can be specified for the u_milestone helper. **Changed:** None diff --git a/regolith/helpers/u_milestonehelper.py b/regolith/helpers/u_milestonehelper.py index 5f439ccec..5484c2daa 100644 --- a/regolith/helpers/u_milestonehelper.py +++ b/regolith/helpers/u_milestonehelper.py @@ -20,7 +20,7 @@ def subparser(subpi): help="Increases the verbosity of the output.") subpi.add_argument("-i", "--index", help="Index of the item in the enumerated list to update. " - "Please enter in the format of `2,5,7` or `3-7`", + "Please enter in the format of 2,5,7 or 3-7 for multiple indices, or just enter one index.", type = str) subpi.add_argument("-d", "--due_date", help="New due date of the milestone in ISO format(YYYY-MM-DD). " @@ -135,6 +135,7 @@ def db_updater(self): raise KeyError(f"please rerun specifying --type with a value from {ALLOWED_TYPES}") if rc.status and rc.status not in (list(chain.from_iterable((k, v) for k, v in ALLOWED_STATI.items()))): raise KeyError(f"please rerun specifying --status with a value from {ALLOWED_STATI}") + rc.index = rc.index.replace(" ", "") if "-" in rc.index: idx_parsed = [i for i in range(int(rc.index.split('-')[0]), int(rc.index.split('-')[1])+1)] elif "," in rc.index: From 2d64e759e9fc8dbe8cb15f6000fa008ef69d1e43 Mon Sep 17 00:00:00 2001 From: Simon Billinge Date: Thu, 17 Dec 2020 11:05:10 -0500 Subject: [PATCH 8/8] Simon and Long working together to make the first w3 template build --- regolith/builder.py | 2 ++ regolith/builders/bghtmlbuilder.py | 31 +++++++++++++++++--------- regolith/templates/bghtmltemplate.html | 2 +- 3 files changed, 24 insertions(+), 11 deletions(-) diff --git a/regolith/builder.py b/regolith/builder.py index 6d84fc83b..11e35fd31 100644 --- a/regolith/builder.py +++ b/regolith/builder.py @@ -2,6 +2,7 @@ from regolith.builders.cvbuilder import CVBuilder from regolith.builders.htmlbuilder import HtmlBuilder +from regolith.builders.bghtmlbuilder import BGhtmlBuilder from regolith.builders.postdocadbuilder import PostdocadBuilder from regolith.builders.preslistbuilder import PresListBuilder from regolith.builders.publistbuilder import PubListBuilder @@ -21,6 +22,7 @@ BUILDERS = { "annual-activity": ActivitylogBuilder, "beamplan": BeamPlanBuilder, + "bghtml": BGhtmlBuilder, "current-pending": CPBuilder, "cv": CVBuilder, "figure": FigureBuilder, diff --git a/regolith/builders/bghtmlbuilder.py b/regolith/builders/bghtmlbuilder.py index 28a8398da..7a67ef4b0 100644 --- a/regolith/builders/bghtmlbuilder.py +++ b/regolith/builders/bghtmlbuilder.py @@ -15,24 +15,24 @@ ) -class HtmlBuilder(BuilderBase): +class BGhtmlBuilder(BuilderBase): """Build HTML files for website""" - btype = "html" + btype = "bghtml" def __init__(self, rc): super().__init__(rc) # TODO: get this from the RC self.cmds = [ "root_index", - "people", - "projects", - "blog", - "jobs", - "abstracts", - "nojekyll", - "cname", - "finish", +# "people", +# "projects", +# "blog", +#$ "jobs", +# "abstracts", +# "nojekyll", +# "cname", +# "finish", ] def construct_global_ctx(self): @@ -57,6 +57,16 @@ def construct_global_ctx(self): all_docs_from_collection(rc.client, "institutions"), key=_id_key ) + def root_index(self): + """Render root index""" + headerinfo = {"title": "BillingeLongGroup"} + self.render("bghtmltemplate.html", "bgindex.html", headerinfo=headerinfo) +# make_bibtex_file(list(all_docs_from_collection(self.rc.client, +# "citations")), +# pid='group', +# person_dir=self.bldir, +# ) +''' def finish(self): """Move files over to their destination and remove them from the source""" @@ -207,3 +217,4 @@ def cname(self): os.path.join(self.bldir, "CNAME"), "w", encoding="utf-8" ) as f: f.write(rc.cname) +''' \ No newline at end of file diff --git a/regolith/templates/bghtmltemplate.html b/regolith/templates/bghtmltemplate.html index 3f3dfb6a7..9ab791a17 100644 --- a/regolith/templates/bghtmltemplate.html +++ b/regolith/templates/bghtmltemplate.html @@ -9,7 +9,7 @@