Skip to content

Commit 74ff351

Browse files
authored
Merge pull request #6640 from LMFDB/main
2 parents e8b51c0 + e858b10 commit 74ff351

File tree

11 files changed

+31
-28
lines changed

11 files changed

+31
-28
lines changed

lmfdb/api/api.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77
from lmfdb import db
88
from psycodict.encoding import Json
99
from lmfdb.utils import flash_error
10-
from datetime import datetime
11-
from lmfdb.utils.datetime_utils import UTC
10+
from lmfdb.utils.datetime_utils import utc_now_naive
1211
from flask import (render_template, request, url_for, current_app,
1312
abort, redirect, Response)
1413
from lmfdb.api import api_page, api_logger
@@ -324,7 +323,7 @@ def apierror(msg, flash_extras=[], code=404, table=True):
324323
# the collected result
325324
data = {
326325
"table": table,
327-
"timestamp": datetime.now(UTC).isoformat(),
326+
"timestamp": utc_now_naive().isoformat(),
328327
"data": data,
329328
"start": start,
330329
"offset": offset,
@@ -427,7 +426,7 @@ def apierror(msg, flash_extras=[], code=404, table=False):
427426
"labels": labels,
428427
"tables": tables,
429428
"label_cols": label_cols,
430-
"timestamp": datetime.now(UTC).isoformat(),
429+
"timestamp": utc_now_naive().isoformat(),
431430
"data": data,
432431
}
433432
if format.lower() == "json":

