Skip to content

Commit

Permalink
عدم السماح بالحذف الشجري، يجب حذف الأطراف ثم الفروع وذلك لحماية البيانات
Browse files Browse the repository at this point in the history
  • Loading branch information
vzool committed Oct 14, 2024
1 parent 33c1582 commit c88e7e6
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions zakat/zakat_tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -2498,10 +2498,10 @@ class Account(db.Entity):
zakatable = pony.Optional(bool, default=True)
created_at = pony.Required(datetime.datetime, default=lambda: datetime.datetime.now())
updated_at = pony.Optional(datetime.datetime)
box = pony.Set('Box')
log = pony.Set('Log')
exchange = pony.Set('Exchange')
history = pony.Set('History')
box = pony.Set('Box', cascade_delete=False)
log = pony.Set('Log', cascade_delete=False)
exchange = pony.Set('Exchange', cascade_delete=False)
history = pony.Set('History', cascade_delete=False)


class Box(db.Entity):
Expand Down Expand Up @@ -2529,7 +2529,7 @@ class Log(db.Entity):
desc = pony.Required(pony.LongStr)
ref = pony.Optional(int, size=64)
created_at = pony.Required(datetime.datetime, default=lambda: datetime.datetime.now())
file = pony.Set('File')
file = pony.Set('File', cascade_delete=False)


class File(db.Entity):
Expand Down Expand Up @@ -2559,15 +2559,15 @@ class Action(db.Entity):
id = pony.PrimaryKey(int, auto=True)
name = pony.Required(str, unique=True)
created_at = pony.Required(datetime.datetime, default=lambda: datetime.datetime.now())
history = pony.Set('History')
history = pony.Set('History', cascade_delete=False)


class Math(db.Entity):
_table_ = 'math'
id = pony.PrimaryKey(int, auto=True)
name = pony.Required(str, unique=True)
created_at = pony.Required(datetime.datetime, default=lambda: datetime.datetime.now())
history = pony.Set('History')
history = pony.Set('History', cascade_delete=False)


class History(db.Entity):
Expand Down Expand Up @@ -2989,7 +2989,9 @@ def recall(self, dry=True, debug=False) -> bool:
pass

def reset(self) -> None:
pass
db.drop_all_tables(with_all_data=True)
db.create_tables()
SQLModel.create_db()

def check(self, silver_gram_price: float, unscaled_nisab: float | int | Decimal = None, debug: bool = False,
now: int = None, cycle: float = None) -> tuple:
Expand Down Expand Up @@ -3656,7 +3658,7 @@ def _test_core(self, restore=False, debug=False):
account_xz_ref, account_xz_name = self.db.account(name='xz')
assert account_xz_ref == 27
assert account_xz_name == 'xz'
assert self.db.account(ref=321) is None
assert self.db.account(ref=123) is None
use_same_account_name_failed = False
try:
self.db.account(name='z', ref=321)
Expand Down Expand Up @@ -3885,7 +3887,7 @@ def _test_core(self, restore=False, debug=False):
if debug:
print('history-count', count)
assert count == 0
self.db.reset()
self.db.reset()

def test(self, debug: bool = False) -> bool:
if debug:
Expand Down

0 comments on commit c88e7e6

Please sign in to comment.