Skip to content

Commit

Permalink
Cleanup @deprecated that affect only tests
Browse files Browse the repository at this point in the history
  • Loading branch information
faebebin committed Aug 16, 2023
1 parent fe8338a commit a868277
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 170 deletions.
10 changes: 0 additions & 10 deletions docker-app/qfieldcloud/core/exceptions.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from deprecated import deprecated
from rest_framework import status


Expand Down Expand Up @@ -177,12 +176,3 @@ class ProjectAlreadyExistsError(QFieldCloudException):
code = "project_already_exists"
message = "This user already owns a project with the same name."
status_code = status.HTTP_400_BAD_REQUEST


@deprecated("moved to subscription")
class ReachedMaxOrganizationMembersError(QFieldCloudException):
"""Raised when an organization has exhausted its quota of members"""

code = "organization_has_max_number_of_members"
message = "Cannot add new organization members, account limit has been reached."
status_code = status.HTTP_403_FORBIDDEN
20 changes: 0 additions & 20 deletions docker-app/qfieldcloud/core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -415,11 +415,6 @@ def current_subscription(self):
Subscription = get_subscription_model()
return Subscription.get_or_create_current_subscription(self)

@property
@deprecated("Use `current_subscription` instead")
def active_subscription(self):
return self.current_subscription()

@property
def upcoming_subscription(self):
from qfieldcloud.subscription.models import get_subscription_model
Expand All @@ -437,13 +432,6 @@ def avatar_url(self):
else:
return None

@property
@deprecated("Use `UserAccount().storage_used_bytes` instead")
# TODO delete this method after refactoring tests so it's no longer used there
def storage_used_mb(self) -> float:
"""Returns the storage used in MB"""
return self.storage_used_bytes / 1000 / 1000

@property
def storage_used_bytes(self) -> float:
"""Returns the storage used in bytes"""
Expand All @@ -457,14 +445,6 @@ def storage_used_bytes(self) -> float:

return used_quota

@property
@deprecated("Use `UserAccount().storage_free_bytes` instead")
# TODO delete this method after refactoring tests so it's no longer used there
def storage_free_mb(self) -> float:
"""Returns the storage quota left in MB (quota from account and packages minus storage of all owned projects)"""

return self.storage_free_bytes / 1000 / 1000

@property
def storage_free_bytes(self) -> float:
"""Returns the storage quota left in bytes (quota from account and packages minus storage of all owned projects)"""
Expand Down
69 changes: 0 additions & 69 deletions docker-app/qfieldcloud/core/permissions_utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from typing import List, Literal, Union

from deprecated import deprecated
from django.utils.translation import gettext as _
from qfieldcloud.authentication.models import AuthToken
from qfieldcloud.core.models import (
Expand Down Expand Up @@ -336,33 +335,6 @@ def can_apply_pending_deltas_for_project(user: QfcUser, project: Project) -> boo
)


@deprecated("Use `can_set_delta_status_for_project` instead")
def can_apply_deltas(user: QfcUser, project: Project) -> bool:
return user_has_project_roles(
user,
project,
[
ProjectCollaborator.Roles.ADMIN,
ProjectCollaborator.Roles.MANAGER,
ProjectCollaborator.Roles.EDITOR,
ProjectCollaborator.Roles.REPORTER,
],
)


@deprecated("Use `can_set_delta_status_for_project` instead")
def can_overwrite_deltas(user: QfcUser, project: Project) -> bool:
return user_has_project_roles(
user,
project,
[
ProjectCollaborator.Roles.ADMIN,
ProjectCollaborator.Roles.MANAGER,
ProjectCollaborator.Roles.EDITOR,
],
)


def can_set_delta_status_for_project(user: QfcUser, project: Project) -> bool:
return user_has_project_roles(
user,
Expand Down Expand Up @@ -414,47 +386,6 @@ def can_create_delta(user: QfcUser, delta: Delta) -> bool:
return False


@deprecated("Use `can_set_delta_status` instead")
def can_retry_delta(user: QfcUser, delta: Delta) -> bool:
if not can_apply_deltas(user, delta.project):
return False

if delta.last_status not in (
Delta.Status.CONFLICT,
Delta.Status.NOT_APPLIED,
Delta.Status.ERROR,
):
return False

return True


@deprecated("Use `can_set_delta_status` instead")
def can_overwrite_delta(user: QfcUser, delta: Delta) -> bool:
if not can_overwrite_deltas(user, delta.project):
return False

if delta.last_status not in (Delta.Status.CONFLICT):
return False

return True


@deprecated("Use `can_set_delta_status` instead")
def can_ignore_delta(user: QfcUser, delta: Delta) -> bool:
if not can_apply_deltas(user, delta.project):
return False

if delta.last_status not in (
Delta.Status.CONFLICT,
Delta.Status.NOT_APPLIED,
Delta.Status.ERROR,
):
return False

return True


def can_read_jobs(user: QfcUser, project: Project) -> bool:
return user_has_project_roles(
user,
Expand Down
9 changes: 0 additions & 9 deletions docker-app/qfieldcloud/subscription/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,10 +368,6 @@ def current(self):

return qs

@deprecated("Use `current` instead. Remove this once parent repo uses current")
def active(self):
return self.current()

def managed_by(self, user_id: int):
"""Returns all subscriptions that are managed by given `user_id`. It means the owner personal account and all organizations they own.
Expand Down Expand Up @@ -698,11 +694,6 @@ def get_or_create_current_subscription(cls, account: UserAccount) -> "Subscripti

return subscription

@property
@deprecated("Use `get_or_create_current_subscription` instead")
def get_or_create_active_subscription(cls, account: UserAccount) -> "Subscription":
return cls.get_or_create_current_subscription(account)

@classmethod
def get_upcoming_subscription(cls, account: UserAccount) -> "Subscription":
result = (
Expand Down
Loading

0 comments on commit a868277

Please sign in to comment.