Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Size column #1023

Merged
merged 5 commits into from Mar 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,4 @@ Please add a _short_ line describing the PR you make, if the PR implements a spe
- Correct response about project being created when email validation fails for users ([#1014](https://github.com/ScilifelabDataCentre/dds_web/pull/1014))
- Introduced an additional validator `dds_web.utils.contains_disallowed_characters` to fix issue [#1007](https://github.com/scilifelabdatacentre/dds_web/issues/1007) ([#1021](https://github.com/ScilifelabDataCentre/dds_web/pull/1021)).
- Fix regex for listing and deleting files [#1029](https://github.com/scilifelabdatacentre/dds_web/issues/1029)
- Hides the "Size" and "total_size" variables according to the role and project status ([#1032](https://github.com/ScilifelabDataCentre/dds_web/pull/1032)).
16 changes: 10 additions & 6 deletions dds_web/api/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,13 +310,15 @@ def get(self):
"PI": p.pi,
"Status": p.current_status,
"Last updated": p.date_updated if p.date_updated else p.date_created,
"Size": p.size,
}

# Get proj size and update total size
proj_size = p.size
total_size += proj_size
project_info["Size"] = proj_size
if (
current_user.role == "Researcher" and p.current_status == "Available"
) or current_user.role != "Researcher":
# Get proj size and update total size
proj_size = p.size
total_size += proj_size
project_info["Size"] = proj_size

if usage:
proj_bhours, proj_cost = self.project_usage(project=p)
Expand All @@ -334,9 +336,11 @@ def get(self):
"usage": total_bhours_db,
"cost": total_cost_db,
},
"total_size": total_size,
}

if total_size or current_user.role in ["Unit Admin", "Unit Personnel"]:
return_info["total_size"] = total_size

return return_info

@staticmethod
Expand Down