-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: added BaseStrictTable for Golongan & Keizinan
- Loading branch information
Showing
3 changed files
with
38 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,27 @@ | ||
from peewee import TextField | ||
import enum | ||
|
||
from samudra.models.base import BaseTable | ||
from peewee import TextField, BooleanField, ForeignKeyField | ||
|
||
from samudra.models.base import BaseTable, BaseStrictTable | ||
|
||
|
||
class RoleEnum(enum.Enum): | ||
DEFAULT = 'BIASA' | ||
|
||
|
||
class Keizinan(BaseStrictTable): | ||
peranan = TextField(null=False, unique=True) | ||
baca = BooleanField(null=False) | ||
ubah = BooleanField(null=False) | ||
tambah = BooleanField(null=False) | ||
buang = BooleanField(null=False) | ||
|
||
|
||
class Pengguna(BaseTable): | ||
nama = TextField(null=False) | ||
kunci = TextField(null=False) | ||
peranan = ForeignKeyField(model=Keizinan, field=Keizinan.peranan, backref='pengguna', | ||
on_delete='set default', default=RoleEnum.DEFAULT.value) | ||
|
||
def __repr__(self) -> str: | ||
return f"<model.{self.__class__.__name__}: id={self.id} nama={self.nama} kunci={self.kunci}>" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters