Skip to content
Snippets Groups Projects
Commit c18e4779 authored by Nik | Klampfradler's avatar Nik | Klampfradler
Browse files

Merge branch '10-button-create-live-document-does-nothing' into 'master'

Resolve "Button "Create live document" does nothing"

Closes #10

See merge request !36
parents 7ed0d381 82582c6c
No related branches found
No related tags found
1 merge request!36Resolve "Button "Create live document" does nothing"
Pipeline #49592 canceled
...@@ -18,6 +18,7 @@ Fixed ...@@ -18,6 +18,7 @@ Fixed
~~~~~ ~~~~~
* Live documents table showed two "Actions" columns. * Live documents table showed two "Actions" columns.
* Button for creation of live documents was there even if there weren't any live document types registered.
`2.0`_ - 2021-12-27 `2.0`_ - 2021-12-27
------------------- -------------------
......
...@@ -9,21 +9,28 @@ ...@@ -9,21 +9,28 @@
{% block page_title %}{% blocktrans %}Live documents{% endblocktrans %}{% endblock %} {% block page_title %}{% blocktrans %}Live documents{% endblocktrans %}{% endblock %}
{% block content %} {% block content %}
<a class="btn green waves-effect waves-light dropdown-trigger" href="#" data-target="widget-dropdown"> {% if document_types %}
<i class="material-icons left">add</i> <a class="btn green waves-effect waves-light dropdown-trigger" href="#" data-target="widget-dropdown">
{% trans "Create live document" %} <i class="material-icons left">add</i>
</a> {% trans "Create live document" %}
</a>
<ul id="widget-dropdown" class="dropdown-content"> <ul id="widget-dropdown" class="dropdown-content">
{% for ct, model in widget_types %} {% for ct, model in document_types %}
<li> <li>
<a href="{% url 'create_live_document' ct.app_label ct.model %}"> <a href="{% url 'create_live_document' ct.app_label ct.model %}">
{% verbose_name_object model as widget_name %} {% verbose_name_object model as document_name %}
{% blocktrans with name=widget_name %}Create {{ name }}{% endblocktrans %} {% blocktrans with name=document_name %}Create {{ name }}{% endblocktrans %}
</a> </a>
</li> </li>
{% endfor %} {% endfor %}
</ul> </ul>
{% else %}
<figure class="alert primary">
<i class="material-icons left">info</i>
{% trans "There is no app installed which registers any live document types." %}
</figure>
{% endif %}
{% render_table table %} {% render_table table %}
{% endblock %} {% endblock %}
...@@ -160,7 +160,7 @@ class LiveDocumentListView(PermissionRequiredMixin, SingleTableView): ...@@ -160,7 +160,7 @@ class LiveDocumentListView(PermissionRequiredMixin, SingleTableView):
def get_context_data(self, **kwargs: Any) -> dict[str, Any]: def get_context_data(self, **kwargs: Any) -> dict[str, Any]:
context = super().get_context_data(**kwargs) context = super().get_context_data(**kwargs)
context["widget_types"] = [ context["document_types"] = [
(ContentType.objects.get_for_model(m, False), m) for m in LiveDocument.__subclasses__() (ContentType.objects.get_for_model(m, False), m) for m in LiveDocument.__subclasses__()
] ]
return context return context
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment