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
741 742 743 | |
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
961 962 963 964 965 966 967 968 969 970 | |
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
911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 | |
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
941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 | |
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
582 583 584 | |
clean()
¤
Ensure that the activity code has a valid value.
Source code in main/models.py
586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 | |
is_complete()
¤
Checks if funding record is complete.
This is only relevant to funding where source is external.
Source code in main/models.py
608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 | |
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
671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 | |
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
803 804 805 | |
clean()
¤
Ensure the charge has valid funding attached and description if Manual.
Source code in main/models.py
807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 | |
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
200 201 202 | |
check_and_notify_status()
¤
Check the project status and notify accordingly.
Source code in main/models.py
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 406 407 | |
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
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 278 279 | |
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
434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 | |
ProjectPhase
¤
Bases: FullTimeEquivalent
Phases associated with a project.
Attributes¤
expected_days_left
property
¤
Expected number of days left in the phase.
If the days were to be used homogeneously over the phase length, this function calculates how many days of effort are left from today. In phases that have not started (today < start date), the days left will be the total number of days, and phases that are gone (today > end date) the total number of days will be zero.
Functions¤
__str__()
¤
String representation of the ProjectPhase object.
Source code in main/models.py
980 981 982 | |
check_overlapping_phases()
¤
Check the phase doesn't overlap with another phase (by 1 day).
Source code in main/models.py
1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 | |
check_phase_alignment()
¤
Ensures phases are aligned but separated by 1 day.
Source code in main/models.py
1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 | |
check_phase_in_project()
¤
Ensure the start phase dates are within the project dates.
Source code in main/models.py
1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 | |
check_project_funding()
¤
Check the project has funding before the phase can be added.
Source code in main/models.py
1070 1071 1072 1073 1074 1075 | |
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
1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 | |
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
984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 | |
TimeEntry
¤
Bases: Model
Time entry for a user.