mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
Hide 'view and edit SQL' if config.allow_sql turned off
This commit is contained in:
parent
7d0299edd4
commit
fe5b6ea95a
2 changed files with 10 additions and 1 deletions
|
|
@ -88,7 +88,7 @@
|
|||
</div>
|
||||
</form>
|
||||
|
||||
{% if query.sql %}
|
||||
{% if query.sql and config.allow_sql %}
|
||||
<p><a class="not-underlined" title="{{ query.sql }}" href="/{{ database }}-{{ database_hash }}?{{ {'sql': query.sql}|urlencode|safe }}{% if query.params %}&{{ query.params|urlencode|safe }}{% endif %}">✎ <span class="underlined">View and edit SQL</span></a></p>
|
||||
{% endif %}
|
||||
|
||||
|
|
|
|||
|
|
@ -713,6 +713,10 @@ def test_allow_sql_on(app_client):
|
|||
)
|
||||
soup = Soup(response.body, 'html.parser')
|
||||
assert len(soup.findAll('textarea', {'name': 'sql'}))
|
||||
response = app_client.get(
|
||||
"/fixtures/sortable"
|
||||
)
|
||||
assert b"View and edit SQL" in response.body
|
||||
|
||||
|
||||
def test_allow_sql_off():
|
||||
|
|
@ -724,6 +728,11 @@ def test_allow_sql_off():
|
|||
)
|
||||
soup = Soup(response.body, 'html.parser')
|
||||
assert not len(soup.findAll('textarea', {'name': 'sql'}))
|
||||
# The table page should no longer show "View and edit SQL"
|
||||
response = client.get(
|
||||
"/fixtures/sortable"
|
||||
)
|
||||
assert b"View and edit SQL" not in response.body
|
||||
|
||||
|
||||
def assert_querystring_equal(expected, actual):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue