test-platform/server/cgi/db/test.py

28 lines
898 B
Python
Raw Normal View History

2024-05-25 19:18:26 +03:00
from db.object_pool import ObjectPool
class Test:
def init(self, sID, name):
self.id = sID
self.name = name
return self
def init_from_data(self, data):
return self.init(*data)
def get_id(self):
return self.id
def get_name(self):
return self.name
def render_short(self):
2024-06-01 19:45:47 +03:00
return f'<div class="test-short"><a class="test-link" href="/index.py?mode=view-test&id={self.id}"><span class="sub-label">#{self.id}</span><span class="main-label">{self.name}</span></a><div class="controls"><a class="sub-button" href="?mode=edit-test&id={self.id}">Редагувати</a><a class="scary-button" href="?mode=delete-test&id={self.id}">Видалити</a></div></div>'
2024-05-25 19:18:26 +03:00
class TestPool:
def __init__(self, db):
self.object_pool = ObjectPool("test", Test)
if db:
self.object_pool.load_from_db(db)