Revize 5b57121e
Přidáno uživatelem Michal Seják před téměř 4 roky(ů)
src/model/subject.py | ||
---|---|---|
1 | 1 |
class Subject: |
2 |
ATTR_MAP = {"C": "common_name", "ST": "state", "L": "locality", "CN": "common_name", "O": "organization", |
|
3 |
"OU": "organization_unit", "emailAddress": "email_address"} |
|
2 | 4 |
|
3 | 5 |
def __init__(self, common_name=None, country=None, locality=None, state=None, organization=None, |
4 | 6 |
organization_unit=None, email_address=None): |
... | ... | |
9 | 11 |
self.organization = organization |
10 | 12 |
self.organization_unit = organization_unit |
11 | 13 |
self.email_address = email_address |
14 |
|
|
15 |
@staticmethod |
|
16 |
def from_dict(d): |
|
17 |
if not isinstance(d, dict): |
|
18 |
return None |
|
19 |
|
|
20 |
s = Subject() |
|
21 |
for k, v in Subject.ATTR_MAP.items(): |
|
22 |
if k in d: |
|
23 |
if not isinstance(d[k], str): |
|
24 |
return None |
|
25 |
s.__setattr__(v, d[k]) |
|
26 |
|
|
27 |
return s |
Také k dispozici: Unified diff
Re #8476 - Refactored the application; swagger is not used for code generation anymore, REST API is being implemented from scratch. Migration only, fixing tests.