Skip to content

Commit

Permalink
api: Expose service limits
Browse files Browse the repository at this point in the history
  • Loading branch information
nijel committed May 17, 2023
1 parent 56e5be6 commit 3142c4c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
8 changes: 8 additions & 0 deletions weblate_web/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -702,6 +702,14 @@ def create_backup(self):
self.backup_repository = create_backup_repository(self)
self.save(update_fields=["backup_repository"])

def get_limits(self):
return {
"hosted_words": self.limit_hosted_words,
"source_strings": self.limit_source_strings,
"projects": self.limit_projects,
"languages": self.limit_languages,
}

def check_in_limits(self):
if (
self.limit_hosted_words
Expand Down
2 changes: 2 additions & 0 deletions weblate_web/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ def api_hosted(request):
"expiry": service.expires,
"backup_repository": service.backup_repository,
"in_limits": service.check_in_limits(),
"limits": service.get_limits(),
}
)

Expand Down Expand Up @@ -270,6 +271,7 @@ def api_support(request):
"expiry": service.expires,
"backup_repository": service.backup_repository,
"in_limits": service.check_in_limits(),
"limits": service.get_limits(),
}
)

Expand Down

0 comments on commit 3142c4c

Please sign in to comment.