Skip to content
Snippets Groups Projects
Commit f63a8bdf authored by Martin Mareš's avatar Martin Mareš
Browse files

DB: "order" nebyl dobrý název sloupečku, musí se všude psát do uvozovek...

parent 6a5448e1
No related branches found
No related tags found
No related merge requests found
...@@ -71,12 +71,12 @@ CREATE TABLE rounds ( ...@@ -71,12 +71,12 @@ CREATE TABLE rounds (
round_id serial PRIMARY KEY, round_id serial PRIMARY KEY,
year int NOT NULL, -- ročník MO year int NOT NULL, -- ročník MO
category varchar(2) NOT NULL, -- "A", "Z5" apod. category varchar(2) NOT NULL, -- "A", "Z5" apod.
"order" int NOT NULL, -- 1=domácí kolo atd. seq int NOT NULL, -- 1=domácí kolo atd.
level int NOT NULL, -- úroveň hierarchie míst level int NOT NULL, -- úroveň hierarchie míst
name varchar(255) NOT NULL, -- zobrazované jméno ("Krajské kolo" apod.) name varchar(255) NOT NULL, -- zobrazované jméno ("Krajské kolo" apod.)
-- FIXME: termíny -- FIXME: termíny
-- FIXME: stav odevzdávání/opravování/... -- FIXME: stav odevzdávání/opravování/...
UNIQUE (year, category, "order") UNIQUE (year, category, seq)
); );
-- Detaily účastníka -- Detaily účastníka
......
INSERT INTO rounds(year, category, "order", level, name) VALUES INSERT INTO rounds(year, category, seq, level, name) VALUES
(1, 70, 'A', 1, 'Krajské kolo' , 3 ), (1, 70, 'A', 1, 'Krajské kolo' , 3 ),
(2, 70, 'A', 0, 'Ústrední kolo' , 4 ), (2, 70, 'A', 0, 'Ústrední kolo' , 4 ),
(3, 70, 'A', 4, 'Školní kolo (domácí)' , 1 ), (3, 70, 'A', 4, 'Školní kolo (domácí)' , 1 ),
......
...@@ -76,18 +76,18 @@ class School(Place): ...@@ -76,18 +76,18 @@ class School(Place):
class Round(Base): class Round(Base):
__tablename__ = 'rounds' __tablename__ = 'rounds'
__table_args__ = ( __table_args__ = (
UniqueConstraint('year', 'category', 'order'), UniqueConstraint('year', 'category', 'seq'),
) )
round_id = Column(Integer, primary_key=True, server_default=text("nextval('rounds_round_id_seq'::regclass)")) round_id = Column(Integer, primary_key=True, server_default=text("nextval('rounds_round_id_seq'::regclass)"))
year = Column(Integer, nullable=False) year = Column(Integer, nullable=False)
category = Column(String(2), nullable=False) category = Column(String(2), nullable=False)
order = Column(Integer, nullable=False) seq = Column(Integer, nullable=False)
level = Column(Integer, nullable=False) level = Column(Integer, nullable=False)
name = Column(String(255), nullable=False) name = Column(String(255), nullable=False)
def round_code(self): def round_code(self):
return f"{self.year}-{self.category}-{self.order}" return f"{self.year}-{self.category}-{self.seq}"
class User(Base): class User(Base):
......
...@@ -65,7 +65,7 @@ def org_users(): ...@@ -65,7 +65,7 @@ def org_users():
def org_contest_root(): def org_contest_root():
sess = db.get_session() sess = db.get_session()
rounds = sess.query(db.Round).filter_by(year=mo.current_year).order_by(db.Round.year, db.Round.category, db.Round.order) rounds = sess.query(db.Round).filter_by(year=mo.current_year).order_by(db.Round.year, db.Round.category, db.Round.seq)
return render_template('org_contest_root.html', rounds=rounds, level_names=mo.db.place_level_names) return render_template('org_contest_root.html', rounds=rounds, level_names=mo.db.place_level_names)
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
<table class=data> <table class=data>
<tr><td>Ročník<td>{{ round.year }} <tr><td>Ročník<td>{{ round.year }}
<tr><td>Kategorie<td>{{ round.category }} <tr><td>Kategorie<td>{{ round.category }}
<tr><td>Pořadí<td>{{ round.order }} <tr><td>Pořadí<td>{{ round.seq }}
<tr><td>Oblast<td>{{ level_names[round.level] }} <tr><td>Oblast<td>{{ level_names[round.level] }}
<tr><td>Název<td>{{ round.name }} <tr><td>Název<td>{{ round.name }}
</table> </table>
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
<td><a href='{{ url_for('org_contest', id=r.round_id) }}'>{{ r.round_code() }}</a> <td><a href='{{ url_for('org_contest', id=r.round_id) }}'>{{ r.round_code() }}</a>
<td>{{ r.year }} <td>{{ r.year }}
<td>{{ r.category }} <td>{{ r.category }}
<td>{{ r.order }} <td>{{ r.seq }}
<td>{{ level_names[r.level] }} <td>{{ level_names[r.level] }}
<td>{{ r.name }} <td>{{ r.name }}
{% endfor %} {% endfor %}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment