From bebe588fdf757bd81428ac9d558406665de7a481 Mon Sep 17 00:00:00 2001 From: Timotej Lazar Date: Thu, 20 Aug 2015 12:40:41 +0200 Subject: Add a data model for the problem table --- db/models.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/db/models.py b/db/models.py index dcd17af..9ebc155 100644 --- a/db/models.py +++ b/db/models.py @@ -23,6 +23,21 @@ class CodeqUser(collections.namedtuple('CodeqUser', ['id', 'username', 'password def filter(**kwargs): return _general_filter(kwargs, CodeqUser, CodeqUser.__sql_prefix) +class Problem(collections.namedtuple('Problem', ['id', 'language_id', 'problem_group_id', 'name', 'identifier', 'is_visible'])): + __sql_prefix = 'select id, language_id, problem_group_id, name, identifier, is_visible from problem' + + @staticmethod + def get(**kwargs): + return _general_get(kwargs, Problem, Problem.__sql_prefix) + + @staticmethod + def list(): + return _general_list(Problem, Problem.__sql_prefix) + + @staticmethod + def filter(**kwargs): + return _general_filter(kwargs, Problem, Problem.__sql_prefix) + # known as Attempt in the original code class Solution(collections.namedtuple('Solution', ['id', 'done', 'content', 'problem_id', 'codeq_user_id', 'trace'])): __sql_prefix = 'select id, done, content, problem_id, codeq_user_id, trace::text from solution' -- cgit v1.2.1