uploads: Show used upload space in attachments UI.

This commit is contained in:
Vishnu Ks
2019-01-17 16:35:09 +05:30
committed by Tim Abbott
parent cc4774f371
commit a288cfc43a
10 changed files with 66 additions and 24 deletions

View File

@@ -8,8 +8,10 @@ from zerver.lib.attachments import user_attachments, remove_attachment, \
def list_by_user(request: HttpRequest, user_profile: UserProfile) -> HttpResponse:
return json_success({"attachments": user_attachments(user_profile)})
return json_success({
"attachments": user_attachments(user_profile),
"upload_space_used": user_profile.realm.currently_used_upload_space_bytes(),
})
def remove(request: HttpRequest, user_profile: UserProfile, attachment_id: str) -> HttpResponse:
attachment = access_attachment_by_id(user_profile, int(attachment_id),
@@ -17,6 +19,3 @@ def remove(request: HttpRequest, user_profile: UserProfile, attachment_id: str)
remove_attachment(user_profile, attachment)
notify_attachment_update(user_profile, "remove", {"id": int(attachment_id)})
return json_success()
def upload_space_used(request: HttpRequest, user_profile: UserProfile) -> HttpResponse:
return json_success({"upload_space_used": user_profile.realm.currently_used_upload_space_bytes()})