From 7f203a711774e80422af4fcd0ef3946d2bdde8c7 Mon Sep 17 00:00:00 2001 From: rucki Date: Wed, 9 Sep 2026 16:31:01 +0200 Subject: [PATCH] Add markdown exports and tighten tag visibility --- core/forms.py | 7 + core/templates/core/collection_detail.html | 7 +- core/templates/core/index.html | 2 +- core/tests.py | 123 ++++++++++++++- core/urls.py | 2 + core/views.py | 168 +++++++++++++++++++-- 6 files changed, 294 insertions(+), 15 deletions(-) diff --git a/core/forms.py b/core/forms.py index 11c4329..f1fb5ef 100644 --- a/core/forms.py +++ b/core/forms.py @@ -189,6 +189,13 @@ class CollectionForm(forms.ModelForm): class ApiKeyForm(forms.ModelForm): + def __init__(self, *args, user=None, **kwargs): + super().__init__(*args, **kwargs) + if user and user.is_authenticated: + self.fields['tags'].queryset = Tag.objects.filter(items__owner=user).distinct().order_by('name') + else: + self.fields['tags'].queryset = Tag.objects.none() + class Meta: model = ApiKey fields = ['name', 'tags'] diff --git a/core/templates/core/collection_detail.html b/core/templates/core/collection_detail.html index 3c11b71..6ca0498 100644 --- a/core/templates/core/collection_detail.html +++ b/core/templates/core/collection_detail.html @@ -13,7 +13,10 @@ {% for tag in collection.filter_tags.all %}#{{ tag.name }}{% endfor %} - {% if can_edit %}{% trans "Edit collection" %}{% endif %} +
+ {% trans "Export" %} + {% if can_edit %}{% trans "Edit collection" %}{% endif %} +
{% if collection.description %}
{{ collection.description|markdown }}
{% endif %} @@ -27,7 +30,7 @@
{% if collection.mode == 'tags' %} - {% for item in tag_items %}
{{ item|collection_item_markdown }}{% if item.comment %}
{{ item.comment|markdown }}
{% endif %}
{% empty %}
{% trans "No entries match the selected tags and types yet." %}
{% endfor %} + {% for item in tag_items %}
{% if item.kind == 'todo' %}
{% csrf_token %}
{% endif %}{{ item|collection_item_markdown }}{% if item.comment %}
{{ item.comment|markdown }}
{% endif %}{% if item.kind == 'todo' %}
{% endif %}
{% empty %}
{% trans "No entries match the selected tags and types yet." %}
{% endfor %} {% else %} {% for section in sections %}{% include 'core/_collection_section_read.html' with section=section %}{% empty %}
{% trans "This collection has no sections yet." %}
{% endfor %} {% endif %} diff --git a/core/templates/core/index.html b/core/templates/core/index.html index 5b5a275..7363051 100644 --- a/core/templates/core/index.html +++ b/core/templates/core/index.html @@ -46,7 +46,7 @@