Skip to content

Commit

Permalink
Merge pull request #1061 from sbillinge/activity
Browse files Browse the repository at this point in the history
initial commit of code to add current grants to projects
  • Loading branch information
sbillinge authored Mar 30, 2024
2 parents 2448bb6 + aa456ff commit 9fb62aa
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 15 deletions.
30 changes: 19 additions & 11 deletions regolith/builders/activitylogbuilder.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
"""Builder for CVs."""
import datetime as dt
import uuid

from dateutil import parser as date_parser
from dateutil.relativedelta import relativedelta
from copy import deepcopy, copy
Expand Down Expand Up @@ -144,17 +146,6 @@ def latex(self):
and get_dates(manrev, date_field_prefix="submitted"
).get("submitted_date", dt.date(1971,1,1)
) >= begin_period])
#########
# highlights
#########
for proj in projs:
if proj.get('highlights'):
proj["current_highlights"] = False
for highlight in proj.get('highlights'):
highlight_date = get_dates(highlight)
if highlight_date.get("end_date") >= begin_period:
highlight["is_current"] = True
proj["current_highlights"] = True

#########
# current and pending
Expand Down Expand Up @@ -253,6 +244,23 @@ def latex(self):
# end current and pending
#########

#########
# highlights
#########
for grant in current_grants:
holdid = grant.get("_id")
grant["_id"] = uuid.uuid4()
projs.append(grant)
grant["_id"] = holdid #not sure if this will update on dump so just be careful
for proj in projs:
if proj.get('highlights'):
proj["current_highlights"] = False
for highlight in proj.get('highlights'):
highlight_date = get_dates(highlight)
if highlight_date.get("end_date") >= begin_period:
highlight["is_current"] = True
proj["current_highlights"] = True

#########
# advising
#########
Expand Down
4 changes: 2 additions & 2 deletions regolith/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,8 +266,8 @@ def validate(rc):
else:
# uncomment when debugging scheme errors
#
# sys.exit(f"Validation failed on some records\n {cap}")
sys.exit(f"Validation failed on some records")
sys.exit(f"Validation failed on some records\n {cap}")
# sys.exit(f"Validation failed on some records")

DISCONNECTED_COMMANDS = {
"rc": lambda rc: print(rc._pformat()),
Expand Down
16 changes: 16 additions & 0 deletions regolith/schemas.json
Original file line number Diff line number Diff line change
Expand Up @@ -735,6 +735,22 @@
"required": false,
"type": "string"
},
"highlights": {
"description": "lists of highlights from the project",
"required": false,
"type": "list",
"schema": {
"schema": {
"year": {"required": false, "type": "integer"},
"month": {"required": false, "type": "integer"},
"description": {
"required": false,
"type": "string"
}
},
"type": "dict"
}
},
"institution": {
"description": "the host institution for the grant",
"type": "string",
Expand Down
3 changes: 3 additions & 0 deletions regolith/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,9 @@ def load_exemplars():
},
],
"status": "accepted",
"highlights": [
{"year": 2020, "month": 5, "description": "high profile pub in Nature"}
],
"title": "SymPy 2.0 Release Support",
"budget": [
{
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ def main():
"static/*.*",
"static/img/*.*",
"*.xsh",
"*.json"
]
},
scripts=["scripts/regolith"],
Expand Down
3 changes: 1 addition & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from regolith.fsclient import dump_yaml
from regolith.schemas import EXEMPLARS

OUTPUT_FAKE_DB = True # always turn it to false after you used it
OUTPUT_FAKE_DB = False # always turn it to false after you used it
# Currently the first two must be named test solely to match the helper map test output text
REGOLITH_MONGODB_NAME = "test"
FS_DB_NAME = 'test'
Expand Down Expand Up @@ -500,4 +500,3 @@ def exemplars_to_mongo(mongo_db_name, collection_list=None):
print('Duplicate key error, check exemplars for duplicates if tests fail')
except mongo_errors.BulkWriteError:
print('Duplicate key error, check exemplars for duplicates if tests fail')

0 comments on commit 9fb62aa

Please sign in to comment.