Skip to content

Commit d75ac60

Browse files
committed
example rearangment
1 parent 982dd19 commit d75ac60

27 files changed

Lines changed: 1385 additions & 678 deletions

db/models.py

Lines changed: 23 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1356,19 +1356,9 @@ class SBS(Base):
13561356
discourses_sutta: Mapped[str] = mapped_column(default="")
13571357
discourses_example: Mapped[str] = mapped_column(default="")
13581358

1359-
# TODO remove after filling class and discourses
13601359
extra_source: Mapped[str] = mapped_column(default="")
13611360
extra_sutta: Mapped[str] = mapped_column(default="")
13621361
extra_example: Mapped[str] = mapped_column(default="")
1363-
# sbs_chant_pali_3: Mapped[str] = mapped_column(default="")
1364-
# sbs_chant_eng_3: Mapped[str] = mapped_column(default="")
1365-
# sbs_chapter_3: Mapped[str] = mapped_column(default="")
1366-
# sbs_source_4: Mapped[str] = mapped_column(default="")
1367-
# sbs_sutta_4: Mapped[str] = mapped_column(default="")
1368-
# sbs_example_4: Mapped[str] = mapped_column(default="")
1369-
# sbs_chant_pali_4: Mapped[str] = mapped_column(default="")
1370-
# sbs_chant_eng_4: Mapped[str] = mapped_column(default="")
1371-
# sbs_chapter_4: Mapped[str] = mapped_column(default="")
13721362

