-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow setting default and individual SU budgets for project members (#…
…437) * Allow setting default and individual SU budgets for project members This commit introduces the functionality to set default and individual SU budgets for project members. It includes the following changes: - Added models ChargeBudget to track individual SU budgets for users in projects. - Implemented set_budget_for_user_in_project function to set SU budgets for individual users in projects. - Added form inputs to allow setting default SU budgets for all non-manager users in a project. - Modified the view_project template to display current SU usage and budget inputs for project members. - Implemented backend logic to handle setting default and individual SU budgets in the view_project view. These changes enable project managers to manage SU budgets more effectively within projects. * Default SU budget for project * Refactor charge calculation and enforce project budgets Refactors the charge calculation logic in the allocations/models.py file for clarity. It introduces a utility function in balance_service/utils/su_calculators.py to calculate total SU usage for users in projects. Additionally, project budget enforcement is implemented. When adding users to projects in projects/membership.py, their budgets are updated to match the project's default budget. The projects/views.py file is updated to delete user budgets if they are assigned the manager role to ensure budget enforcement.
- Loading branch information
1 parent
b5bcbd5
commit f3ad018
Showing
9 changed files
with
396 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Generated by Django 3.2 on 2024-03-11 21:47 | ||
|
||
from django.conf import settings | ||
import django.core.validators | ||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('projects', '0021_project_default_su_budget'), | ||
migrations.swappable_dependency(settings.AUTH_USER_MODEL), | ||
('allocations', '0008_allocation_balance_service_version'), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='ChargeBudget', | ||
fields=[ | ||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('su_budget', models.IntegerField(default=0, validators=[django.core.validators.MinValueValidator(0)])), | ||
('project', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='projects.project')), | ||
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='projectbudgets', to=settings.AUTH_USER_MODEL)), | ||
], | ||
options={ | ||
'unique_together': {('user', 'project')}, | ||
}, | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Generated by Django 3.2 on 2024-03-11 21:47 | ||
|
||
import django.core.validators | ||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('projects', '0020_duplicate_publications'), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name='project', | ||
name='default_su_budget', | ||
field=models.IntegerField(default=0, validators=[django.core.validators.MinValueValidator(0)]), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.