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 = [
|
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):
|
def get_queryset(self):
|
||||||
groups = self.request.user.groups.values_list('name',flat=True)
|
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:
|
if self.request.user.is_superuser:
|
||||||
qs = qs.filter(authorization__in=[1,2,3])
|
qs = qs.filter(authorization__in=[1,2,3])
|
||||||
elif 'prof' in groups:
|
elif 'prof' in groups:
|
||||||
|
|
|
||||||
|
|
@ -87,7 +87,7 @@
|
||||||
</table>
|
</table>
|
||||||
<p>
|
<p>
|
||||||
<a href="{% url 'module-pdf' object.id %}">Imprimer en PDF</a>
|
<a href="{% url 'module-pdf' object.id %}">Imprimer en PDF</a>
|
||||||
<a href="{% url 'intranet-list' %}">Documents de cours (connexion requise)</a>
|
<a href="{% url 'intranet-list' object.id %}">Documents de cours (connexion requise)</a>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
||||||
|
|
@ -1,32 +1,42 @@
|
||||||
{% extends "cms/base_site.html" %}
|
{% extends "cms/base_site.html" %}
|
||||||
{% load i18n static %}
|
{% load i18n static group_tags %}
|
||||||
|
|
||||||
{% block extrastyle %}
|
{% block extrastyle %}
|
||||||
{{ block.super }}
|
{{ block.super }}
|
||||||
<style type="text/css">
|
|
||||||
ul li {float: none;}
|
|
||||||
</style>
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<div id="content-main">
|
<div id="content-main">
|
||||||
<h1>Documents de cours</h1>
|
<h1>Documents de cours</h1>
|
||||||
{% regroup object_list by module as module_list %}
|
<div style="float:left; widht:500px">
|
||||||
<ul>
|
<ol>
|
||||||
{% for module in module_list %}
|
<h3>Documents Etudiant</h3>
|
||||||
<li><h3>{{ module.grouper }}</h3>
|
{% for doc in object_list %}
|
||||||
<ol>
|
{% if doc.authorization == 1 %}
|
||||||
{% for doc in module.list %}
|
<li><a href="{{ doc.doc.url }}">{{ doc.doc.name }}</a></li>
|
||||||
<li><a href="{{ doc.doc.url }}">{{ doc.doc.name }} ({{ doc.get_authorization_display }})</a></li>
|
{% endif %}
|
||||||
{% endfor %}
|
{% empty %}
|
||||||
</ol>
|
<p><i>Aucun document disponible.</i></p>
|
||||||
</li>
|
{% endfor %}
|
||||||
{% empty %}
|
</ol>
|
||||||
<p><i>Désolé, aucun document disponible pour le moment.</i></p>
|
</div>
|
||||||
{% endfor %}
|
{% if user|has_group:"prof" or user.is_staff %}
|
||||||
</ul>
|
<div style="margin-left:600px; width:500px">
|
||||||
|
<ol>
|
||||||
|
<h3>Documents ENSEIGNANT</h3>
|
||||||
|
{% for doc in object_list %}
|
||||||
|
{% if doc.authorization == 2 %}
|
||||||
|
<li><a href="{{ doc.doc.url }}">{{ doc.doc.name }}</a></li>
|
||||||
|
{% endif %}
|
||||||
|
{% empty %}
|
||||||
|
<p><i>Aucun document disponible.</i></p>
|
||||||
|
{% endfor %}
|
||||||
|
</ol>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
{% if user.is_staff %}
|
{% if user.is_staff %}
|
||||||
<hr>
|
<hr style="margin-top:100px">
|
||||||
<p><a href="{% url 'admin:intranet_intranetdoc_changelist' %}">Gestion des documents</a></p>
|
<p><a href="{% url 'admin:intranet_intranetdoc_changelist' %}">Gestion des documents</a></p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue