1 # This file is part of FNP-Redakcja, licensed under GNU Affero GPLv3 or later.
2 # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
4 from django.urls import reverse
5 from django import template
6 from django.utils.translation import ugettext as _
8 register = template.Library()
16 def __init__(self, slug, caption, url):
18 self.caption = caption
22 @register.inclusion_tag("documents/main_tabs.html", takes_context=True)
23 def main_tabs(context):
24 active = getattr(context['request'], 'documents_active_tab', None)
27 user = context['user']
28 tabs.append(Tab('my', _('My page'), reverse("documents_user")))
30 tabs.append(Tab('activity', _('Activity'), reverse("documents_activity")))
31 tabs.append(Tab('all', _('All'), reverse("documents_document_list")))
32 tabs.append(Tab('images', _('Images'), reverse("documents_image_list")))
33 tabs.append(Tab('users', _('Users'), reverse("documents_users")))
35 if user.has_perm('documents.add_book'):
36 tabs.append(Tab('create', _('Add'), reverse("documents_create_missing")))
37 tabs.append(Tab('upload', _('Upload'), reverse("documents_upload")))
39 tabs.append(Tab('cover', _('Covers'), reverse("cover_image_list")))
41 return {"tabs": tabs, "active_tab": active}
46 return user.get_full_name() or user.username