new template for intranet docs

This commit is contained in:
alazo 2018-09-01 12:30:31 +02:00
parent 1b41d838d9
commit a986e8939b
6 changed files with 41 additions and 22 deletions

View file

View file

@ -0,0 +1,9 @@
from django import template
from django.contrib.auth.models import Group
register = template.Library()
@register.filter(name='has_group')
def has_group(user, group_name):
group = Group.objects.get(name=group_name)
return True if group in user.groups.all() else False

View file

@ -3,5 +3,5 @@ from intranet import views
urlpatterns = [
path('list/', views.IntranetListView.as_view(), name='intranet-list'),
path('list/<int:module>/', views.IntranetListView.as_view(), name='intranet-list'),
]

View file

@ -12,7 +12,7 @@ class IntranetListView(LoginRequiredMixin, ListView):
def get_queryset(self):
groups = self.request.user.groups.values_list('name',flat=True)
qs = IntranetDoc.objects.filter(published=True)
qs = IntranetDoc.objects.filter(published=True, module=self.kwargs['module'])
if self.request.user.is_superuser:
qs = qs.filter(authorization__in=[1,2,3])
elif 'prof' in groups: