This commit is contained in:
Christopher T. Johnson
2025-02-12 10:47:56 -05:00
parent 860cbe8ff0
commit e498769db7
4 changed files with 45 additions and 34 deletions

View File

@@ -34,9 +34,9 @@ class docketModel(QAbstractTableModel):
if not query.exec():
query_error(query)
while query.next():
date = query.value('date')
date = query.value("date")
assert isinstance(date, QDate)
row = [date.toString('MMMM d, yyyy'), query.value(3)]
row = [date.toString("MMMM d, yyyy"), query.value(3)]
self.entries.append(row)
q2.bindValue(":eid", query.value("entry_id"))
if not q2.exec():

View File

@@ -1,7 +1,7 @@
from datetime import date, datetime
from decimal import Decimal
from pony.orm import (
from pony.orm import ( # type: ignore[import-untyped]
Database,
LongStr,
Optional,
@@ -16,7 +16,7 @@ db = Database
db = Database()
class Cases(db.Entity):
class Cases(db.Entity): # type: ignore[name-defined]
case_id = PrimaryKey(int, auto=True)
docket_id = Required(str)
petitioners = Required(str)
@@ -24,28 +24,32 @@ class Cases(db.Entity):
date = Required(date)
active = Required(bool)
entries = Set("Entries")
lhs_id = Set('Cases', column='lhs')
rhs_id = Set('Cases', column='rhs')
lhs_id = Set("Cases", column="lhs")
rhs_id = Set("Cases", column="rhs")
class Entries(db.Entity):
class Entries(db.Entity): # type: ignore[name-defined]
entry_id = PrimaryKey(int, auto=True)
case_id = Required(Cases)
date = Required(date)
text = Required(LongStr)
documents = Set('Documents')
documents = Set("Documents")
class Documents(db.Entity):
class Documents(db.Entity): # type: ignore[name-defined]
document_id = PrimaryKey(int, auto=True)
entry_id = Required(Entries)
name = Required(str)
url = Required(LongStr)
class History(db.Entity):
class History(db.Entity): # type: ignore[name-defined]
history_id = PrimaryKey(int, auto=True)
year = Required(str, max_len=3)
edocket = Required(bool)
number = Required(int)
set_sql_debug(True)
db.bind(
provider="mysql",

View File

@@ -81,14 +81,16 @@ class documentDelegate(QStyledItemDelegate):
return
def eventFilter(self, object: QObject, event: QEvent) -> bool:
if event.type() in [ QEvent.Type.MouseButtonPress,
QEvent.Type.MouseButtonRelease]:
if event.type() in [
QEvent.Type.MouseButtonPress,
QEvent.Type.MouseButtonRelease,
]:
return False
return super().eventFilter(object, event)
def event(self, ev:QEvent) -> bool:
def event(self, ev: QEvent) -> bool:
print(ev)
return super(documentDelegate,self).event(ev)
return super(documentDelegate, self).event(ev)
def paint(
self,
@@ -226,6 +228,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
model.setQuery(query)
return
def main() -> int:
#
app = QApplication(sys.argv)
@@ -236,6 +239,7 @@ def main() -> int:
db.setPassword("lechOtvirf8Om/")
db.open()
import lib.dbConfig
window = MainWindow()
return app.exec()

View File

@@ -156,7 +156,7 @@ def update_db(case_id: str, db: QSqlDatabase) -> int:
assert isinstance(tmp, str)
matches = re.match(r"(No.)?\s*(\d+[-A]\d+).*$", tmp)
assert matches is not None
print(matches,matches.groups())
print(matches, matches.groups())
docket_id = matches.group(2)
print(f"Found {docket_id}")
@@ -188,13 +188,13 @@ def update_db(case_id: str, db: QSqlDatabase) -> int:
assert isinstance(tr, Tag) and isinstance(tr.contents[1], Tag)
td = tr.contents[1]
assert isinstance(td, Tag)
if td.string is None:
tmp = datetime.datetime(year=1776, month=7, day=4)
else:
docket_date = td.string.strip()
tmp = dateparser.parse(docket_date)
assert isinstance(tmp, datetime.datetime)
date = QDateTime.fromSecsSinceEpoch(int(tmp.timestamp()))
docket_date = td.string
if docket_date is None:
docket_date = "July 7, 1776"
tmp = dateparser.parse(docket_date) # type: ignore[assignment]
assert tmp is not None
date = QDateTime.fromSecsSinceEpoch(int(tmp.timestamp())) # type: ignore[assignment, attr-defined]
#
# linked case is row 3, column 0
@@ -224,7 +224,7 @@ def update_db(case_id: str, db: QSqlDatabase) -> int:
# If there is a linked case, we need to get the ID for that case.
if linked is not None:
linked = linked.replace("Linked with ", "")
for did in linked.split(','):
for did in linked.split(","):
did = did.strip()
query.prepare("SELECT * FROM cases WHERE docket_id = :did")
query.bindValue(":did", linked)
@@ -235,19 +235,22 @@ def update_db(case_id: str, db: QSqlDatabase) -> int:
if linked_id <= 0:
raise Exception(f"Unable to create linked case: {did}")
else:
linked_id = query.value('case_id')
linked_id = query.value("case_id")
#
#
query.prepare("SELECT * FROM cases_cases WHERE lhs = :lhs "
"AND rhs = :rhs")
query.bindValue(':lhs', case_id)
query.bindValue(':rhs', linked_id)
query.prepare(
"SELECT * FROM cases_cases WHERE lhs = :lhs " "AND rhs = :rhs"
)
query.bindValue(":lhs", case_id)
query.bindValue(":rhs", linked_id)
if not query.exec():
query_error(query)
if not query.next():
query.prepare("INSERT INTO cases_cases (lhs, rhs) "
"VALUES ( :lhs, :rhs)")
query.prepare(
"INSERT INTO cases_cases (lhs, rhs) "
"VALUES ( :lhs, :rhs)"
)
query.bindValue(":lhs", case_id)
query.bindValue(":rhs", linked_id)
if not query.exec():