kopia lustrzana https://github.com/simonw/datasette
rodzic
a1ba6cd6bb
commit
fe687fd020
|
@ -180,7 +180,11 @@ class ColumnFacet(Facet):
|
||||||
"name": column,
|
"name": column,
|
||||||
"toggle_url": self.ds.absolute_url(
|
"toggle_url": self.ds.absolute_url(
|
||||||
self.request,
|
self.request,
|
||||||
path_with_added_args(self.request, {"_facet": column}),
|
self.ds.urls.path(
|
||||||
|
path_with_added_args(
|
||||||
|
self.request, {"_facet": column}
|
||||||
|
)
|
||||||
|
),
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
@ -334,8 +338,10 @@ class ArrayFacet(Facet):
|
||||||
"type": "array",
|
"type": "array",
|
||||||
"toggle_url": self.ds.absolute_url(
|
"toggle_url": self.ds.absolute_url(
|
||||||
self.request,
|
self.request,
|
||||||
|
self.ds.urls.path(
|
||||||
path_with_added_args(
|
path_with_added_args(
|
||||||
self.request, {"_facet_array": column}
|
self.request, {"_facet_array": column}
|
||||||
|
)
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
|
@ -461,8 +467,10 @@ class DateFacet(Facet):
|
||||||
"type": "date",
|
"type": "date",
|
||||||
"toggle_url": self.ds.absolute_url(
|
"toggle_url": self.ds.absolute_url(
|
||||||
self.request,
|
self.request,
|
||||||
|
self.ds.urls.path(
|
||||||
path_with_added_args(
|
path_with_added_args(
|
||||||
self.request, {"_facet_date": column}
|
self.request, {"_facet_date": column}
|
||||||
|
)
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,9 +9,9 @@
|
||||||
{{ column.name }}
|
{{ column.name }}
|
||||||
{% else %}
|
{% else %}
|
||||||
{% if column.name == sort %}
|
{% if column.name == sort %}
|
||||||
<a href="{{ path_with_replaced_args(request, {'_sort_desc': column.name, '_sort': None, '_next': None}) }}" rel="nofollow">{{ column.name }} ▼</a>
|
<a href="{{ fix_path(path_with_replaced_args(request, {'_sort_desc': column.name, '_sort': None, '_next': None})) }}" rel="nofollow">{{ column.name }} ▼</a>
|
||||||
{% else %}
|
{% else %}
|
||||||
<a href="{{ path_with_replaced_args(request, {'_sort': column.name, '_sort_desc': None, '_next': None}) }}" rel="nofollow">{{ column.name }}{% if column.name == sort_desc %} ▲{% endif %}</a>
|
<a href="{{ fix_path(path_with_replaced_args(request, {'_sort': column.name, '_sort_desc': None, '_next': None})) }}" rel="nofollow">{{ column.name }}{% if column.name == sort_desc %} ▲{% endif %}</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</th>
|
</th>
|
||||||
|
|
|
@ -592,13 +592,15 @@ class DataView(BaseView):
|
||||||
)
|
)
|
||||||
it_can_render = await await_me_maybe(it_can_render)
|
it_can_render = await await_me_maybe(it_can_render)
|
||||||
if it_can_render:
|
if it_can_render:
|
||||||
renderers[key] = path_with_format(
|
renderers[key] = self.ds.urls.path(
|
||||||
|
path_with_format(
|
||||||
request=request, format=key, extra_qs={**url_labels_extra}
|
request=request, format=key, extra_qs={**url_labels_extra}
|
||||||
)
|
)
|
||||||
|
)
|
||||||
|
|
||||||
url_csv_args = {"_size": "max", **url_labels_extra}
|
url_csv_args = {"_size": "max", **url_labels_extra}
|
||||||
url_csv = path_with_format(
|
url_csv = self.ds.urls.path(
|
||||||
request=request, format="csv", extra_qs=url_csv_args
|
path_with_format(request=request, format="csv", extra_qs=url_csv_args)
|
||||||
)
|
)
|
||||||
url_csv_path = url_csv.split("?")[0]
|
url_csv_path = url_csv.split("?")[0]
|
||||||
context = {
|
context = {
|
||||||
|
|
|
@ -459,7 +459,7 @@ class QueryView(DataView):
|
||||||
"metadata": metadata,
|
"metadata": metadata,
|
||||||
"settings": self.ds.settings_dict(),
|
"settings": self.ds.settings_dict(),
|
||||||
"request": request,
|
"request": request,
|
||||||
"show_hide_link": show_hide_link,
|
"show_hide_link": self.ds.urls.path(show_hide_link),
|
||||||
"show_hide_text": show_hide_text,
|
"show_hide_text": show_hide_text,
|
||||||
"show_hide_hidden": markupsafe.Markup(show_hide_hidden),
|
"show_hide_hidden": markupsafe.Markup(show_hide_hidden),
|
||||||
"hide_sql": hide_sql,
|
"hide_sql": hide_sql,
|
||||||
|
|
|
@ -942,6 +942,7 @@ class TableView(RowTableShared):
|
||||||
"extra_wheres_for_ui": extra_wheres_for_ui,
|
"extra_wheres_for_ui": extra_wheres_for_ui,
|
||||||
"form_hidden_args": form_hidden_args,
|
"form_hidden_args": form_hidden_args,
|
||||||
"is_sortable": any(c["sortable"] for c in display_columns),
|
"is_sortable": any(c["sortable"] for c in display_columns),
|
||||||
|
"fix_path": ds.urls.path,
|
||||||
"path_with_replaced_args": path_with_replaced_args,
|
"path_with_replaced_args": path_with_replaced_args,
|
||||||
"path_with_removed_args": path_with_removed_args,
|
"path_with_removed_args": path_with_removed_args,
|
||||||
"append_querystring": append_querystring,
|
"append_querystring": append_querystring,
|
||||||
|
|
|
@ -1614,11 +1614,16 @@ def test_metadata_sort_desc(app_client):
|
||||||
"/fixtures/compound_three_primary_keys/a,a,a",
|
"/fixtures/compound_three_primary_keys/a,a,a",
|
||||||
"/fixtures/paginated_view",
|
"/fixtures/paginated_view",
|
||||||
"/fixtures/facetable",
|
"/fixtures/facetable",
|
||||||
|
"/fixtures?sql=select+1",
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
def test_base_url_config(app_client_base_url_prefix, path):
|
@pytest.mark.parametrize("use_prefix", (True, False))
|
||||||
|
def test_base_url_config(app_client_base_url_prefix, path, use_prefix):
|
||||||
client = app_client_base_url_prefix
|
client = app_client_base_url_prefix
|
||||||
response = client.get("/prefix/" + path.lstrip("/"))
|
path_to_get = path
|
||||||
|
if use_prefix:
|
||||||
|
path_to_get = "/prefix/" + path.lstrip("/")
|
||||||
|
response = client.get(path_to_get)
|
||||||
soup = Soup(response.body, "html.parser")
|
soup = Soup(response.body, "html.parser")
|
||||||
for el in soup.findAll(["a", "link", "script"]):
|
for el in soup.findAll(["a", "link", "script"]):
|
||||||
if "href" in el.attrs:
|
if "href" in el.attrs:
|
||||||
|
@ -1642,11 +1647,16 @@ def test_base_url_config(app_client_base_url_prefix, path):
|
||||||
# If this has been made absolute it may start http://localhost/
|
# If this has been made absolute it may start http://localhost/
|
||||||
if href.startswith("http://localhost/"):
|
if href.startswith("http://localhost/"):
|
||||||
href = href[len("http://localost/") :]
|
href = href[len("http://localost/") :]
|
||||||
assert href.startswith("/prefix/"), {
|
assert href.startswith("/prefix/"), json.dumps(
|
||||||
|
{
|
||||||
"path": path,
|
"path": path,
|
||||||
|
"path_to_get": path_to_get,
|
||||||
"href_or_src": href,
|
"href_or_src": href,
|
||||||
"element_parent": str(el.parent),
|
"element_parent": str(el.parent),
|
||||||
}
|
},
|
||||||
|
indent=4,
|
||||||
|
default=repr,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_base_url_affects_metadata_extra_css_urls(app_client_base_url_prefix):
|
def test_base_url_affects_metadata_extra_css_urls(app_client_base_url_prefix):
|
||||||
|
|
Ładowanie…
Reference in New Issue