|
3 | 3 |
|
4 | 4 | import os |
5 | 5 | import datetime |
6 | | -from sqlalchemy import create_engine, Column, Integer, String, Boolean, DateTime, Date, Text |
| 6 | +from sqlalchemy import create_engine, Column, Integer, String, Boolean, DateTime, Date, Text, ForeignKey |
7 | 7 | from sqlalchemy.orm import sessionmaker, declarative_base |
8 | 8 | from sqlalchemy.types import BigInteger |
9 | 9 |
|
@@ -50,65 +50,44 @@ class Listable(Base): |
50 | 50 | chat_id = Column(String) |
51 | 51 | validated = Column(Boolean, default=False) |
52 | 52 | type = Column(String(50)) |
| 53 | + cubawiki_url = Column(String, nullable=True) # Specific to Obligatoria, null for others |
53 | 54 |
|
54 | 55 | __mapper_args__ = { |
55 | 56 | 'polymorphic_identity': 'listable', |
56 | 57 | 'polymorphic_on': type |
57 | 58 | } |
58 | 59 |
|
59 | 60 | class Obligatoria(Listable): |
60 | | - __tablename__ = 'obligatorias' |
61 | | - id = Column(Integer, primary_key=True) |
62 | | - listable_id = Column(Integer, autoincrement=True) |
63 | | - cubawiki_url = Column(String) |
64 | 61 | __mapper_args__ = { |
65 | 62 | 'polymorphic_identity': 'obligatoria', |
66 | 63 | } |
67 | 64 |
|
68 | 65 | class Optativa(Listable): |
69 | | - __tablename__ = 'optativas' |
70 | | - id = Column(Integer, primary_key=True) |
71 | | - listable_id = Column(Integer, autoincrement=True) |
72 | 66 | __mapper_args__ = { |
73 | 67 | 'polymorphic_identity': 'optativa', |
74 | 68 | } |
75 | 69 |
|
76 | 70 | class ECI(Listable): |
77 | | - __tablename__ = 'ecis' |
78 | | - id = Column(Integer, primary_key=True) |
79 | | - listable_id = Column(Integer, autoincrement=True) |
80 | 71 | __mapper_args__ = { |
81 | 72 | 'polymorphic_identity': 'eci', |
82 | 73 | } |
83 | 74 |
|
84 | 75 | class Otro(Listable): |
85 | | - __tablename__ = 'otros' |
86 | | - id = Column(Integer, primary_key=True) |
87 | | - listable_id = Column(Integer, autoincrement=True) |
88 | 76 | __mapper_args__ = { |
89 | 77 | 'polymorphic_identity': 'otro', |
90 | 78 | } |
91 | 79 |
|
92 | 80 | class Grupo(Listable): |
93 | | - __tablename__ = 'grupos' |
94 | | - id = Column(Integer, primary_key=True) |
95 | | - listable_id = Column(Integer, autoincrement=True) |
96 | 81 | __mapper_args__ = { |
97 | 82 | 'polymorphic_identity': 'grupo', |
98 | 83 | } |
99 | 84 |
|
100 | 85 | class GrupoOptativa(Listable): |
101 | | - __tablename__ = 'grupo_optativas' |
102 | | - id = Column(Integer, primary_key=True) |
103 | | - listable_id = Column(Integer, autoincrement=True) |
104 | 86 | __mapper_args__ = { |
105 | 87 | 'polymorphic_identity': 'grupo_optativa', |
106 | 88 | } |
107 | 89 |
|
108 | 90 | class GrupoOtros(Listable): |
109 | | - __tablename__ = 'grupo_otros' |
110 | | - id = Column(Integer, primary_key=True) |
111 | | - listable_id = Column(Integer, autoincrement=True) |
112 | 91 | __mapper_args__ = { |
113 | 92 | 'polymorphic_identity': 'grupo_otros', |
114 | 93 | } |
|
0 commit comments