new template for intranet docs
This commit is contained in:
parent
1b41d838d9
commit
a986e8939b
6 changed files with 41 additions and 22 deletions
0
intranet/templatetags/__init__.py
Normal file
0
intranet/templatetags/__init__.py
Normal file
9
intranet/templatetags/group_tags.py
Normal file
9
intranet/templatetags/group_tags.py
Normal 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
|
||||
|
|
@ -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'),
|
||||
]
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue