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-03 08:45:31 +00:00
|
|
|
"""policy structs"""
|
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-04 07:50:25 +00:00
|
|
|
user: 'User'
|
2019-10-03 08:45:31 +00:00
|
|
|
http_request: HttpRequest
|
|
|
|
|
2019-10-04 07:50:25 +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}>"
|