diff --git a/bookmarks/models.py b/bookmarks/models.py index 5b1124f..8878de5 100644 --- a/bookmarks/models.py +++ b/bookmarks/models.py @@ -8,6 +8,9 @@ class Tag(models.Model): date_added = models.DateTimeField() owner = models.ForeignKey(get_user_model(), on_delete=models.CASCADE) + def __str__(self): + return self.name + class Bookmark(models.Model): url = models.URLField() @@ -22,6 +25,10 @@ class Bookmark(models.Model): owner = models.ForeignKey(get_user_model(), on_delete=models.CASCADE) tags = models.ManyToManyField(Tag) + # Attributes might be calculated in query + tag_count = 0 + tag_string = '' + @property def resolved_title(self): return self.website_title if not self.title else self.title @@ -30,6 +37,12 @@ class Bookmark(models.Model): def resolved_description(self): return self.website_description if not self.description else self.description + @property + def tag_names(self): + tag_names = self.tag_string.strip().split(',') if self.tag_string else [] + tag_names.sort(key=str.lower) + return tag_names + def __str__(self): return self.resolved_title + ' (' + self.url[:30] + '...)' diff --git a/bookmarks/queries.py b/bookmarks/queries.py index b79274a..3f659b3 100644 --- a/bookmarks/queries.py +++ b/bookmarks/queries.py @@ -17,11 +17,10 @@ class Concat(Aggregate): def query_bookmarks(user: User, query_string: str): - # Add aggregated tag info to bookmark instances query_set = Bookmark.objects \ - .annotate(tags_count=Count('tags')) \ - .annotate(tags_string=Concat('tags__name')) + .annotate(tag_count=Count('tags'), + tag_string=Concat('tags__name')) # Sanitize query params if not query_string: diff --git a/bookmarks/styles/bookmarks.scss b/bookmarks/styles/bookmarks.scss index f2adf36..d3aa5ff 100644 --- a/bookmarks/styles/bookmarks.scss +++ b/bookmarks/styles/bookmarks.scss @@ -5,11 +5,15 @@ ul.bookmark-list { padding: 0; .description { - color: $gray-color; + color: $gray-color-dark; + + a { + color: $alternative-color; + } } .actions .btn-link { - color: $gray-color-dark; + color: $gray-color; padding-left: 0; padding-right: 0; @@ -17,7 +21,7 @@ ul.bookmark-list { &:hover, &:active, &.active { - color: darken($gray-color-dark, 10%); + color: darken($gray-color, 10%); } } } diff --git a/bookmarks/styles/index.scss b/bookmarks/styles/index.scss index e3bf278..e1b1f6e 100644 --- a/bookmarks/styles/index.scss +++ b/bookmarks/styles/index.scss @@ -1,6 +1,12 @@ // Font sizes $html-font-size: 18px !default; +$alternative-color: #f45d00; +$alternative-color: #FF84E8; +$alternative-color: #98C1D9; +$alternative-color: #7B287D; +$alternative-color: #06c5c2; + // Import Spectre CSS lib @import "../../node_modules/spectre.css/src/spectre"; // Import Spectre icons diff --git a/bookmarks/templates/bookmarks/index.html b/bookmarks/templates/bookmarks/index.html index 3834210..6f632af 100644 --- a/bookmarks/templates/bookmarks/index.html +++ b/bookmarks/templates/bookmarks/index.html @@ -24,14 +24,25 @@
- {% if bookmark.resolved_description is not None %} -