Currently, we use both Python's built-in datetime library and Pendulum
to do datetime operations. For the sake of consistency, we should try to
stick to one library for datetimes. We could have used either, but
Pendulum has a more ergonomic API, so I decided to go with it when
possible.
The places where were we didn't / couldn't replace datetime are:
- checking instances of datetimes. Pendulum's objects are subclasses of
python native datetime objects, so it's still useful to import
datetime in those cases of using is_instance()
- WTForms date validators expect datetime style string formats --
Pendulum has its own format for formatting/ parsing strings. As such,
our custom validator DateRange needs to use datetime.stptime() to
account for this format.
Like claim_for_update, the claim_many_for_update claims resources with
an expiring lock. This was written to allow the updating of multiple
application roles with a single cloud_id, since multiple application
roles will map to a single Azure Active Directory user.
Also removes the clock class.
Makes PoP date ranges inclusive such that a task order with:
- a start date on or after the current date
and
- an end date on or before the current date
should be considered valid.
This commit also removes the Clock class. This class had two methods as
shortcuts for common uses of pendlum functions. But it wasn't being used
in very many places, and it took up about the same space as
from pendulum import today()
...
today(tz="UTC").date()
If we want to add this back in, it might be a good idea to extend it for
other time functions we have sprinkled around, like the random date
functions in our tests
1. Funding duration
Returns a tuple of the earliest period of performance start date and
latest period of performance end date for all active task order in a portfolio.
2. Days to funding expiration
Returns the numbei of days between today and the lastest
period performance end date of all active task orders
3. Active task orders
Returns a list of a portfolio's active task orders a
- Factory adds total_amount field, which is always greater than obligated
field
- add total_amount field on tests that create TOs manually
- update tests that calculate total_contract_amount and
total_obligated_amount
CLINS have a special ordering:
- First, they are sorted by the last three digits
- Then, they are sorted by the first digit
Trying to add CLIN sorting logic to the relationship field in the task
order proved to be more challenging than expected. So, a separate
property was defined in order to access the clins in sorted order.
- Applies our previous CSP namespacing pattern to the upload classes.
- Removes code and config for previous uploader implementation.
- Removes Attachment model's ability to upload files directly and
adjusts tests that expected that behavior.
Portfolio invitations do not associate a user entity until the
invitation has been accepted. User info, including DOD ID, is held on
the invitation itself. When a user accepts and invitation, their user
entry is associated with the corresponding `portfolio_role` entry.
The same change will be applied to `application_role` and application
invitations. For now, small changes have been made to
application-related methods so that that flow works as-is.
In the future, an `application_invitation1 will not refer to a `user` until
someone accepts the invitation; they'll only reference an
`application_role`. When a user is invited to an application, the
inviter can specify the environments the invitee should have access to.
For this to be possible, an `environment_role` should reference an
`application_role`, because no `user` entity will be known at that time.
In addition to updating all the models and domain methods necessary for
this change, this commit deletes unused code and tests that were
dependent on `environment_roles` having a `user_id` foreign key.
- Adds a property to ApplicationRole model so that it knows its related
EnvironmentRole models.
- Rewrite the form data builder in the routes file so that it loops the
application members and their environment roles to build the data
structure.
- add a base domain class
- extract shared model code to mixin
- rename invitation classes
- invitation model relationship to portfolio_role name is now more
generic "role"