Merge a986e8939b into ff88669ae4
This commit is contained in:
commit
56e22b5305
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:
|
||||
|
|
|
|||
|
|
@ -87,7 +87,7 @@
|
|||
</table>
|
||||
<p>
|
||||
<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>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
|
|
|||
|
|
@ -1,32 +1,42 @@
|
|||
{% extends "cms/base_site.html" %}
|
||||
{% load i18n static %}
|
||||
{% load i18n static group_tags %}
|
||||
|
||||
{% block extrastyle %}
|
||||
{{ block.super }}
|
||||
<style type="text/css">
|
||||
ul li {float: none;}
|
||||
</style>
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div id="content-main">
|
||||
<h1>Documents de cours</h1>
|
||||
{% regroup object_list by module as module_list %}
|
||||
<ul>
|
||||
{% for module in module_list %}
|
||||
<li><h3>{{ module.grouper }}</h3>
|
||||
<ol>
|
||||
{% for doc in module.list %}
|
||||
<li><a href="{{ doc.doc.url }}">{{ doc.doc.name }} ({{ doc.get_authorization_display }})</a></li>
|
||||
{% endfor %}
|
||||
</ol>
|
||||
</li>
|
||||
{% empty %}
|
||||
<p><i>Désolé, aucun document disponible pour le moment.</i></p>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
<div style="float:left; widht:500px">
|
||||
<ol>
|
||||
<h3>Documents Etudiant</h3>
|
||||
{% for doc in object_list %}
|
||||
{% if doc.authorization == 1 %}
|
||||
<li><a href="{{ doc.doc.url }}">{{ doc.doc.name }}</a></li>
|
||||
{% endif %}
|
||||
{% empty %}
|
||||
<p><i>Aucun document disponible.</i></p>
|
||||
{% endfor %}
|
||||
</ol>
|
||||
</div>
|
||||
{% if user|has_group:"prof" or user.is_staff %}
|
||||
<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 %}
|
||||
<hr>
|
||||
<hr style="margin-top:100px">
|
||||
<p><a href="{% url 'admin:intranet_intranetdoc_changelist' %}">Gestion des documents</a></p>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue