This repository has been archived on 2024-05-31. You can view files and clone it, but cannot push or open issues or pull requests.
2019-10-14 13:00:20 +00:00
|
|
|
"""policy structures"""
|
2019-10-07 14:33:48 +00:00
|
|
|
from __future__ import annotations
|
2019-10-07 14:50:13 +00:00
|
|
|
|
2019-10-04 07:50:25 +00:00
|
|
|
from typing import TYPE_CHECKING, List
|
2019-10-03 08:45:31 +00:00
|
|
|
|
|
|
|
from django.http import HttpRequest
|
|
|
|
|
2019-10-04 07:50:25 +00:00
|
|
|
if TYPE_CHECKING:
|
|
|
|
from passbook.core.models import User
|
2019-10-03 08:45:31 +00:00
|
|
|
|
|
|
|
class PolicyRequest:
|
|
|
|
"""Data-class to hold policy request data"""
|
|
|
|
|
2019-10-07 14:33:48 +00:00
|
|
|
user: User
|
2019-10-03 08:45:31 +00:00
|
|
|
http_request: HttpRequest
|
|
|
|
|
2019-10-07 14:33:48 +00:00
|
|
|
def __init__(self, user: User):
|
2019-10-03 08:45:31 +00:00
|
|
|
self.user = user
|
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
return f"<PolicyRequest user={self.user}>"
|
|
|
|
|
|
|
|
|
|
|
|
class PolicyResult:
|
|
|
|
"""Small data-class to hold policy results"""
|
|
|
|
|
|
|
|
passing: bool = False
|
|
|
|
messages: List[str] = []
|
|
|
|
|
|
|
|
def __init__(self, passing: bool, *messages: str):
|
|
|
|
self.passing = passing
|
|
|
|
self.messages = messages
|
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
return f"<PolicyResult passing={self.passing}>"
|