From 5dfb09efffc3bc8cf21a794ac6ee1011af951d66 Mon Sep 17 00:00:00 2001 From: OpenClaw Sub-agent Date: Sun, 2 Aug 2026 18:22:38 +1000 Subject: [PATCH] refactor: merge Template back into Link type (per user decision) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Revert TEMPLATE as separate LinkType; templates are plain links whose URL contains {param} placeholders - migration 0055: data-migrate any TEMPLATE links back to LINK, roll back choices (0054 stays in history) - link_form: back to 3 tabs (Link/Custom/Action); Link tab owns the URL field plus a dashed '🔧 Add template parameters' toggle; the Sketch builder auto-shows when the URL contains { } (and stays visible after a manual toggle); hidden on Custom/Action tabs - badges (row/detail/search) detect templates by URL content again; detail page shows Original URL for plain links - views/forms: drop is_template plumbing and TEMPLATE validation --- links/forms.py | 2 - .../0055_merge_template_back_into_link.py | 25 +++++ links/models.py | 1 - links/templates/links/_link_row.html | 2 +- links/templates/links/link_detail.html | 4 +- links/templates/links/link_form.html | 94 ++++++++++--------- links/templates/links/link_list.html | 1 - links/views.py | 2 - 8 files changed, 77 insertions(+), 54 deletions(-) create mode 100644 links/migrations/0055_merge_template_back_into_link.py diff --git a/links/forms.py b/links/forms.py index c70a622..ad33f32 100644 --- a/links/forms.py +++ b/links/forms.py @@ -130,8 +130,6 @@ class LinkForm(forms.ModelForm): if link_type == Link.LinkType.LINK and not original_url: raise forms.ValidationError(_("Original URL is required for Link type.")) - elif link_type == Link.LinkType.TEMPLATE and not original_url: - raise forms.ValidationError(_("Original URL is required for Template type.")) elif link_type == Link.LinkType.CUSTOM and not text: raise forms.ValidationError(_("Text is required for Custom type.")) elif link_type == Link.LinkType.ACTION: diff --git a/links/migrations/0055_merge_template_back_into_link.py b/links/migrations/0055_merge_template_back_into_link.py new file mode 100644 index 0000000..2be6209 --- /dev/null +++ b/links/migrations/0055_merge_template_back_into_link.py @@ -0,0 +1,25 @@ +# Generated by Django 5.2.12 on 2026-08-02 08:17 + +from django.db import migrations, models + + +def template_to_link(apps, schema_editor): + """Template links were merged back into plain links.""" + Link = apps.get_model('links', 'Link') + Link.objects.filter(link_type='TEMPLATE').update(link_type='LINK') + + +class Migration(migrations.Migration): + + dependencies = [ + ('links', '0054_add_template_link_type'), + ] + + operations = [ + migrations.RunPython(template_to_link, migrations.RunPython.noop), + migrations.AlterField( + model_name='link', + name='link_type', + field=models.CharField(choices=[('LINK', 'Link'), ('CUSTOM', 'Custom'), ('ACTION', 'Action')], default='LINK', max_length=10), + ), + ] diff --git a/links/models.py b/links/models.py index 3c5de33..763ba69 100644 --- a/links/models.py +++ b/links/models.py @@ -19,7 +19,6 @@ logger = logging.getLogger(__name__) class Link(models.Model): class LinkType(models.TextChoices): LINK = 'LINK', _('Link') - TEMPLATE = 'TEMPLATE', _('Template') CUSTOM = 'CUSTOM', _('Custom') ACTION = 'ACTION', _('Action') diff --git a/links/templates/links/_link_row.html b/links/templates/links/_link_row.html index 4a1ba34..d2a7ec3 100644 --- a/links/templates/links/_link_row.html +++ b/links/templates/links/_link_row.html @@ -7,7 +7,7 @@ {{ link.alias }} - {% if link.link_type == 'TEMPLATE' or '{' in link.original_url|default:'' and '}' in link.original_url|default:'' %} + {% if '{' in link.original_url|default:'' and '}' in link.original_url|default:'' %} {% trans "Template" %} {% elif link.link_type == 'LINK' %} {% trans "Link" %} diff --git a/links/templates/links/link_detail.html b/links/templates/links/link_detail.html index 8c3316c..0538ea3 100644 --- a/links/templates/links/link_detail.html +++ b/links/templates/links/link_detail.html @@ -10,7 +10,7 @@