diff --git a/news/helper_f_milestone.rst b/news/helper_f_milestone.rst new file mode 100644 index 000000000..fc6f3624c --- /dev/null +++ b/news/helper_f_milestone.rst @@ -0,0 +1,13 @@ +**Added:** + * A finish argument to finish milestone and record the end datetime. + * Multiple indices can be specified for the u_milestone helper. + +**Changed:** None + +**Deprecated:** None + +**Removed:** None + +**Fixed:** None + +**Security:** None \ No newline at end of file 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/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), } diff --git a/regolith/helpers/u_milestonehelper.py b/regolith/helpers/u_milestonehelper.py index df1d2e068..5484c2daa 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"} @@ -16,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 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). " "Required for a new milestone.") @@ -42,6 +44,9 @@ def subparser(subpi): help="Audience of the milestone. " "Defaults to ['lead', 'pi', 'group_members'] for a new milestone.", ) + subpi.add_argument("-f", "--finish", action="store_true", + help="Finish milestone. " + ) # Do not delete --database arg subpi.add_argument("--database", help="The database that will be updated. Defaults to " @@ -130,7 +135,14 @@ 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: + 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: + 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 = {} @@ -171,6 +183,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}) + 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)}) 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 @@