Skip to content

Commit e97b599

Browse files
authored
Merge branch 'main' into opentelemetry
2 parents 86ab743 + 2031885 commit e97b599

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+3514
-2400
lines changed

.pythonstartup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
initialize_db()
1212

1313
# Make it easier to do session stuff at the command line
14-
session = Session().session
14+
session = Session()
1515

1616
if c.DEV_BOX:
1717
admin = session.query(AdminAccount).filter(

alembic/env.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import logging
44
import sys
5+
import sqlmodel
56
from logging.config import fileConfig
67
from alembic import context
78

@@ -24,19 +25,21 @@
2425
logger = logging.getLogger('alembic.env')
2526

2627
# Add the model's MetaData object here for "autogenerate" support.
27-
target_metadata = Session.BaseClass.metadata
28+
target_metadata = uber.models.MagModel.metadata
2829

2930

3031
def include_object(object, name, type_, reflected, compare_to):
3132
"""Exclude alembic's own version tables from alembic's consideration."""
32-
return not name.startswith('alembic_version')
33+
return not name or not name.startswith('alembic_version')
3334

3435

3536
def render_item(type_, obj, autogen_context):
3637
"""Apply custom rendering for selected items."""
3738
if type_ == 'type':
3839
if isinstance(obj, Choice):
3940
return 'sa.Integer()'
41+
if isinstance(obj, sqlmodel.sql.sqltypes.AutoString):
42+
return 'sa.Unicode()'
4043
# Default rendering for other objects
4144
return False
4245

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
"""Add missing columns from SQLAlchemy upgrade
2+
3+
Revision ID: 3d942ce689fc
4+
Revises: 5a0e898174d4
5+
Create Date: 2026-02-05 16:34:19.803186
6+
7+
"""
8+
9+
10+
# revision identifiers, used by Alembic.
11+
revision = '3d942ce689fc'
12+
down_revision = '5a0e898174d4'
13+
branch_labels = None
14+
depends_on = None
15+
16+
from alembic import op
17+
import sqlalchemy as sa
18+
from sqlalchemy.dialects import postgresql
19+
20+
21+
try:
22+
is_sqlite = op.get_context().dialect.name == 'sqlite'
23+
except Exception:
24+
is_sqlite = False
25+
26+
if is_sqlite:
27+
op.get_context().connection.execute('PRAGMA foreign_keys=ON;')
28+
utcnow_server_default = "(datetime('now', 'utc'))"
29+
else:
30+
utcnow_server_default = "timezone('utc', current_timestamp)"
31+
32+
def sqlite_column_reflect_listener(inspector, table, column_info):
33+
"""Adds parenthesis around SQLite datetime defaults for utcnow."""
34+
if column_info['default'] == "datetime('now', 'utc')":
35+
column_info['default'] = utcnow_server_default
36+
37+
sqlite_reflect_kwargs = {
38+
'listeners': [('column_reflect', sqlite_column_reflect_listener)]
39+
}
40+
41+
# ===========================================================================
42+
# HOWTO: Handle alter statements in SQLite
43+
#
44+
# def upgrade():
45+
# if is_sqlite:
46+
# with op.batch_alter_table('table_name', reflect_kwargs=sqlite_reflect_kwargs) as batch_op:
47+
# batch_op.alter_column('column_name', type_=sa.Unicode(), server_default='', nullable=False)
48+
# else:
49+
# op.alter_column('table_name', 'column_name', type_=sa.Unicode(), server_default='', nullable=False)
50+
#
51+
# ===========================================================================
52+
53+
54+
def upgrade():
55+
op.add_column('panel_applicant', sa.Column('social_media_info', sa.String(), server_default='', nullable=False))
56+
op.drop_column('panel_applicant', 'social_media')
57+
op.drop_index(op.f('uq_promo_code_word_normalized_word_part_of_speech'), table_name='promo_code_word')
58+
op.create_index('uq_promo_code_word_normalized_word_part_of_speech', 'promo_code_word', [sa.literal_column('lower(trim(word))'), 'part_of_speech'], unique=True)
59+
60+
61+
def downgrade():
62+
op.drop_index('uq_promo_code_word_normalized_word_part_of_speech', table_name='promo_code_word')
63+
op.create_index(op.f('uq_promo_code_word_normalized_word_part_of_speech'), 'promo_code_word', [sa.literal_column('lower(TRIM(BOTH FROM word))'), 'part_of_speech'], unique=True)
64+
op.add_column('panel_applicant', sa.Column('social_media', postgresql.JSON(astext_type=sa.Text()), server_default=sa.text("'{}'::json"), autoincrement=False, nullable=False))
65+
op.drop_column('panel_applicant', 'social_media_info')

alembic/versions/6902e1cceec6_relationships_overhaul.py

Lines changed: 606 additions & 0 deletions
Large diffs are not rendered by default.

docs/script_example.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,3 @@
66

77
with Session() as session:
88
initialize_db()
9-
session = Session().session

requirements.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ configobj==5.0.9
1111
email_validator==2.2.0
1212
fpdf2==2.8.3
1313
geopy==2.4.1
14+
TatSu==5.7.4
1415
ics==0.7.2
1516
Jinja2==3.1.6
1617
ortools==9.14.6206
@@ -31,6 +32,7 @@ rpctools @ git+https://github.com/appliedsec/rpctools.git@4e4108c3b7b4b6c482e515
3132
sentry-sdk==2.32.0
3233
signnow_python_sdk==2.0.1
3334
SQLAlchemy==2.0.46
35+
sqlmodel==0.0.37
3436
stripe==9.1.0
3537
tatsu==5.7.4
3638
twilio==9.6.5

tests/uber/models/test_badge_funcs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
@pytest.fixture
1414
def session(request):
15-
session = Session().session
15+
session = Session()
1616
request.addfinalizer(session.close)
1717
check_ranges(session)
1818
for badge_type, badge_name in [(c.STAFF_BADGE, 'Staff'), (c.CONTRACTOR_BADGE, 'Contractor')]:

tests/uber/models/test_config.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def test_under_limit_no_price_bump(self):
4444

4545
def test_over_limit_price_bump_before_event(self, monkeypatch):
4646
monkeypatch.setattr(c, 'EPOCH', localized_now() + timedelta(days=1))
47-
session = Session().session
47+
session = Session()
4848
assert c.BADGES_SOLD == 0
4949

5050
with request_cached_context():
@@ -57,7 +57,7 @@ def test_over_limit_price_bump_before_event(self, monkeypatch):
5757
def test_over_limit_price_bump_during_event(self, monkeypatch):
5858
monkeypatch.setattr(c, 'EPOCH', localized_now() - timedelta(days=1))
5959

60-
session = Session().session
60+
session = Session()
6161
assert c.BADGES_SOLD == 0
6262

6363
with request_cached_context():
@@ -69,7 +69,7 @@ def test_over_limit_price_bump_during_event(self, monkeypatch):
6969

7070
def test_refunded_badge_price_bump_before_event(self, monkeypatch):
7171
monkeypatch.setattr(c, 'EPOCH', localized_now() + timedelta(days=1))
72-
session = Session().session
72+
session = Session()
7373
assert c.BADGES_SOLD == 0
7474

7575
with request_cached_context():
@@ -81,7 +81,7 @@ def test_refunded_badge_price_bump_before_event(self, monkeypatch):
8181

8282
def test_refunded_badge_price_bump_during_event(self, monkeypatch):
8383
monkeypatch.setattr(c, 'EPOCH', localized_now() - timedelta(days=1))
84-
session = Session().session
84+
session = Session()
8585
assert c.BADGES_SOLD == 0
8686

8787
with request_cached_context():
@@ -92,7 +92,7 @@ def test_refunded_badge_price_bump_during_event(self, monkeypatch):
9292
assert 40 == c.get_attendee_price()
9393

9494
def test_invalid_badge_no_price_bump(self):
95-
session = Session().session
95+
session = Session()
9696
assert c.BADGES_SOLD == 0
9797

9898
with request_cached_context():
@@ -103,7 +103,7 @@ def test_invalid_badge_no_price_bump(self):
103103
assert 40 == c.get_attendee_price()
104104

105105
def test_free_badge_no_price_bump(self):
106-
session = Session().session
106+
session = Session()
107107
assert c.BADGES_SOLD == 0
108108

109109
with request_cached_context():
@@ -249,31 +249,31 @@ def test_dealer_reg_soft_closed_after_deadline(self, monkeypatch):
249249
assert c.DEALER_REG_SOFT_CLOSED
250250

251251
def test_dealer_app(self):
252-
session = Session().session
252+
session = Session()
253253
with request_cached_context():
254254
session.add(Group(tables=1, cost=10, status=c.UNAPPROVED))
255255
session.commit()
256256

257257
assert c.DEALER_APPS == 1
258258

259259
def test_waitlisted_dealer_not_app(self):
260-
session = Session().session
260+
session = Session()
261261
with request_cached_context():
262262
session.add(Group(tables=1, cost=10, status=c.WAITLISTED))
263263
session.commit()
264264

265265
assert c.DEALER_APPS == 0
266266

267267
def test_free_dealer_no_app(self):
268-
session = Session().session
268+
session = Session()
269269
with request_cached_context():
270270
session.add(Group(tables=1, cost=0, auto_recalc=False, status=c.UNAPPROVED))
271271
session.commit()
272272

273273
assert c.DEALER_APPS == 0
274274

275275
def test_not_a_dealer_no_app(self):
276-
session = Session().session
276+
session = Session()
277277
with request_cached_context():
278278
session.add(Group(tables=0, cost=10, status=c.UNAPPROVED))
279279
session.commit()

tests/uber/models/test_group.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
@pytest.fixture
1313
def session(request, monkeypatch):
14-
session = Session().session
14+
session = Session()
1515
request.addfinalizer(session.close)
1616
monkeypatch.setattr(session, 'add', Mock())
1717
monkeypatch.setattr(session, 'delete', Mock())

tests/uber/models/test_job.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def test_total_hours(monkeypatch):
3131

3232
@pytest.fixture
3333
def session(request):
34-
session = Session().session
34+
session = Session()
3535
for num in ['One', 'Two', 'Three', 'Four', 'Five', 'Six']:
3636
setattr(session, 'job_' + num.lower(), session.job(name='Job ' + num))
3737
for num in ['One', 'Two', 'Three', 'Four', 'Five']:

0 commit comments

Comments
 (0)