summaryrefslogtreecommitdiff
path: root/db
diff options
context:
space:
mode:
Diffstat (limited to 'db')
-rw-r--r--db/create.sql6
-rw-r--r--db/models.py5
2 files changed, 2 insertions, 9 deletions
diff --git a/db/create.sql b/db/create.sql
index bb7ee35..4abdb33 100644
--- a/db/create.sql
+++ b/db/create.sql
@@ -46,19 +46,15 @@ create table user_in_group (
create table language (
id integer not null default nextval('language_id_seq'),
- name varchar(30) not null,
identifier varchar(30) not null,
constraint language_pk primary key (id),
- constraint language_uq1 unique (name),
constraint language_uq2 unique (identifier)
);
create table problem_group (
id integer not null default nextval('problem_group_id_seq'),
- name varchar(100) not null,
identifier varchar(100) not null,
constraint group_pk primary key (id),
- constraint group_uq1 unique (name),
constraint group_uq2 unique (identifier)
);
@@ -66,12 +62,10 @@ create table problem (
id integer not null default nextval('problem_id_seq'),
language_id integer not null,
problem_group_id integer not null,
- name varchar(100) not null,
identifier varchar(100) not null,
constraint problem_pk primary key (id),
constraint problem_fk1 foreign key (language_id) references language (id) on delete no action on update cascade,
constraint problem_fk2 foreign key (problem_group_id) references problem_group (id) on delete no action on update cascade,
- constraint problem_uq1 unique (language_id, problem_group_id, name),
constraint problem_uq2 unique (language_id, problem_group_id, identifier)
);
diff --git a/db/models.py b/db/models.py
index b8d64a1..17f9681 100644
--- a/db/models.py
+++ b/db/models.py
@@ -7,7 +7,6 @@ from . import get_connection, return_connection
__all__ = ['CodeqUser', 'Solution']
-
class CodeqUser(collections.namedtuple('CodeqUser', ['id', 'username', 'password', 'name', 'email', 'is_admin', 'is_active', 'date_joined', 'last_login'])):
__sql_prefix = 'select id, username, password, name, email, is_admin, is_active, date_joined, last_login from codeq_user'
@@ -27,8 +26,8 @@ class CodeqUser(collections.namedtuple('CodeqUser', ['id', 'username', 'password
def solved_problems(user_id, language):
return _run_sql('select g.identifier, p.identifier from solution s inner join problem p on p.id = s.problem_id inner join problem_group g on g.id = p.problem_group_id inner join language l on l.id = p.language_id where s.codeq_user_id = %s and l.identifier = %s and s.done = True', (user_id, language), fetch_one=False)
-class Problem(collections.namedtuple('Problem', ['id', 'language_id', 'problem_group_id', 'name', 'identifier'])):
- __sql_prefix = 'select id, language_id, problem_group_id, name, identifier from problem'
+class Problem(collections.namedtuple('Problem', ['id', 'language_id', 'problem_group_id', 'identifier'])):
+ __sql_prefix = 'select id, language_id, problem_group_id, identifier from problem'
@staticmethod
def get(**kwargs):