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

use user limit to get org traffic limit #7405

Merged
merged 1 commit into from
Jan 21, 2025
Merged
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
10 changes: 4 additions & 6 deletions seahub/organizations/api/admin/info.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,13 @@
from seahub.api2.authentication import TokenAuthentication

from seahub.utils import get_org_traffic_by_month
from seahub.utils.ccnet_db import CcnetDB
from seahub.utils.file_size import get_file_size_unit, get_quota_from_string
from seahub.role_permissions.utils import get_enabled_role_permissions_by_role

from seahub.organizations.api.permissions import IsOrgAdmin
from seahub.organizations.models import OrgAdminSettings, \
OrgMemberQuota, FORCE_ADFS_LOGIN, DISABLE_ORG_ENCRYPTED_LIBRARY, \
DISABLE_ORG_USER_CLEAN_TRASH
DISABLE_ORG_USER_CLEAN_TRASH, OrgSettings
from seahub.organizations.settings import ORG_MEMBER_QUOTA_ENABLED, \
ORG_ENABLE_ADMIN_CUSTOM_NAME

Expand Down Expand Up @@ -94,12 +93,11 @@ def get_org_info(request, org_id):
info['traffic_this_month'] = get_org_traffic_by_month(org_id, current_date)

info['traffic_limit'] = ''
role_perm_dict = get_enabled_role_permissions_by_role()
org_role = OrgSettings.objects.get_role_by_org(request.user.org)
role_perm_dict = get_enabled_role_permissions_by_role(org_role)
monthly_rate_limit_per_user = role_perm_dict.get('monthly_rate_limit_per_user', '')
if monthly_rate_limit_per_user:
ccnet_db = CcnetDB()
user_count = ccnet_db.get_org_user_count(org_id)
traffic_limit = get_quota_from_string(monthly_rate_limit_per_user) * user_count
traffic_limit = get_quota_from_string(monthly_rate_limit_per_user) * member_quota
info['traffic_limit'] = traffic_limit

info['storage_quota'] = storage_quota
Expand Down
Loading