Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lmfdb/elliptic_curves/congruent_numbers.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@

congruent_number_data_directory = os.path.expanduser('~/data/congruent_number_curves')

# The files offered by the download buttons in templates/congruent_number_data.html.
congruent_number_data_files = ['CN.conductor', 'CN.rank', 'CN.MWgroup', 'CN.height',
'CN.regulator', 'CN.root.number', 'CN.Tate-Sha', 'CN.classes']


def CNfilename(file_suffix):
return os.path.join(congruent_number_data_directory, "CN.{}".format(file_suffix))
Expand Down
4 changes: 2 additions & 2 deletions lmfdb/elliptic_curves/elliptic_curve.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
from lmfdb.elliptic_curves.web_ec import WebEC, match_lmfdb_label, match_cremona_label, split_lmfdb_label, split_cremona_label, weierstrass_eqn_regex, short_weierstrass_eqn_regex, class_lmfdb_label, curve_lmfdb_label, EC_ainvs, latex_sha, gl2_subgroup_data, CREMONA_BOUND, match_weierstrass_polys, match_coeff_vec
from sage.misc.cachefunc import cached_method
from lmfdb.ecnf.ecnf_stats import latex_tor
from .congruent_numbers import get_congruent_number_data, congruent_number_data_directory
from .congruent_numbers import get_congruent_number_data, congruent_number_data_directory, congruent_number_data_files
from lmfdb.sato_tate_groups.main import st_display_knowl

q = ZZ['x'].gen()
Expand Down Expand Up @@ -968,7 +968,7 @@ def render_congruent_number_data():
bread = [("Datasets", url_for("datasets")), (t, " ")]
if 'filename' in info:
filepath = os.path.join(congruent_number_data_directory,info['filename'])
if os.path.isfile(filepath) and os.access(filepath, os.R_OK):
if info['filename'] in congruent_number_data_files and os.path.isfile(filepath) and os.access(filepath, os.R_OK):
return send_file(filepath, as_attachment=True)
else:
flash_error('File {} not found'.format(info['filename']))
Expand Down
8 changes: 8 additions & 0 deletions lmfdb/elliptic_curves/test_ell_curves.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import os

from lmfdb.tests import LmfdbTest


Expand Down Expand Up @@ -241,6 +243,12 @@ def test_diagram_search(self):
assert 'my_dataviz' in data
assert 'pointRadius' in data

def test_congruent_number_file_outside_dataset(self):
resp = self.tc.get('/EllipticCurve/Q/CongruentNumbers',
query_string={'filename': os.path.abspath(__file__)})
assert resp.status_code == 302
assert resp.headers['Location'].endswith('/EllipticCurve/Q/CongruentNumbers')

def test_dataset_files_from_beta(self):
for url in ['/EllipticCurve/Q/stein-watkins?ctype=prime&k=0&Fetch=fetch',
'/EllipticCurve/Q/BHKSSW?k=0&Fetch=fetch']:
Expand Down
Loading