Skip to content

Commit

Permalink
Resolves #10 using playhouse generic foreign keys
Browse files Browse the repository at this point in the history
  • Loading branch information
cimbalo committed Mar 9, 2017
1 parent 5cc4e5a commit 1eab1b0
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 11 deletions.
5 changes: 4 additions & 1 deletion models/authority.py
Original file line number Diff line number Diff line change
@@ -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 *

Expand All @@ -16,6 +17,8 @@

class Authority(customModel.CustomModel):

signed_certificates = ReverseGFK(Certificate, 'authority_type', 'authority_id')

request_allowed = []

# data stored in the database
Expand Down
10 changes: 4 additions & 6 deletions models/certificate.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,23 @@
#!/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 *


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,
Expand Down
2 changes: 1 addition & 1 deletion models/customModel.py
Original file line number Diff line number Diff line change
@@ -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'))
Expand Down
4 changes: 2 additions & 2 deletions models/ssh.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -103,7 +103,7 @@ def sign(self, request):
pub_key_path = request.destination

cert = Certificate(
signed_by = self,
authority = self,
cert_id = request.req_id,
date_issued = datetime.now(),
receiver = request.receiver,
Expand Down
2 changes: 1 addition & 1 deletion models/ssl.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from peewee import *
from playhouse.gfk import *

import os
import os.path
Expand Down

0 comments on commit 1eab1b0

Please sign in to comment.