models
main.models
¤
Models module for main app.
Classes¤
AnalysisCode
¤
Capacity
¤
Bases: Model
Proportion of working time that team members are able to work on projects.
Classes¤
Meta
¤
Meta class for the model.
Functions¤
__str__()
¤
String representation of the Capacity object.
Source code in main/models.py
706 707 708 | |
Department
¤
Bases: Model
Model to manage the departments.
You can find the faculties and potential departments in:
https://www.imperial.ac.uk/faculties-and-departments/
FullTimeEquivalent
¤
Bases: Model
Full-time-equivalent model for user and projects.
Attributes¤
days
property
¤
Convert FTE to days using the working days in a year in the settings.
Classes¤
Meta
¤
Model metadata.
Functions¤
clean()
¤
Ensure start date comes before end date and that value 0 or positive.
Source code in main/models.py
924 925 926 927 928 929 930 931 932 933 | |
from_days(days, start_date, end_date, **kwargs)
classmethod
¤
Creates an FTE object given a number of days time period.
Source code in main/models.py
876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 | |
trace(timerange=None)
¤
Convert the FTE to a dataframe.
If timerange is provided, those dates are used, otherwise a datetime index is created using the start and end dates of the FTE object.
Source code in main/models.py
906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 | |
Funding
¤
Bases: Model
Funding associated with a project.
Attributes¤
effort
property
¤
Provide the effort in days, calculated based on the budget and daily rate.
Returns:
| Type | Description |
|---|---|
float
|
The total number of days of effort provided by the funding. |
effort_left
property
¤
Provide the effort left in days.
Returns:
| Type | Description |
|---|---|
float
|
The number of days worth of effort left. |
funding_left
property
¤
Provide the funding left in currency.
Funding left is calculated based on 'Confirmed' monthly charges.
Returns:
| Type | Description |
|---|---|
Decimal
|
The amount of funding left. |
project_code
property
¤
Provide the project code, containing the cost centre and activity code.
Returns:
| Type | Description |
|---|---|
str
|
The designated project code. |
Classes¤
Meta
¤
Meta class for the model.
Functions¤
__str__()
¤
String representation of the Funding object.
Source code in main/models.py
547 548 549 | |
clean()
¤
Ensure that the activity code has a valid value.
Source code in main/models.py
551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 | |
is_complete()
¤
Checks if funding record is complete.
This is only relevant to funding where source is external.
Source code in main/models.py
573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 | |
monthly_pro_rata_charge(date)
¤
Calculate the charge per month if the project has Pro-rata charging.
Calculates the number of months between project start and end date regardless of the day of the month so the monthly charge will be the same regardless of the number of days in the month.
The last month of the project is not charged, so the charge applies from the month of the start date until the month before the end date, to ensure that no charges are made outside of the project period. For example, if a project starts on 15th January and ends on 10th April, the charge will apply for January, February and March, but not April.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
date
|
date
|
The date for which to calculate the monthly charge, used to check if the project has started and hasn't ended yet. |
required |
Returns:
| Type | Description |
|---|---|
float | None
|
The monthly charge amount, or None if the project doesn't have Pro-rata |
float | None
|
charging or the date is outside the project period. |
Source code in main/models.py
636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 | |
MonthlyCharge
¤
Bases: Model
Monthly charge for a specific project, account and analysis code.
Functions¤
__str__()
¤
String representation of the MonthlyCharge object.
Source code in main/models.py
768 769 770 | |
clean()
¤
Ensure the charge has valid funding attached and description if Manual.
Source code in main/models.py
772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 | |
Project
¤
Bases: Warning, Model
Software project details.
Attributes¤
days_left
property
¤
Provide the days worth of effort left.
Returns:
| Type | Description |
|---|---|
tuple[float, float] | None
|
The number of days and percentage worth of effort left, or None if there is |
tuple[float, float] | None
|
no funding information. |
effort_per_day
property
¤
Calculate the estimated effort per day.
Considers only working (business) days.
Returns:
| Type | Description |
|---|---|
float | None
|
Float representing the estimated effort per day over project lifespan. |
percent_effort_left
property
¤
Provide the percentage of effort left.
Returns:
| Type | Description |
|---|---|
float | None
|
The percentage of effort left, or None if there is no funding information. |
total_effort
property
¤
Provide the total days worth of effort available from funding.
Returns:
| Type | Description |
|---|---|
float | None
|
The total number of days effort, or None if there is no funding information. |
total_funding_left
property
¤
Provide the total funding left after deducting confirmed charges.
Returns:
| Type | Description |
|---|---|
Decimal | None
|
The total monetary amount of funding left, or none if there is no funding |
Decimal | None
|
information. |
total_working_days
property
¤
Provide the total number of working (business) days given the dates.
Returns:
| Type | Description |
|---|---|
int | None
|
Number of working days between the project start and end date. |
weeks_to_deadline
property
¤
Provide the number of weeks left until project deadline.
Only relevant for active projects.
Returns:
| Type | Description |
|---|---|
tuple[int, float] | None
|
The number of weeks left or None if the project is Tentative or Not done. |
Functions¤
__str__()
¤
String representation of the Project object.
Source code in main/models.py
198 199 200 | |
check_and_notify_status()
¤
Check the project status and notify accordingly.
Source code in main/models.py
354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 | |
clean()
¤
Ensure all fields have a value unless status is 'Tentative' or 'Not done'.
It also checks that, if present, the end date is after the start date.
Source code in main/models.py
251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 | |
fte(timerange=None)
¤
Calculate the FTE trace for the project over a given timerange.
This is calculated by summing the trace of all the phases of the project, which are assumed to be sequential and non-overlapping.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
timerange
|
DatetimeIndex | None
|
The timerange to calculate the FTE trace over. |
None
|
Returns:
| Type | Description |
|---|---|
Series
|
A pandas Series with the FTE trace over the timerange, or a trace of 0 if |
Series
|
there are no phases. |
Source code in main/models.py
432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 | |
ProjectPhase
¤
Bases: FullTimeEquivalent
Phases associated with a project.
Functions¤
__str__()
¤
String representation of the ProjectPhase object.
Source code in main/models.py
943 944 945 | |
check_overlapping_phases()
¤
Check the phase doesn't overlap with another phase (by 1 day).
Source code in main/models.py
985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 | |
check_phase_alignment()
¤
Ensures phases are aligned but separated by 1 day.
Source code in main/models.py
1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 | |
check_phase_in_project()
¤
Ensure the start phase dates are within the project dates.
Source code in main/models.py
972 973 974 975 976 977 978 979 980 981 982 983 | |
check_project_funding()
¤
Check the project has funding before the phase can be added.
Source code in main/models.py
1033 1034 1035 1036 1037 1038 | |
clean()
¤
Ensures that phase dates are sensible.
Ensures start is before the end date (from FTE clean). Ensures phase within project period. Ensures the phase isn't covered by any other phases. Ensures at least phase start or end date aligns with other phases or project dates. Ensures project has funding before phase added.
Source code in main/models.py
1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 | |
save(**kwargs)
¤
Saves the object to the database.
This overwrites models.Model.save() to keep the days constant if the start or
end date changes, modifying the FTE value. Except if value has also changed in
the same modification.
Source code in main/models.py
947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 | |
TimeEntry
¤
Bases: Model
Time entry for a user.