Skip to content

Commit

Permalink
Hide adverts created by deactivated users (#90)
Browse files Browse the repository at this point in the history
* Hide adverts created by deactivated users

* Hide adverts created by deactivated users

* Hide adverts created by deactivated users

* Hide adverts created by deactivated users

* Hide adverts created by deactivated users

* Hide adverts created by deactivated users
  • Loading branch information
berk76 authored Oct 5, 2024
1 parent 605fa0f commit 9326fdf
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions svjis/articles/views_adverts.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,13 @@


def get_side_menu(active_item, user):
description_template = '{} ({})'
result = []
result.append(
{
'description': _("All") + f' ({models.Advert.objects.filter(published=True).count()})',
'description': description_template.format(
_("All"), models.Advert.objects.filter(published=True, created_by_user__is_active=True).count()
),
'link': reverse(adverts_list_view) + '?scope=all',
'active': True if active_item == 'all' else False,
}
Expand All @@ -22,7 +25,10 @@ def get_side_menu(active_item, user):
for t in types:
result.append(
{
'description': t.description + f' ({models.Advert.objects.filter(published=True, type=t).count()})',
'description': description_template.format(
t.description,
models.Advert.objects.filter(published=True, created_by_user__is_active=True, type=t).count(),
),
'link': reverse(adverts_list_view) + f'?scope={t.description}',
'active': True if active_item == t.description else False,
}
Expand All @@ -31,7 +37,9 @@ def get_side_menu(active_item, user):
if user.has_perm('articles.svjis_add_advert'):
result.append(
{
'description': _("Mine") + f' ({models.Advert.objects.filter(created_by_user=user).count()})',
'description': description_template.format(
_("Mine"), models.Advert.objects.filter(created_by_user=user).count()
),
'link': reverse(adverts_list_view) + '?scope=mine',
'active': True if active_item == 'mine' else False,
}
Expand All @@ -44,7 +52,7 @@ def get_side_menu(active_item, user):
@permission_required("articles.svjis_view_adverts_menu")
@require_GET
def adverts_list_view(request):
advert_list = models.Advert.objects.filter(published=True)
advert_list = models.Advert.objects.filter(published=True, created_by_user__is_active=True)
scope = request.GET.get('scope', 'all')
scope_description = _('All')

Expand Down

0 comments on commit 9326fdf

Please sign in to comment.