lmfdb/app.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -713,6 +713,7 @@ def sitemap():
713713
def WhiteListedRoutes():
714714
return [
715715
'ArtinRepresentation',
716+
'Belyi',
716717
'Character/Dirichlet',
717718
'Character/calc-gauss/Dirichlet',
718719
'Character/calc-jacobi/Dirichlet',

lmfdb/classical_modular_forms/download.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from psycodict.encoding import Json
66
from lmfdb.utils import Downloader, flash_error
77
from lmfdb.characters.TinyConrey import ConreyCharacter
8-
from lmfdb.classical_modular_forms.web_newform import WebNewform
8+
from lmfdb.classical_modular_forms.web_newform import WebNewform, valid_label
99
from lmfdb.classical_modular_forms.web_space import WebNewformSpace, WebGamma1Space
1010

1111

@@ -148,6 +148,8 @@ def _get_traces(self, label):
148148
qexp_function_body_sparse_cyclotomic = {'sage': header + discrete_log_sage + extend_multiplicatively_sage + field_and_convert_sage_sparse_cyclotomic + convert_aps + char_values_sage_generic + an_code_sage}
149149

150150
def download_qexp(self, label, lang='sage'):
151+
if not valid_label(label):
152+
return abort(404, "Invalid label: %s" % label)
151153
if isinstance(lang, str):
152154
lang = self.languages.get(lang, self.languages['sage'])
153155
hecke_nf = self._get_hecke_nf(label)

lmfdb/classical_modular_forms/test_cmf2.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ def test_download_qexp(self):
3030
page = self.tc.get('/ModularForm/GL2/Q/holomorphic/download_qexp/{}'.format(label), follow_redirects=True)
3131
assert 'q-expansion not available for newform {}'.format(label) in page.get_data(as_text=True)
3232

33+
# Test invalid labels return 404 with proper error message
34+
for label in ['safeboating', 'invalid.label', '11.2.a', '11.2.a.a.extra']:
35+
page = self.tc.get('/ModularForm/GL2/Q/holomorphic/download_qexp/{}'.format(label), follow_redirects=True)
36+
assert 'Invalid label: {}'.format(label) in page.get_data(as_text=True)
37+
3338
def test_download(self):
3439
r"""
3540
Test download function

lmfdb/modular_curves/upload.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11

22
import re
3-
from datetime import datetime
4-
from lmfdb.utils.datetime_utils import UTC
3+
from lmfdb.utils.datetime_utils import utc_now_naive
54
from flask import url_for
65
from sage.all import ZZ, QQ, lazy_attribute, NumberField
76
from lmfdb import db
@@ -233,7 +232,7 @@ def final_process(self, ids, F, by_table, cols):
233232
else:
234233
status = 3
235234
comment = ""
236-
timestamp = datetime.now(UTC).isoformat()
235+
timestamp = utc_now_naive().isoformat()
237236
ids = {upid: (status, timestamp, comment) for upid, data in self.delayed}
238237

239238
# If other columns are added later, it's important that these be sorted (see lmfdb/uploads/process.py)

lmfdb/number_fields/number_field.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1237,7 +1237,7 @@ def __init__(self):
12371237
knowl="nf.narrow_class_number",
12381238
example="5")
12391239
narrow_class_group = TextBox(
1240-
name="class_group",
1240+
name="narrow_class_group",
12411241
label="Narrow class group structure",
12421242
short_label='Narrow class group',
12431243
knowl="nf.narrow_class_group",

lmfdb/tests/test_dynamic_knowls.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
from lmfdb.tests import LmfdbTest
3-
from lmfdb.utils.datetime_utils import UTC
3+
from lmfdb.utils.datetime_utils import utc_now_naive
44

55
class DynamicKnowlTest(LmfdbTest):
66
"""
@@ -50,7 +50,7 @@ def test_prod_knowl_sync(self):
5050
# Create a different connection to devmirror to compare timestamps
5151
from lmfdb.utils.config import Configuration
5252
from psycopg2.sql import SQL
53-
from datetime import timedelta, datetime
53+
from datetime import timedelta
5454
dev_config = Configuration()
5555
# Modify configuration to connect to devmirror
5656
for D in [dev_config.default_args["postgresql"], dev_config.postgresql_options, dev_config.options["postgresql"]]:
@@ -63,7 +63,7 @@ def test_prod_knowl_sync(self):
6363
dev_db = PostgresDatabase(dev_config)
6464

6565
# Updates happen every 20 minutes, so we only compare knowls older than that (plus a buffer).
66-
cutoff = datetime.now(UTC) - timedelta(minutes=30)
66+
cutoff = utc_now_naive() - timedelta(minutes=30)
6767

6868
t_query = SQL("SELECT timestamp FROM kwl_knowls WHERE timestamp < %s LIMIT 1")
6969
dev_t = dev_db._execute(t_query, [cutoff]).fetchone()[0]

lmfdb/uploads/process.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@
88
import sys
99
import tempfile
1010
from collections import defaultdict
11-
from datetime import datetime
12-
from lmfdb.utils.datetime_utils import UTC
11+
from lmfdb.utils.datetime_utils import utc_now_naive
1312
here = os.path.dirname(os.path.abspath(__file__))
1413
data_folder = os.path.join(here, "data")
1514
upone, _ = os.path.split(here)
@@ -52,7 +51,7 @@ def process_all():
5251
else:
5352
status = 3
5453
comment = ""
55-
timestamp = datetime.now(UTC).isoformat()
54+
timestamp = utc_now_naive().isoformat()
5655
status_update[rec["section"]][rec["id"]] = (status, timestamp, comment)
5756

5857
# There are some sections (like gonality propagation) that want to do more
@@ -66,7 +65,7 @@ def process_all():
6665
db.data_uploads.update_from_file(F.name, "id")
6766
db.data_uploads.cleanup_from_reload()
6867
os.unlink(F.name)
69-
timestamp = datetime.now(UTC).isoformat().replace(":", "-").replace("T", "-").replace(".", "-")
68+
timestamp = utc_now_naive().isoformat().replace(":", "-").replace("T", "-").replace(".", "-")
7069
uploads = []
7170
for (table, newrows), lines in by_table.items():
7271
nr = "t" if newrows else "f"

lmfdb/uploads/verify.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77
import os
88
import sys
99
import tempfile
10-
from datetime import datetime
11-
from lmfdb.utils.datetime_utils import UTC
10+
from lmfdb.utils.datetime_utils import utc_now_naive
1211
here = os.path.dirname(os.path.abspath(__file__))
1312
upone, _ = os.path.split(here)
1413
uptwo, _ = os.path.split(upone)
@@ -35,7 +34,7 @@ def verify_all():
3534
else:
3635
status = 1
3736
comment = ""
38-
timestamp = datetime.now(UTC).isoformat()
37+
timestamp = utc_now_naive().isoformat()
3938
_ = F.write(f"{rec['id']}|{status}|{timestamp}|{timestamp}|{comment}\n")
4039
F.close()
4140
db.data_uploads.update_from_file(F.name, "id")

lmfdb/users/pwdmanager.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
from psycodict.base import PostgresBase
1212
from psycodict.encoding import Array
1313
from psycopg2.sql import SQL, Identifier, Placeholder
14-
from datetime import datetime, timedelta
15-
from lmfdb.utils.datetime_utils import UTC
14+
from datetime import timedelta
15+
from lmfdb.utils.datetime_utils import utc_now_naive
1616

1717
from .main import logger
1818

@@ -97,7 +97,7 @@ def new_user(self, uid, pwd=None, full_name=None, about=None, url=None):
9797
password = self.bchash(pwd)
9898
#TODO: use identifiers
9999
insertor = SQL("INSERT INTO userdb.users (username, bcpassword, created, full_name, about, url) VALUES (%s, %s, %s, %s, %s, %s)")
100-
self._execute(insertor, [uid, password, datetime.now(UTC), full_name, about, url])
100+
self._execute(insertor, [uid, password, utc_now_naive(), full_name, about, url])
101101
new_user = LmfdbUser(uid)
102102
return new_user
103103

@@ -198,7 +198,7 @@ def create_tokens(self, tokens):
198198
return
199199

200200
insertor = SQL("INSERT INTO userdb.tokens (id, expire) VALUES %s")
201-
now = datetime.now(UTC)
201+
now = utc_now_naive()
202202
tdelta = timedelta(days=1)
203203
exp = now + tdelta
204204
self._execute(insertor, [(t, exp) for t in tokens], values_list=True)
@@ -216,7 +216,7 @@ def delete_old_tokens(self):
216216
logger.info("no attempt to delete old tokens, not enough privileges")
217217
return
218218
deletor = SQL("DELETE FROM userdb.tokens WHERE expire < %s")
219-
now = datetime.now(UTC)
219+
now = utc_now_naive()
220220
tdelta = timedelta(days=8)
221221
cutoff = now - tdelta
222222
self._execute(deletor, [cutoff])

0 commit comments

Comments
 (0)