Skip to content

Commit

Permalink
first try at html reconcile page
Browse files Browse the repository at this point in the history
  • Loading branch information
drkane committed Dec 20, 2023
1 parent 12113ab commit eace1f6
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 3 deletions.
2 changes: 1 addition & 1 deletion specs
Submodule specs updated 34 files
+37 −0 draft/examples/data-extension-response/valid/example-dir.json
+3 −2 draft/examples/manifest/invalid/bad-authentication.json
+3 −2 draft/examples/manifest/invalid/feature-view.json
+1 −4 draft/examples/manifest/invalid/godot-missing-view.json
+3 −2 draft/examples/manifest/invalid/missing-version.json
+3 −2 draft/examples/manifest/invalid/old-version.json
+2 −4 draft/examples/manifest/invalid/opencorporates.json
+2 −4 draft/examples/manifest/invalid/ror-invalid-view-pattern.json
+2 −4 draft/examples/manifest/invalid/slub-invalid-property-setting.json
+1 −3 draft/examples/manifest/valid/authentication.json
+0 −2 draft/examples/manifest/valid/codefork-viaf.json
+3 −2 draft/examples/manifest/valid/example-min.json
+3 −2 draft/examples/manifest/valid/feature-view.json
+0 −2 draft/examples/manifest/valid/findthatcharity.json
+3 −2 draft/examples/manifest/valid/fundref.json
+0 −2 draft/examples/manifest/valid/geocollider-sinatra.json
+0 −2 draft/examples/manifest/valid/getty.json
+0 −2 draft/examples/manifest/valid/kerameikos.json
+2 −4 draft/examples/manifest/valid/kew.json
+1 −3 draft/examples/manifest/valid/lobid-gnd.json
+1 −3 draft/examples/manifest/valid/nomisma.json
+1 −3 draft/examples/manifest/valid/occrp.json
+1 −3 draft/examples/manifest/valid/ordnance-survey.json
+2 −4 draft/examples/manifest/valid/vivo-cornell.json
+2 −4 draft/examples/manifest/valid/wikidata.json
+16 −4 draft/examples/reconciliation-query-batch/valid/example-full.json
+28 −0 draft/examples/reconciliation-result-batch/valid/minimal.json
+10 −2 draft/examples/suggest-properties-response/valid/example.json
+107 −78 draft/index.html
+6 −0 draft/schemas/data-extension-response.json
+1 −10 draft/schemas/manifest.json
+17 −0 draft/schemas/reconciliation-query-batch.json
+1 −2 draft/schemas/reconciliation-result-batch.json
+21 −0 draft/schemas/suggest-properties-response.json
8 changes: 6 additions & 2 deletions src/datasette_reconcile/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from datasette_reconcile.reconcile import ReconcileAPI
from datasette_reconcile.utils import check_config, check_permissions
from datasette_reconcile.views import ReconcileHTML


async def reconcile(request, datasette):
Expand Down Expand Up @@ -30,5 +31,8 @@ async def reconcile(request, datasette):


@hookimpl
def register_routes():
return [(r"/(?P<db_name>[^/]+)/(?P<db_table>[^/]+?)/-/reconcile$", reconcile)]
def register_routes(datasette):
return [
(r"/(?P<db_name>[^/]+)/(?P<db_table>[^/]+?)/-/reconcile$", reconcile),
(r"/(?P<db_name>[^/]+)/(?P<db_table>[^/]+?)/-/reconcile.html$", ReconcileHTML.as_view(datasette)),
]
19 changes: 19 additions & 0 deletions src/datasette_reconcile/templates/reconcile.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{% extends "base.html" %}

{% block title %}{{ metadata.title or "Datasette" }}: Reconciliation{% endblock %}

{%- block extra_head %}
{{- super() -}}
<script src="https://cdnjs.cloudflare.com/ajax/libs/PapaParse/5.4.1/papaparse.min.js"
integrity="sha512-dfX5uYVXzyU8+KHqj8bjo7UkOdg18PaOtpa48djpNbZHwExddghZ+ZmzWT06R5v6NSk3ZUfsH6FNEDepLx9hPQ=="
crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script>
const RECONCILE_URL = {{ reconcile_url|tojson }};
</script>
{% endblock -%}

{% block content %}
<h1>{{ metadata.title or "Datasette" }} Reconciliation {% if private %} 🔒{% endif %}</h1>

{{ reconcile_config }}
{% endblock %}
42 changes: 42 additions & 0 deletions src/datasette_reconcile/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
from datasette.version import __version__
from datasette.views.base import BaseView

from datasette_reconcile.utils import check_config, check_permissions


class ReconcileHTML(BaseView):
name = "reconcile_html"

async def get(self, request):
database = request.url_vars["db_name"]
table = request.url_vars["db_table"]
db = self.ds.get_database(database)

# get plugin configuration
config = self.ds.plugin_config("datasette-reconcile", database=database, table=table)
config = await check_config(config, db, table)

# check user can at least view this table
await check_permissions(
request,
[
("view-table", (database, table)),
("view-database", database),
"view-instance",
],
self.ds,
)

return await self.render(
["reconcile.html"],
request=request,
context={
"database": database,
"table": table,
"reconcile_config": config,
"reconcile_url": self.ds.absolute_url(request, self.ds.urls.table(database, table) + "/-/reconcile"),
"metadata": self.ds.metadata(),
"datasette_version": __version__,
"private": not await self.ds.permission_allowed(None, "view-instance"),
},
)

0 comments on commit eace1f6

Please sign in to comment.