diff --git a/re2o/settings.py b/re2o/settings.py index 96fa9308..14907570 100644 --- a/re2o/settings.py +++ b/re2o/settings.py @@ -78,7 +78,6 @@ LOCAL_APPS = ( 're2o', 'preferences', 'logs', - 'tickets', ) INSTALLED_APPS = ( DJANGO_CONTRIB_APPS + diff --git a/re2o/urls.py b/re2o/urls.py index c9e00667..5db9abe8 100644 --- a/re2o/urls.py +++ b/re2o/urls.py @@ -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 diff --git a/templates/base.html b/templates/base.html index 10590167..6d39f8c8 100644 --- a/templates/base.html +++ b/templates/base.html @@ -100,7 +100,10 @@ with this program; if not, write to the Free Software Foundation, Inc., {% can_view_app cotisations %}
  • {% trans "Manage the subscriptions" %}
  • {% acl_end %} + + {% comment %}
  • {% trans "Tickets" %}
  • + {% endcomment %} {% acl_end %} @@ -131,7 +134,9 @@ with this program; if not, write to the Free Software Foundation, Inc., {% if not request.user.is_authenticated %} diff --git a/tickets/templates/tickets/profil.html b/tickets/templates/tickets/profil.html new file mode 100644 index 00000000..06b727a4 --- /dev/null +++ b/tickets/templates/tickets/profil.html @@ -0,0 +1,23 @@ +{% load i18n %} + +
    +
    +

    + {% trans " Tickets" %} +

    +
    +
    + +
    + {% if tickets_list %} + {% include 'tickets/aff_tickets.html' with tickets_list=tickets_list %} + {% else %} +

    {% trans "No tickets" %}

    + {% endif %} +
    +
    +
    diff --git a/tickets/views.py b/tickets/views.py index cb138590..9c6b42e6 100644 --- a/tickets/views.py +++ b/tickets/views.py @@ -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) diff --git a/users/templates/users/profil.html b/users/templates/users/profil.html index dee64ccc..a7079232 100644 --- a/users/templates/users/profil.html +++ b/users/templates/users/profil.html @@ -528,27 +528,11 @@ with this program; if not, write to the Free Software Foundation, Inc., -
    -
    -

    - {% trans " Tickets" %} -

    -
    -
    - -
    - {% if tickets_list %} - {% include 'tickets/aff_tickets.html' with tickets_list=tickets_list %} - {% else %} -

    {% trans "No tickets" %}

    - {% endif %} -
    -
    -
    + + {% for template in optionnal_templates_list %} + {{ template }} + {% endfor %} + {% endblock %} diff --git a/users/views.py b/users/views.py index a039bad6..426645e5 100644 --- a/users/views.py +++ b/users/views.py @@ -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,