55 lines
1.1 KiB
Python
55 lines
1.1 KiB
Python
|
from peewee import *
|
||
|
from playhouse.sqlcipher_ext import SqlCipherDatabase
|
||
|
|
||
|
db = SqlCipherDatabase(None)
|
||
|
|
||
|
|
||
|
class Person(Model):
|
||
|
id = AutoField()
|
||
|
first_name = CharField()
|
||
|
last_name = CharField()
|
||
|
date = DateField()
|
||
|
|
||
|
class Meta:
|
||
|
database = db
|
||
|
|
||
|
|
||
|
class Resource(Model):
|
||
|
id = AutoField()
|
||
|
name = CharField()
|
||
|
|
||
|
class Meta:
|
||
|
database = db
|
||
|
|
||
|
|
||
|
class Role(Model):
|
||
|
id = AutoField()
|
||
|
name = CharField()
|
||
|
description = CharField()
|
||
|
|
||
|
class Meta:
|
||
|
database = db
|
||
|
|
||
|
|
||
|
class Permission(Model):
|
||
|
id = AutoField()
|
||
|
name = CharField()
|
||
|
idResource = ForeignKeyField(Resource, related_name='has_permission')
|
||
|
idRole = ForeignKeyField(Role, related_name='has_permission')
|
||
|
description = CharField()
|
||
|
|
||
|
class Meta:
|
||
|
database = db
|
||
|
|
||
|
|
||
|
class UserAccount(Model):
|
||
|
id = AutoField()
|
||
|
username = CharField()
|
||
|
idPerson = ForeignKeyField(Person, related_name='has_user_account')
|
||
|
idResource = ForeignKeyField(Resource, related_name='has_user_account')
|
||
|
idRole = ForeignKeyField(Role, related_name='has_user_account')
|
||
|
date = DateField()
|
||
|
|
||
|
class Meta:
|
||
|
database = db
|