13731363
@declared_attr
13741364
def sbs_index(cls):
@@ -1395,10 +1385,8 @@ def needs_sbs_example_button(self) -> bool:
13951385
return any(
13961386
example and example.strip()
13971387
for example in (
1398-
self.sbs_example_1,
1399-
self.sbs_example_2,
1400-
# self.sbs_example_3,
1401-
# self.sbs_example_4,
1388+
self.sbs_example_1 if self.sbs_chapter_1 else "",
1389+
self.sbs_example_2 if self.sbs_chapter_1 else "",
14021390
self.dhp_example,
14031391
self.pat_example,
14041392
self.vib_example,
@@ -1412,10 +1400,8 @@ def needs_sbs_example(self) -> bool:
14121400
return any(
14131401
example and example.strip()
14141402
for example in (
1415-
self.sbs_example_1,
1416-
self.sbs_example_2,
1417-
# self.sbs_example_3,
1418-
# self.sbs_example_4,
1403+
self.sbs_example_1 if self.sbs_chapter_1 else "",
1404+
self.sbs_example_2 if self.sbs_chapter_1 else "",
14191405
)
14201406
)
14211407

@@ -1424,16 +1410,15 @@ def needs_sbs_example(self) -> bool:
14241410
def needs_dhp_example(self) -> bool:
14251411
if self.dhp_example:
14261412
examples = [
1427-
self.sbs_example_1,
1428-
self.sbs_example_2,
1429-
# self.sbs_example_3,
1430-
# self.sbs_example_4,
1413+
self.sbs_example_1 if self.sbs_chapter_1 else "",
1414+
self.sbs_example_2 if self.sbs_chapter_1 else "",
1415+
self.class_example,
14311416
]
14321417
if not any(examples):
14331418
return True
14341419
for example in examples:
14351420
if example and paragraphs_are_similar(
1436-
clean_machine(example), clean_machine(self.dhp_example), 0.9
1421+
clean_machine(example), clean_machine(self.dhp_example), 0.8
14371422
):
14381423
return False
14391424
return True
@@ -1443,16 +1428,15 @@ def needs_dhp_example(self) -> bool:
14431428
def needs_pat_example(self) -> bool:
14441429
if self.pat_example:
14451430
examples = [
1446-
self.sbs_example_1,
1447-
self.sbs_example_2,
1448-
# self.sbs_example_3,
1449-
# self.sbs_example_4,
1431+
self.sbs_example_1 if self.sbs_chapter_1 else "",
1432+
self.sbs_example_2 if self.sbs_chapter_1 else "",
1433+
self.class_example,
14501434
]
14511435
if not any(examples):
14521436
return True
14531437
for example in examples:
14541438
if example and paragraphs_are_similar(
1455-
clean_machine(example), clean_machine(self.pat_example), 0.9
1439+
clean_machine(example), clean_machine(self.pat_example), 0.8
14561440
):
14571441
return False
14581442
return True
@@ -1462,16 +1446,15 @@ def needs_pat_example(self) -> bool:
14621446
def needs_vib_example(self) -> bool:
14631447
if self.vib_example:
14641448
examples = [
1465-
self.sbs_example_1,
1466-
self.sbs_example_2,
1467-
# self.sbs_example_3,
1468-
# self.sbs_example_4,
1449+
self.sbs_example_1 if self.sbs_chapter_1 else "",
1450+
self.sbs_example_2 if self.sbs_chapter_1 else "",
1451+
self.class_example,
14691452
]
14701453
if not any(examples):
14711454
return True
14721455
for example in examples:
14731456
if example and paragraphs_are_similar(
1474-
clean_machine(example), clean_machine(self.vib_example), 0.9
1457+
clean_machine(example), clean_machine(self.vib_example), 0.8
14751458
):
14761459
return False
14771460
return True
@@ -1481,20 +1464,14 @@ def needs_vib_example(self) -> bool:
14811464
def needs_class_example(self) -> bool:
14821465
if self.class_example:
14831466
examples = [
1484-
self.sbs_example_1,
1485-
self.sbs_example_2,
1486-
# self.sbs_example_3,
1487-
# self.sbs_example_4,
1488-
self.dhp_example,
1489-
self.pat_example,
1490-
self.vib_example,
1491-
self.discourses_example,
1467+
self.sbs_example_1 if self.sbs_chapter_1 else "",
1468+
self.sbs_example_2 if self.sbs_chapter_1 else "",
14921469
]
14931470
if not any(examples):
14941471
return True
14951472
for example in examples:
14961473
if example and paragraphs_are_similar(
1497-
clean_machine(example), clean_machine(self.class_example), 0.9
1474+
clean_machine(example), clean_machine(self.class_example), 0.8
14981475
):
14991476
return False
15001477
return True
@@ -1504,16 +1481,15 @@ def needs_class_example(self) -> bool:
15041481
def needs_discourses_example(self) -> bool:
15051482
if self.discourses_example:
15061483
examples = [
1507-
self.sbs_example_1,
1508-
self.sbs_example_2,
1509-
# self.sbs_example_3,
1510-
# self.sbs_example_4,
1484+
self.sbs_example_1 if self.sbs_chapter_1 else "",
1485+
self.sbs_example_2 if self.sbs_chapter_1 else "",
1486+
self.class_example,
15111487
]
15121488
if not any(examples):
15131489
return True
15141490
for example in examples:
15151491
if example and paragraphs_are_similar(
1516-
clean_machine(example), clean_machine(self.discourses_example), 0.9
1492+
clean_machine(example), clean_machine(self.discourses_example), 0.8
15171493
):
15181494
return False
15191495
return True
@@ -1530,16 +1506,6 @@ def sbs_chant_link_2(self):
15301506
chant_link_map = SBS_table_tools().load_chant_link_map()
15311507
return chant_link_map.get(self.sbs_chant_pali_2, "")
15321508

1533-
# @property
1534-
# def sbs_chant_link_3(self):
1535-
# chant_link_map = SBS_table_tools().load_chant_link_map()
1536-
# return chant_link_map.get(self.sbs_chant_pali_3, "")
1537-
1538-
# @property
1539-
# def sbs_chant_link_4(self):
1540-
# chant_link_map = SBS_table_tools().load_chant_link_map()
1541-
# return chant_link_map.get(self.sbs_chant_pali_4, "")
1542-
15431509
@property
15441510
def sbs_class_link(self):
15451511
class_link_map = SBS_table_tools().load_class_link_map()
@@ -1563,14 +1529,6 @@ def sbs_source_link_1(self) -> str:
15631529
def sbs_source_link_2(self) -> str:
15641530
return generate_link(self.sbs_source_2) if self.sbs_source_2 else ""
15651531

1566-
# @property
1567-
# def sbs_source_link_3(self) -> str:
1568-
# return generate_link(self.sbs_source_3) if self.sbs_source_3 else ""
1569-
1570-
# @property
1571-
# def sbs_source_link_4(self) -> str:
1572-
# return generate_link(self.sbs_source_4) if self.sbs_source_4 else ""
1573-
15741532
@property
15751533
def dhp_source_link(self) -> str:
15761534
return generate_link(self.dhp_source) if self.dhp_source else ""

0 commit comments

Comments
 (0)