Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Web #661

Open
wants to merge 11 commits into
base: bghtml
Choose a base branch
from
13 changes: 13 additions & 0 deletions news/helper_f_milestone.rst
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions regolith/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -21,6 +22,7 @@
BUILDERS = {
"annual-activity": ActivitylogBuilder,
"beamplan": BeamPlanBuilder,
"bghtml": BGhtmlBuilder,
"current-pending": CPBuilder,
"cv": CVBuilder,
"figure": FigureBuilder,
Expand Down
31 changes: 21 additions & 10 deletions regolith/builders/bghtmlbuilder.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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"""
Expand Down Expand Up @@ -207,3 +217,4 @@ def cname(self):
os.path.join(self.bldir, "CNAME"), "w", encoding="utf-8"
) as f:
f.write(rc.cname)
'''
13 changes: 5 additions & 8 deletions regolith/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,31 +30,28 @@
"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),
"a_todo": (a_todo.TodoAdderHelper, a_todo.subparser),
"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),
}


Expand Down
25 changes: 21 additions & 4 deletions regolith/helpers/u_milestonehelper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"}
Expand All @@ -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.")
Expand All @@ -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 "
Expand Down Expand Up @@ -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 = {}
Expand Down Expand Up @@ -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)})
Expand Down
2 changes: 1 addition & 1 deletion regolith/templates/bghtmltemplate.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<!-- Navbar (sit on top) -->
<div class="w3-top">
<div class="w3-bar w3-white w3-wide w3-padding w3-card">
<a href="#home" class="w3-bar-item w3-button"><b>BG</b> BillingeGroup</a>
<a href="#home" class="w3-bar-item w3-button"><b>BG</b> {{ headerinfo.get("title") }}</a>
<!-- Float links to the right. Hide them on small screens -->
<div class="w3-right w3-hide-small">
<a href="#news" class="w3-bar-item w3-button">News</a>
Expand Down