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. +
+