-
Notifications
You must be signed in to change notification settings - Fork 401
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2ffe8e9
commit c92e824
Showing
4 changed files
with
49 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# TODO: split this into a private package? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import os | ||
from datetime import datetime | ||
|
||
from pydantic import BaseModel | ||
|
||
from organisations.models import UserOrganisation | ||
from projects.models import Project | ||
|
||
|
||
class LicenceInformation(BaseModel): | ||
licensee: str | ||
plan_id: str | ||
expiry_date: datetime | ||
|
||
# TODO: should these live in a nested object? | ||
num_seats: int | ||
num_projects: int # TODO: what about Flagsmith on Flagsmith project? | ||
|
||
def get_remaining_seats(self) -> int: | ||
return self.num_seats - UserOrganisation.objects.count() | ||
|
||
def get_remaining_projects(self) -> int: | ||
return self.num_projects - Project.objects.count() | ||
|
||
|
||
def licence_file_exists(licence_file_path: str = "") -> bool: | ||
return os.path.isfile(licence_file_path) | ||
|
||
|
||
def read_license_file(licence_file_path: str = "") -> LicenceInformation: | ||
return LicenceInformation.parse_file(licence_file_path) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters