mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-12-23 07:23:46 +00:00
Cannonisation de l'affichage des apps optionnels sur le profil et imports conditionnels dans les urls
This commit is contained in:
parent
7099d6d57a
commit
575e570d16
7 changed files with 53 additions and 30 deletions
|
@ -78,7 +78,6 @@ LOCAL_APPS = (
|
|||
're2o',
|
||||
'preferences',
|
||||
'logs',
|
||||
'tickets',
|
||||
)
|
||||
INSTALLED_APPS = (
|
||||
DJANGO_CONTRIB_APPS +
|
||||
|
|
|
@ -49,6 +49,8 @@ from django.contrib import admin
|
|||
from django.utils.translation import gettext_lazy as _
|
||||
from django.views.generic import RedirectView
|
||||
|
||||
from .settings_local import OPTIONNAL_APPS
|
||||
|
||||
from .views import index, about_page, contact_page
|
||||
|
||||
# Admin site configuration
|
||||
|
@ -70,7 +72,6 @@ urlpatterns = [
|
|||
include('cotisations.urls', namespace='cotisations')
|
||||
),
|
||||
url(r'^machines/', include('machines.urls', namespace='machines')),
|
||||
url(r'^tickets/', include('tickets.urls', namespace='tickets')),
|
||||
url(r'^topologie/', include('topologie.urls', namespace='topologie')),
|
||||
url(r'^logs/', include('logs.urls', namespace='logs')),
|
||||
url(
|
||||
|
@ -84,6 +85,10 @@ urlpatterns = [
|
|||
url(r'^admin/login/$', RedirectView.as_view(pattern_name='login')),
|
||||
url(r'^admin/', include(admin.site.urls)),
|
||||
]
|
||||
|
||||
|
||||
urlpatterns += [url(r'^{}/'.format(app), include('{}.urls'.format(app), namespace=app)) for app in OPTIONNAL_APPS]
|
||||
|
||||
# Add debug_toolbar URLs if activated
|
||||
if 'debug_toolbar' in settings.INSTALLED_APPS:
|
||||
import debug_toolbar
|
||||
|
|
|
@ -100,7 +100,10 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||
{% can_view_app cotisations %}
|
||||
<li><a href="{% url 'cotisations:index' %}"><i class="fa fa-eur"></i> {% trans "Manage the subscriptions" %}</a></li>
|
||||
{% acl_end %}
|
||||
|
||||
{% comment %}
|
||||
<li><a href="{% url 'tickets:aff-tickets' %}"><i class="fa fa-ticket"></i> {% trans "Tickets" %}</a></li>
|
||||
{% endcomment %}
|
||||
</ul>
|
||||
</li>
|
||||
{% acl_end %}
|
||||
|
@ -131,7 +134,9 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||
<ul class="dropdown-menu">
|
||||
<li><a href="{% url 'about' %}"><i class="fa fa-info-circle"></i> {% trans "About" %}</a></li>
|
||||
<li><a href="{% url 'contact' %}"><i class="fa fa-at"></i> {% trans "Contact" %}</a></li>
|
||||
{% comment %}
|
||||
<li><a href="{% url 'tickets:new-ticket' %}"><i class="fa fa-ticket"></i> {% trans "Ouvrir un ticket" %}</a><li>
|
||||
{% endcomment %}
|
||||
</ul>
|
||||
</li>
|
||||
{% if not request.user.is_authenticated %}
|
||||
|
|
23
tickets/templates/tickets/profil.html
Normal file
23
tickets/templates/tickets/profil.html
Normal file
|
@ -0,0 +1,23 @@
|
|||
{% load i18n %}
|
||||
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading clearfix profil" data-parent="#accordion" data-toggle="collapse" data-target="#ticket">
|
||||
<h3 class="panel-title pull-left">
|
||||
<i class="fa fa-ticket"></i>{% trans " Tickets" %}
|
||||
</h3>
|
||||
</div>
|
||||
<div id="ticket" class="panel-collapse collapse">
|
||||
<div class="panel-body">
|
||||
<a class="btn btn-primary btn-sm" role="button" href="{% url 'tickets:new-ticket' %}">
|
||||
<i class="fa fa-ticket"></i>{% trans " Open a Ticket" %}
|
||||
</a>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
{% if tickets_list %}
|
||||
{% include 'tickets/aff_tickets.html' with tickets_list=tickets_list %}
|
||||
{% else %}
|
||||
<p>{% trans "No tickets" %}</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
|
@ -1,5 +1,6 @@
|
|||
from django.contrib import messages
|
||||
from django.shortcuts import render, redirect
|
||||
from django.template.loader import render_to_string
|
||||
from django.urls import reverse
|
||||
from django.forms import modelformset_factory
|
||||
from re2o.views import form
|
||||
|
@ -50,3 +51,8 @@ def aff_tickets(request):
|
|||
tickets = Ticket.objects.all().order_by('-date')
|
||||
return render(request,'tickets/index.html',
|
||||
{'tickets_list':tickets})
|
||||
def profil(request,user):
|
||||
""" Vue cannonique d'affichage des tickets dans l'accordeon du profil"""
|
||||
tickets = Ticket.objects.filter(user=user).all().order_by('-date')
|
||||
context = {'tickets_list':tickets}
|
||||
return render_to_string('tickets/profil.html', context=context, request=request, using=None)
|
||||
|
|
|
@ -528,27 +528,11 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading clearfix profil" data-parent="#accordion" data-toggle="collapse" data-target="#ticket">
|
||||
<h3 class="panel-title pull-left">
|
||||
<i class="fa fa-ticket"></i>{% trans " Tickets" %}
|
||||
</h3>
|
||||
</div>
|
||||
<div id="ticket" class="panel-collapse collapse">
|
||||
<div class="panel-body">
|
||||
<a class="btn btn-primary btn-sm" role="button" href="{% url 'tickets:new-ticket' %}">
|
||||
<i class="fa fa-ticket"></i>{% trans " Open a Ticket" %}
|
||||
</a>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
{% if tickets_list %}
|
||||
{% include 'tickets/aff_tickets.html' with tickets_list=tickets_list %}
|
||||
{% else %}
|
||||
<p>{% trans "No tickets" %}</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% for template in optionnal_templates_list %}
|
||||
{{ template }}
|
||||
{% endfor %}
|
||||
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
|
|
|
@ -47,6 +47,7 @@ from django.http import HttpResponse
|
|||
from django.http import HttpResponseRedirect
|
||||
from django.views.decorators.csrf import csrf_exempt
|
||||
from django.utils.translation import ugettext as _
|
||||
from django.template import loader
|
||||
|
||||
from rest_framework.renderers import JSONRenderer
|
||||
from reversion import revisions as reversion
|
||||
|
@ -54,10 +55,9 @@ from reversion import revisions as reversion
|
|||
from cotisations.models import Facture, Paiement
|
||||
from machines.models import Machine
|
||||
|
||||
# A IMPORTER SOUS CONDITION QUE TICKET SOIT INSTALLED
|
||||
from tickets.models import Ticket
|
||||
|
||||
from preferences.models import OptionalUser, GeneralOption, AssoOption
|
||||
from importlib import import_module
|
||||
from re2o.settings_local import OPTIONNAL_APPS
|
||||
from re2o.views import form
|
||||
from re2o.utils import (
|
||||
all_has_access,
|
||||
|
@ -978,8 +978,10 @@ def profil(request, users, **_kwargs):
|
|||
request.GET.get('order'),
|
||||
SortTable.MACHINES_INDEX
|
||||
)
|
||||
tickets = Ticket.objects.filter(user=users).all().order_by('-date')
|
||||
nb_tickets = tickets.count()
|
||||
|
||||
optionnal_apps = [import_module(app) for app in OPTIONNAL_APPS]
|
||||
optionnal_templates_list = [app.views.profil(request,users) for app in optionnal_apps]
|
||||
|
||||
pagination_large_number = GeneralOption.get_cached_value(
|
||||
'pagination_large_number'
|
||||
)
|
||||
|
@ -1022,8 +1024,7 @@ def profil(request, users, **_kwargs):
|
|||
'users': users,
|
||||
'machines_list': machines,
|
||||
'nb_machines': nb_machines,
|
||||
'tickets_list': tickets,
|
||||
'nb_tickets': nb_tickets,
|
||||
'optionnal_templates_list': optionnal_templates_list,
|
||||
'facture_list': factures,
|
||||
'ban_list': bans,
|
||||
'white_list': whitelists,
|
||||
|
|
Loading…
Reference in a new issue