From e03f53692573da7719e537f5315e52b22cd47d11 Mon Sep 17 00:00:00 2001 From: Viacheslav Slinko Date: Fri, 17 May 2024 09:38:08 +0300 Subject: [PATCH] Add option for disabling tag grouping (#735) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Configurable tag grouping * update tag group name --------- Co-authored-by: Sascha Ißbrücker --- .../0035_userprofile_tag_grouping.py | 22 +++++++++++ bookmarks/models.py | 13 +++++++ bookmarks/templates/settings/general.html | 8 ++++ bookmarks/tests/test_settings_general_view.py | 3 ++ bookmarks/tests/test_tag_cloud_template.py | 37 +++++++++++++++++++ bookmarks/views/partials/contexts.py | 25 ++++++++++++- 6 files changed, 106 insertions(+), 2 deletions(-) create mode 100644 bookmarks/migrations/0035_userprofile_tag_grouping.py diff --git a/bookmarks/migrations/0035_userprofile_tag_grouping.py b/bookmarks/migrations/0035_userprofile_tag_grouping.py new file mode 100644 index 0000000..dda5bc3 --- /dev/null +++ b/bookmarks/migrations/0035_userprofile_tag_grouping.py @@ -0,0 +1,22 @@ +# Generated by Django 5.0.3 on 2024-05-14 08:28 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("bookmarks", "0034_bookmark_preview_image_file_and_more"), + ] + + operations = [ + migrations.AddField( + model_name="userprofile", + name="tag_grouping", + field=models.CharField( + choices=[("alphabetical", "Alphabetical"), ("disabled", "Disabled")], + default="alphabetical", + max_length=12, + ), + ), + ] diff --git a/bookmarks/models.py b/bookmarks/models.py index 199142e..7b0a75c 100644 --- a/bookmarks/models.py +++ b/bookmarks/models.py @@ -352,6 +352,12 @@ class UserProfile(models.Model): (TAG_SEARCH_STRICT, "Strict"), (TAG_SEARCH_LAX, "Lax"), ] + TAG_GROUPING_ALPHABETICAL = "alphabetical" + TAG_GROUPING_DISABLED = "disabled" + TAG_GROUPING_CHOICES = [ + (TAG_GROUPING_ALPHABETICAL, "Alphabetical"), + (TAG_GROUPING_DISABLED, "Disabled"), + ] user = models.OneToOneField( get_user_model(), related_name="profile", on_delete=models.CASCADE ) @@ -392,6 +398,12 @@ class UserProfile(models.Model): blank=False, default=TAG_SEARCH_STRICT, ) + tag_grouping = models.CharField( + max_length=12, + choices=TAG_GROUPING_CHOICES, + blank=False, + default=TAG_GROUPING_ALPHABETICAL, + ) enable_sharing = models.BooleanField(default=False, null=False) enable_public_sharing = models.BooleanField(default=False, null=False) enable_favicons = models.BooleanField(default=False, null=False) @@ -419,6 +431,7 @@ class UserProfileForm(forms.ModelForm): "bookmark_link_target", "web_archive_integration", "tag_search", + "tag_grouping", "enable_sharing", "enable_public_sharing", "enable_favicons", diff --git a/bookmarks/templates/settings/general.html b/bookmarks/templates/settings/general.html index acafeb0..f04edab 100644 --- a/bookmarks/templates/settings/general.html +++ b/bookmarks/templates/settings/general.html @@ -110,6 +110,14 @@ result will also include bookmarks where a search term matches otherwise. +
+ + {{ form.tag_grouping|add_class:"form-select width-25 width-sm-100" }} +
+ In alphabetical mode, tags will be grouped by the first letter. + If disabled, tags will not be grouped. +
+