Browse Source

Resolves #10 using playhouse generic foreign keys

master
Andrea Cimbalo 7 years ago
parent
commit
1eab1b0479
5 changed files with 12 additions and 11 deletions
  1. +4
    -1
      models/authority.py
  2. +4
    -6
      models/certificate.py
  3. +1
    -1
      models/customModel.py
  4. +2
    -2
      models/ssh.py
  5. +1
    -1
      models/ssl.py

+ 4
- 1
models/authority.py View File

@ -1,12 +1,13 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from peewee import *
from playhouse.gfk import *
import os
import os.path
from models import customModel
from models.certificate import Certificate
from paths import *
@ -16,6 +17,8 @@ Module of base classes to handle authorities
class Authority(customModel.CustomModel):
signed_certificates = ReverseGFK(Certificate, 'authority_type', 'authority_id')
request_allowed = []
# data stored in the database


+ 4
- 6
models/certificate.py View File

@ -1,14 +1,13 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from peewee import *
from playhouse.gfk import *
import os
import json
from models import customModel
from models.authority import Authority
from paths import *
@ -16,10 +15,9 @@ class Certificate(customModel.CustomModel):
"""
"""
signed_by = ForeignKeyField(
Authority,
related_name = 'signed_certificates',
)
authority_type = CharField(null=True)
authority_id = IntegerField(null=True)
authority = GFKField('authority_type', 'authority_id')
cert_id = CharField(
index = True,


+ 1
- 1
models/customModel.py View File

@ -1,5 +1,5 @@
from paths import *
from peewee import *
from playhouse.gfk import *
import os
custom_db = SqliteDatabase(os.path.join(MANAGER_PATH, 'ca_manager.db'))


+ 2
- 2
models/ssh.py View File

@ -1,7 +1,7 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from peewee import *
from playhouse.gfk import *
from datetime import datetime
import os.path
@ -103,7 +103,7 @@ class SSHAuthority(Authority):
pub_key_path = request.destination
cert = Certificate(
signed_by = self,
authority = self,
cert_id = request.req_id,
date_issued = datetime.now(),
receiver = request.receiver,


+ 1
- 1
models/ssl.py View File

@ -1,7 +1,7 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from peewee import *
from playhouse.gfk import *
import os
import os.path


Loading…
Cancel
Save