Skip to content

Commit

Permalink
Merge pull request #476 from opengisch/can_change_additional_storage
Browse files Browse the repository at this point in the history
  • Loading branch information
suricactus authored Jan 20, 2023
2 parents 0be65d6 + d8c4020 commit c4ff6ba
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions docker-app/qfieldcloud/core/permissions_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -748,12 +748,22 @@ def can_read_billing(user: QfcUser, account: QfcUser) -> bool:
return False


def can_change_additional_storage(user, account):
if account.is_person:
return user_eq(user, account)
elif account.is_organization:
def can_change_additional_storage(user: QfcUser, subscription: Subscription) -> bool:
if not subscription.plan.is_storage_modifiable:
return False

# assuming that active until is the same as current_period_until
# TODO change this when yearly subscriptions are supported
if subscription.active_until:
return False

if subscription.account.user.is_person:
return user_eq(user, subscription.account.user)
elif subscription.account.user.is_organization:
return user_has_organization_role_origins(
user, account, [OrganizationQueryset.RoleOrigins.ORGANIZATIONOWNER]
user,
subscription.account,
[OrganizationQueryset.RoleOrigins.ORGANIZATIONOWNER],
)

return False
Expand Down

0 comments on commit c4ff6ba

Please sign in to comment.