kopia lustrzana https://github.com/simonw/datasette
rodzic
a1ba6cd6bb
commit
fe687fd020
|
@ -180,7 +180,11 @@ class ColumnFacet(Facet):
|
|||
"name": column,
|
||||
"toggle_url": self.ds.absolute_url(
|
||||
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",
|
||||
"toggle_url": self.ds.absolute_url(
|
||||
self.request,
|
||||
path_with_added_args(
|
||||
self.request, {"_facet_array": column}
|
||||
self.ds.urls.path(
|
||||
path_with_added_args(
|
||||
self.request, {"_facet_array": column}
|
||||
)
|
||||
),
|
||||
),
|
||||
}
|
||||
|
@ -461,8 +467,10 @@ class DateFacet(Facet):
|
|||
"type": "date",
|
||||
"toggle_url": self.ds.absolute_url(
|
||||
self.request,
|
||||
path_with_added_args(
|
||||
self.request, {"_facet_date": column}
|
||||
self.ds.urls.path(
|
||||
path_with_added_args(
|
||||
self.request, {"_facet_date": column}
|
||||
)
|
||||
),
|
||||
),
|
||||
}
|
||||
|
|
|
@ -9,9 +9,9 @@
|
|||
{{ column.name }}
|
||||
{% else %}
|
||||
{% 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 %}
|
||||
<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 %}
|
||||
</th>
|
||||
|
|
|
@ -592,13 +592,15 @@ class DataView(BaseView):
|
|||
)
|
||||
it_can_render = await await_me_maybe(it_can_render)
|
||||
if it_can_render:
|
||||
renderers[key] = path_with_format(
|
||||
request=request, format=key, extra_qs={**url_labels_extra}
|
||||
renderers[key] = self.ds.urls.path(
|
||||
path_with_format(
|
||||
request=request, format=key, extra_qs={**url_labels_extra}
|
||||
)
|
||||
)
|
||||
|
||||
url_csv_args = {"_size": "max", **url_labels_extra}
|
||||
url_csv = path_with_format(
|
||||
request=request, format="csv", extra_qs=url_csv_args
|
||||
url_csv = self.ds.urls.path(
|
||||
path_with_format(request=request, format="csv", extra_qs=url_csv_args)
|
||||
)
|
||||
url_csv_path = url_csv.split("?")[0]
|
||||
context = {
|
||||
|
|
|
@ -459,7 +459,7 @@ class QueryView(DataView):
|
|||
"metadata": metadata,
|
||||
"settings": self.ds.settings_dict(),
|
||||
"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_hidden": markupsafe.Markup(show_hide_hidden),
|
||||
"hide_sql": hide_sql,
|
||||
|
|
|
@ -942,6 +942,7 @@ class TableView(RowTableShared):
|
|||
"extra_wheres_for_ui": extra_wheres_for_ui,
|
||||
"form_hidden_args": form_hidden_args,
|
||||
"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_removed_args": path_with_removed_args,
|
||||
"append_querystring": append_querystring,
|
||||
|
|
|
@ -1614,11 +1614,16 @@ def test_metadata_sort_desc(app_client):
|
|||
"/fixtures/compound_three_primary_keys/a,a,a",
|
||||
"/fixtures/paginated_view",
|
||||
"/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
|
||||
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")
|
||||
for el in soup.findAll(["a", "link", "script"]):
|
||||
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 href.startswith("http://localhost/"):
|
||||
href = href[len("http://localost/") :]
|
||||
assert href.startswith("/prefix/"), {
|
||||
"path": path,
|
||||
"href_or_src": href,
|
||||
"element_parent": str(el.parent),
|
||||
}
|
||||
assert href.startswith("/prefix/"), json.dumps(
|
||||
{
|
||||
"path": path,
|
||||
"path_to_get": path_to_get,
|
||||
"href_or_src": href,
|
||||
"element_parent": str(el.parent),
|
||||
},
|
||||
indent=4,
|
||||
default=repr,
|
||||
)
|
||||
|
||||
|
||||
def test_base_url_affects_metadata_extra_css_urls(app_client_base_url_prefix):
|
||||
|
|
Ładowanie…
Reference in New Issue