Skip to content

Commit

Permalink
Merge pull request #232 from django-daiquiri/add-list-of-schemas
Browse files Browse the repository at this point in the history
Add list of schemas
  • Loading branch information
kimakan authored Feb 19, 2024
2 parents 6eeec21 + 593db1f commit 1b6a0bd
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 1 deletion.
1 change: 1 addition & 0 deletions daiquiri/core/settings/django.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@
'QUERY_UPLOAD',
'SITE_PUBLISHER',
'SITE_URL',
'SITE_TITLE',
'STATS_RESOURCE_TYPES'
]

Expand Down
39 changes: 39 additions & 0 deletions daiquiri/metadata/templates/metadata/schemas.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{% extends 'core/page.html' %}
{% load i18n %}
{% load static %}
{% load core_tags %}
{% load metadata_tags %}

{% block page %}

<h2 class="hide-overflow">
Metadata for {{ settings.SITE_TITLE }} databases
</h2>
</br>

<ul class="list-unstyled">
{% for schema in schemas %}
<li>
<h3>
<a href="{% url 'metadata:schema' schema.name %}">
{% if schema.title %}
{{ schema.title }} ({{ schema }})
{% else %}
{{ schema }}
{% endif %}
</a>
</h3>
{% if schema.description %}
{{ schema.description | markdown }}
{% elif schema.long_description %}
{{ schema.long_description | markdown }}
{% endif %}
</li>
{% endfor %}
</ul>

{% endblock %}

{% block sidebar %}

{% endblock %}
3 changes: 2 additions & 1 deletion daiquiri/metadata/urls.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from django.urls import include, path, re_path
from rest_framework import routers

from .views import ManagementView, SchemaView, TableView
from .views import ManagementView, SchemaView, SchemasView, TableView
from .viewsets import (AccessLevelViewSet, ColumnViewSet, FunctionViewSet,
LicenseViewSet, SchemaViewSet, TableTypeViewSet,
TableViewSet)
Expand All @@ -24,4 +24,5 @@

re_path(r'^(?P<schema_name>\w+)/$', SchemaView.as_view(), name='schema'),
re_path(r'^(?P<schema_name>\w+)/(?P<table_name>\w+)/$', TableView.as_view(), name='table'),
path(r'', SchemasView.as_view(), name='schemas'),
]
15 changes: 15 additions & 0 deletions daiquiri/metadata/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,21 @@ def get_context_data(self, **kwargs):
return context


class SchemasView(TemplateView):
template_name = 'metadata/schemas.html'

def get_context_data(self, **kwargs):
context = super(SchemasView, self).get_context_data(**kwargs)

try:
schemas = Schema.objects.filter_by_metadata_access_level(self.request.user).all()
except Schema.DoesNotExist:
raise Http404()

context['schemas'] = schemas
return context


class SchemaView(TemplateView):
template_name = 'metadata/schema.html'

Expand Down

0 comments on commit 1b6a0bd

Please sign in to comment.