Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance Category visibility #119

Merged
merged 2 commits into from
Jan 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions backend/templates/songs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
{% load static %}
{% load i18n %}

{% block title %}{{ title }}{% endblock %}

{% block extra_head %}
<script async src="{% static 'js/chords.js' %}"></script>
<script defer type="text/javascript" src="{% static "datatables/datatables.min.js" %}"></script>
Expand Down
9 changes: 9 additions & 0 deletions backend/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ def get_queryset(self):
queryset = queryset.filter(archived=False)
return queryset

def get_title(self):
"""Return title of this song set"""
return self.request.tenant.display_name

def get_context_data(self, *, object_list=None, **kwargs):
context_data = super().get_context_data(object_list=object_list, **kwargs)

Expand All @@ -59,6 +63,7 @@ def get_context_data(self, *, object_list=None, **kwargs):
i += 1

context_data["songs"] = json.dumps(songs, cls=DjangoJSONEncoder)
context_data["title"] = self.get_title()
return context_data


Expand All @@ -68,6 +73,10 @@ class AllSongListView(BaseSongListView):
def get_queryset(self):
return super().get_queryset().filter(categories__tenant=self.request.tenant)

def get_title(self):
"""Return title of this song set"""
return f'{_("All Songs")} | {self.request.tenant.display_name}'


class IndexSongListView(RedirectView):
"""Shows first available category"""
Expand Down
10 changes: 9 additions & 1 deletion category/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,20 @@ class CategorySongsListView(BaseSongListView, AnalyticsMixin):
def get_key(self):
return self.kwargs["slug"]

def category_queryset(self):
"""Returns queryset for this category"""
return Category.objects.filter(slug=self.kwargs["slug"], tenant=self.request.tenant)

def get_queryset(self):
slug = self.kwargs["slug"]
if not Category.objects.filter(slug=slug, tenant=self.request.tenant).exists():
if not self.category_queryset().exists():
raise Http404(_("Category with url /%(slug)s does not exist") % {"slug": slug})
return super().get_queryset().filter(categories__slug=slug)

def get_title(self):
"""Return title of this song set"""
return f"{self.category_queryset().get().name} | {self.request.tenant.display_name}"


class CategoryListView(LocalAdminRequired, ListView):
"""Lists all categories"""
Expand Down
2 changes: 1 addition & 1 deletion frontend/static/styles.sass
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ $border-color: $bgHighlight
.dropdown-menu
--bs-dropdown-link-color: #{$colDefault}
--bs-dropdown-link-hover-color: #{$colHighlight}
--bs-dropdown-link-active-color: #{$colHighlight}
--bs-dropdown-link-active-bg: #{$colDefault}

//.chord
// position: absolute
Expand Down
2 changes: 1 addition & 1 deletion frontend/templates/menu/bootstrap4-menu-submenu.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<button type="submit" class="btn-link dropdown-item">{% if item.skip_translate %}{{ item.title }}{% else %}{% trans item.title %}{% endif %}</button>
</form>
{% else %}
<a class="dropdown-item" href="{{ item.url }}">{% if item.skip_translate %}{{ item.title }}{% else %}{% trans item.title %}{% endif %}</a>
<a class="dropdown-item {% if item.selected %}active{% endif %}" href="{{ item.url }}">{% if item.skip_translate %}{{ item.title }}{% else %}{% trans item.title %}{% endif %}</a>
{% endif %}
{% endif %}
{% endfor %}
Expand Down
Loading