diff options
author | Timotej Lazar <timotej.lazar@araneo.org> | 2015-08-20 12:40:41 +0200 |
---|---|---|
committer | Timotej Lazar <timotej.lazar@araneo.org> | 2015-08-20 12:40:41 +0200 |
commit | bebe588fdf757bd81428ac9d558406665de7a481 (patch) | |
tree | 39ac191aa495f769ca311e804a814b0113081afa | |
parent | 83fd8a32f663ddceb713d46fae3cf52df893123a (diff) |
Add a data model for the problem table
-rw-r--r-- | db/models.py | 15 |
1 files changed, 15 insertions, 0 deletions
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' |