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

28 lines
706 B
Python

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):
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 TestPool:
def __init__(self, db):
self.object_pool = ObjectPool("test", Test)
if db:
self.object_pool.load_from_db(db)