mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-12-22 23:13:46 +00:00
Merge branch 'split_profil' into 'dev'
Split profil See merge request re2o/re2o!564
This commit is contained in:
commit
38b79aec19
10 changed files with 507 additions and 101 deletions
|
@ -96,6 +96,16 @@ class BaseInvoice(RevMixin, AclMixin, FieldPermissionModelMixin, models.Model):
|
|||
)
|
||||
return name
|
||||
|
||||
def name_detailed(self):
|
||||
"""
|
||||
Return:
|
||||
- a list of strings with the name of all article in the invoice
|
||||
and their quantity.
|
||||
"""
|
||||
ventes = self.vente_set.all()
|
||||
strings = ["{} x {}".format(v.number, v.name) for v in ventes]
|
||||
return strings
|
||||
|
||||
|
||||
# TODO : change facture to invoice
|
||||
class Facture(BaseInvoice):
|
||||
|
|
141
cotisations/templates/cotisations/aff_profil.html
Normal file
141
cotisations/templates/cotisations/aff_profil.html
Normal file
|
@ -0,0 +1,141 @@
|
|||
{% comment %}
|
||||
Re2o est un logiciel d'administration développé initiallement au rezometz. Il
|
||||
se veut agnostique au réseau considéré, de manière à être installable en
|
||||
quelques clics.
|
||||
|
||||
Copyright © 2017 Gabriel Détraz
|
||||
Copyright © 2017 Lara Kermarec
|
||||
Copyright © 2017 Augustin Lemesle
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
{% endcomment %}
|
||||
|
||||
{% load acl %}
|
||||
{% load i18n %}
|
||||
{% load logs_extra %}
|
||||
|
||||
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading clearfix profil" data-parent="#accordion" data-toggle="collapse"
|
||||
data-target="#subscriptions">
|
||||
<h3 class="panel-title pull-left">
|
||||
<i class="fa fa-eur"></i>
|
||||
{% trans "Subscriptions" %}
|
||||
</h3>
|
||||
</div>
|
||||
<div id="subscriptions" class="panel-collapse collapse">
|
||||
<div class="panel-body">
|
||||
{% can_create Facture %}
|
||||
<a class="btn btn-primary btn-sm" role="button" href="{% url 'cotisations:new-facture' users.id %}">
|
||||
<i class="fa fa-eur"></i>
|
||||
{% trans "Add a subscription" %}
|
||||
</a>
|
||||
{% if user_solde %}
|
||||
<a class="btn btn-primary btn-sm" role="button" href="{% url 'cotisations:credit-solde' users.id %}">
|
||||
<i class="fa fa-eur"></i>
|
||||
{% trans "Edit the balance" %}
|
||||
</a>
|
||||
{% endif%}
|
||||
{% acl_end %}
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
{% if facture_list %}
|
||||
<div class="table-responsive">
|
||||
{% if facture_list.paginator %}
|
||||
{% include 'pagination.html' with list=facture_list %}
|
||||
{% endif %}
|
||||
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
{% trans "User" as tr_user %}
|
||||
{% include 'buttons/sort.html' with prefix='cotis' col='user' text=tr_user %}
|
||||
</th>
|
||||
<th>{% trans "Designation" %}</th>
|
||||
<th>{% trans "Total price" %}</th>
|
||||
<th>
|
||||
{% trans "Payment method" as tr_payment_method %}
|
||||
{% include 'buttons/sort.html' with prefix='cotis' col='paiement' text=tr_payment_method %}
|
||||
</th>
|
||||
<th>
|
||||
{% trans "Date" as tr_date %}
|
||||
{% include 'buttons/sort.html' with prefix='cotis' col='date' text=tr_date %}
|
||||
</th>
|
||||
<th>
|
||||
{% trans "Invoice ID" as tr_invoice_id %}
|
||||
{% include 'buttons/sort.html' with prefix='cotis' col='id' text=tr_invoice_id %}
|
||||
</th>
|
||||
<th></th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
{% for facture in facture_list %}
|
||||
<tr>
|
||||
<td><a href="{% url 'users:profil' userid=facture.user.id %}">{{ facture.user }}</a></td>
|
||||
<td>
|
||||
<table class="table-striped">
|
||||
{% for article in facture.name_detailed %}
|
||||
<tr>
|
||||
<td>
|
||||
{{ article }}
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
</td>
|
||||
<td>{{ facture.prix_total }}</td>
|
||||
<td>{{ facture.paiement }}</td>
|
||||
<td>{{ facture.date }}</td>
|
||||
<td>{{ facture.id }}</td>
|
||||
<td>
|
||||
{% can_edit facture %}
|
||||
{% include 'buttons/edit.html' with href='cotisations:edit-facture' id=facture.id %}
|
||||
{% acl_else %}
|
||||
{% trans "Controlled invoice" %}
|
||||
{% acl_end %}
|
||||
{% can_delete facture %}
|
||||
{% include 'buttons/suppr.html' with href='cotisations:del-facture' id=facture.id %}
|
||||
{% acl_end %}
|
||||
{% history_button facture %}
|
||||
</td>
|
||||
<td>
|
||||
{% if facture.valid %}
|
||||
<a class="btn btn-primary btn-sm" role="button" href="{% url 'cotisations:facture-pdf' facture.id %}">
|
||||
<i class="fa fa-file-pdf-o"></i> {% trans "PDF" %}
|
||||
</a>
|
||||
{% else %}
|
||||
<i class="text-danger">{% trans "Invalidated invoice" %}</i>
|
||||
{% endif %}
|
||||
{% if facture.control and facture.is_subscription %}
|
||||
<a class="btn btn-primary btn-sm" role="button" href="{% url 'cotisations:voucher-pdf' facture.id %}">
|
||||
<i class="fa fa-file-pdf-o"></i> {% trans "Voucher" %}
|
||||
</a>
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
|
||||
{% if facture_list.paginator %}
|
||||
{% include 'pagination.html' with list=facture_list %}
|
||||
{% endif %}
|
||||
</div>
|
||||
{% else %}
|
||||
<p>{% trans "No invoice" %}</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
|
@ -33,6 +33,7 @@ import os
|
|||
|
||||
from django.urls import reverse
|
||||
from django.shortcuts import render, redirect, get_object_or_404
|
||||
from django.template.loader import render_to_string
|
||||
from django.contrib.auth.decorators import login_required
|
||||
from django.contrib import messages
|
||||
from django.db.models import ProtectedError
|
||||
|
@ -1060,3 +1061,26 @@ def voucher_pdf(request, invoice, **_kwargs):
|
|||
"date_begin": invoice.date,
|
||||
},
|
||||
)
|
||||
|
||||
def aff_profil(request,user):
|
||||
"""View used to display the cotisations on a user's profil."""
|
||||
|
||||
factures = Facture.objects.filter(user=user)
|
||||
factures = SortTable.sort(
|
||||
factures,
|
||||
request.GET.get("col"),
|
||||
request.GET.get("order"),
|
||||
SortTable.COTISATIONS_INDEX,
|
||||
)
|
||||
|
||||
pagination_large_number = GeneralOption.get_cached_value("pagination_large_number")
|
||||
factures = re2o_paginator(request, factures,pagination_large_number)
|
||||
|
||||
context = {
|
||||
"users":user,
|
||||
"facture_list": factures,
|
||||
}
|
||||
|
||||
return render_to_string(
|
||||
"cotisations/aff_profil.html",context=context,request=request,using=None
|
||||
)
|
||||
|
|
271
machines/templates/machines/aff_profil.html
Normal file
271
machines/templates/machines/aff_profil.html
Normal file
|
@ -0,0 +1,271 @@
|
|||
{% comment %}
|
||||
Re2o est un logiciel d'administration développé initiallement au rezometz. Il
|
||||
se veut agnostique au réseau considéré, de manière à être installable en
|
||||
quelques clics.
|
||||
|
||||
Copyright © 2017 Gabriel Détraz
|
||||
Copyright © 2017 Lara Kermarec
|
||||
Copyright © 2017 Augustin Lemesle
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
{% endcomment %}
|
||||
|
||||
{% load acl %}
|
||||
{% load logs_extra %}
|
||||
{% load i18n %}
|
||||
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading clearfix profil" data-parent="#accordion" data-toggle="collapse"
|
||||
data-target="#machines">
|
||||
<h3 class="panel-title pull-left">
|
||||
<i class="fa fa-desktop"></i>
|
||||
{% trans "Machines" %}
|
||||
<span class="badge">{{ nb_machines }}</span>
|
||||
</h3>
|
||||
</div>
|
||||
<div id="machines" class="panel-collapse collapse">
|
||||
<div class="panel-body">
|
||||
<a class="btn btn-primary btn-sm" role="button" href="{% url 'machines:new-machine' users.id %}">
|
||||
<i class="fa fa-desktop"></i>
|
||||
{% trans "Add a machine" %}
|
||||
</a>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
{% if machines_list %}
|
||||
<div class="table-responsive">
|
||||
{% if machines_list.paginator %}
|
||||
{% include 'pagination.html' with list=machines_list go_to_id="machines" %}
|
||||
{% endif %}
|
||||
|
||||
<table class="table" id="machines_table">
|
||||
<colgroup>
|
||||
<col>
|
||||
<col>
|
||||
<col>
|
||||
<col width="{% if ipv6_enabled %}300{% else %}150{% endif %}px">
|
||||
<col width="144px">
|
||||
</colgroup>
|
||||
<thead>
|
||||
{% trans "DNS name" as tr_dns_name %}
|
||||
<th>{% include 'buttons/sort.html' with prefix='machine' col='name' text=tr_dns_name %}</th>
|
||||
<th>{% trans "Type" %}</th>
|
||||
<th>{% trans "MAC address" %}</th>
|
||||
<th>{% trans "IP address" %}</th>
|
||||
<th>{% trans "Actions" %}</th>
|
||||
<tbody>
|
||||
{% for machine in machines_list %}
|
||||
<tr class="info">
|
||||
<td colspan="4">
|
||||
{% trans "No name" as tr_no_name %}
|
||||
{% trans "View the profile" as tr_view_the_profile %}
|
||||
{% if machine.active %}
|
||||
<span class="text-success">
|
||||
{% else %}
|
||||
<span class="text-warning">{% trans "Deactivated" %}:
|
||||
{% endif %}
|
||||
<b>{{ machine.get_name|default:tr_no_name }}</b> </span><i class="fa fa-angle-right"></i>
|
||||
<a href="{% url 'users:profil' userid=machine.user.id %}" title=tr_view_the_profile>
|
||||
<i class="fa fa-user"></i> {{ machine.user }}
|
||||
</a>
|
||||
</td>
|
||||
<td class="text-right">
|
||||
{% can_create Interface machine.id %}
|
||||
{% trans "Create an interface" as tr_create_an_interface %}
|
||||
{% include 'buttons/add.html' with href='machines:new-interface' id=machine.id desc=tr_create_an_interface %}
|
||||
{% acl_end %}
|
||||
{% history_button machine %}
|
||||
{% can_delete machine %}
|
||||
{% include 'buttons/suppr.html' with href='machines:del-machine' id=machine.id %}
|
||||
{% acl_end %}
|
||||
</td>
|
||||
</tr>
|
||||
{% for interface in machine.interface_set.all %}
|
||||
<tr>
|
||||
<td>
|
||||
{% if interface.domain.related_domain.all %}
|
||||
{{ interface.domain }}
|
||||
<button class="btn btn-default btn-xs" type="button" data-toggle="collapse"
|
||||
data-target="#collapseDomain_{{ interface.id }}" aria-expanded="true"
|
||||
aria-controls="collapseDomain_{{ interface.id }}">
|
||||
{% trans "Display the aliases" %}
|
||||
</button>
|
||||
{% else %}
|
||||
{{ interface.domain }}
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>
|
||||
{{ interface.machine_type }}
|
||||
</td>
|
||||
<td>
|
||||
{{ interface.mac_address }}
|
||||
<button class="btn btn-default btn-xs" type="button" data-toggle="collapse"
|
||||
data-target="#collapseVendor_{{ interface.id }}" aria-expanded="true"
|
||||
aria-controls="collapseVendor_{{ interface.id }}">
|
||||
{% trans "Display the vendor" %}
|
||||
</button>
|
||||
</td>
|
||||
<td>
|
||||
<b>IPv4</b> {{ interface.ipv4 }}
|
||||
<br>
|
||||
{% if ipv6_enabled and interface.ipv6 != 'None' %}
|
||||
<b>IPv6</b>
|
||||
<button class="btn btn-default btn-xs" type="button" data-toggle="collapse"
|
||||
data-target="#collapseIpv6_{{ interface.id }}" aria-expanded="true"
|
||||
aria-controls="collapseIpv6_{{ interface.id }}">
|
||||
{% trans "Display the IPv6 address" %}
|
||||
</button>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td class="text-right">
|
||||
<div style="width: 128px;">
|
||||
<div class="btn-group" role="group">
|
||||
<button class="btn btn-primary btn-sm dropdown-toggle" type="button"
|
||||
id="editioninterface" data-toggle="dropdown" aria-haspopup="true"
|
||||
aria-expanded="true">
|
||||
<i class="fa fa-edit"></i> <span class="caret"></span>
|
||||
</button>
|
||||
<ul class="dropdown-menu" aria-labelledby="editioninterface">
|
||||
{% can_edit interface %}
|
||||
<li>
|
||||
<a href="{% url 'machines:edit-interface' interface.id %}">
|
||||
<i class="fa fa-edit"></i>
|
||||
{% trans "Edit" %}
|
||||
</a>
|
||||
</li>
|
||||
{% acl_end %}
|
||||
{% can_create Domain interface.id %}
|
||||
<li>
|
||||
<a href="{% url 'machines:index-alias' interface.id %}">
|
||||
<i class="fa fa-edit"></i>
|
||||
{% trans "Manage the aliases" %}
|
||||
</a>
|
||||
</li>
|
||||
{% acl_end %}
|
||||
{% can_create Ipv6List interface.id %}
|
||||
<li>
|
||||
<a href="{% url 'machines:index-ipv6' interface.id %}">
|
||||
<i class="fa fa-edit"></i>
|
||||
{% trans "Manage the IPv6 addresses" %}
|
||||
</a>
|
||||
</li>
|
||||
{% acl_end %}
|
||||
{% can_create SshFp interface.machine.id %}
|
||||
<li>
|
||||
<a href="{% url 'machines:index-sshfp' interface.machine.id %}">
|
||||
<i class="fa fa-edit"></i>
|
||||
{% trans "Manage the SSH fingerprints" %}
|
||||
</a>
|
||||
</li>
|
||||
{% acl_end %}
|
||||
{% can_create OuverturePortList %}
|
||||
<li>
|
||||
<a href="{% url 'machines:port-config' interface.id %}">
|
||||
<i class="fa fa-edit"></i>
|
||||
{% trans "Manage the ports configuration" %}
|
||||
</a>
|
||||
</li>
|
||||
{% acl_end %}
|
||||
</ul>
|
||||
</div>
|
||||
{% history_button interface %}
|
||||
{% can_delete interface %}
|
||||
{% include 'buttons/suppr.html' with href='machines:del-interface' id=interface.id %}
|
||||
{% acl_end %}
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan=5 style="border-top: none; padding: 1px;">
|
||||
<div class="collapse in" id="collapseVendor_{{ interface.id }}">
|
||||
<ul class="list-group" style="margin-bottom: 0;">
|
||||
<li class="list-group-item col-xs-6 col-sm-6 col-md-6" style="border: none;">
|
||||
{{ interface.get_vendor }}
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
{% if ipv6_enabled and interface.ipv6 != 'None' %}
|
||||
<tr>
|
||||
<td colspan=5 style="border-top: none; padding: 1px;">
|
||||
<div class="collapse in" id="collapseIpv6_{{ interface.id }}">
|
||||
<ul class="list-group" style="margin-bottom: 0;">
|
||||
{% for ipv6 in interface.ipv6.all %}
|
||||
<li class="list-group-item col-xs-6 col-sm-6 col-md-6" style="border: none;">
|
||||
{{ ipv6 }}
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
{% if interface.domain.related_domain.all %}
|
||||
<tr>
|
||||
<td colspan=5 style="border-top: none; padding: 1px;">
|
||||
<div class="collapse in" id="collapseDomain_{{ interface.id }}">
|
||||
<ul class="list-group" style="margin-bottom: 0;">
|
||||
{% for al in interface.domain.related_domain.all %}
|
||||
<li class="list-group-item col-xs-6 col-sm-4 col-md-3" style="border: none;">
|
||||
<a href="http://{{ al }}">
|
||||
{{ al }}
|
||||
<i class="fa fa-share"></i>
|
||||
</a>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
<tr>
|
||||
<td colspan="8"></td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<script>
|
||||
$("#machines_table").ready(function () {
|
||||
var alias_div = [{% for machine in machines_list %}{% for interface in machine.interface_set.all %}{% if interface.domain.related_domain.all %}$("#collapseDomain_{{ interface.id }}"), {% endif %}{% endfor %}{% endfor %}];
|
||||
for (var i = 0; i < alias_div.length; i++) {
|
||||
alias_div[i].collapse('hide');
|
||||
}
|
||||
});
|
||||
$("#machines_table").ready(function () {
|
||||
var ipv6_div = [{% for machine in machines_list %}{% for interface in machine.interface_set.all %}{% if interface.ipv6.all %}$("#collapseIpv6_{{ interface.id }}"), {% endif %}{% endfor %}{% endfor %}];
|
||||
for (var i = 0; i < ipv6_div.length; i++) {
|
||||
ipv6_div[i].collapse('hide');
|
||||
}
|
||||
});
|
||||
$("#machines_table").ready(function () {
|
||||
var vendor_div = [{% for machine in machines_list %}{% for interface in machine.interface_set.all %}{% if interface.get_vendor %}$("#collapseVendor_{{ interface.id }}"), {% endif %}{% endfor %}{% endfor %}];
|
||||
for (var i = 0; i < vendor_div.length; i++) {
|
||||
vendor_div[i].collapse('hide');
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
{% if machines_list.paginator %}
|
||||
{% include 'pagination.html' with list=machines_list go_to_id="machines" %}
|
||||
{% endif %}
|
||||
</div>
|
||||
{% else %}
|
||||
<p>{% trans "No machine" %}</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
|
@ -39,6 +39,7 @@ from django.db import IntegrityError
|
|||
from django.forms import modelformset_factory
|
||||
from django.http import HttpResponse
|
||||
from django.shortcuts import render, redirect
|
||||
from django.template.loader import render_to_string
|
||||
from django.urls import reverse
|
||||
from django.utils.translation import ugettext as _
|
||||
from django.views.decorators.csrf import csrf_exempt
|
||||
|
@ -1311,6 +1312,40 @@ def index(request):
|
|||
machines_list = re2o_paginator(request, machines_list, pagination_large_number)
|
||||
return render(request, "machines/index.html", {"machines_list": machines_list})
|
||||
|
||||
# Canonic view for displaying machines in users's profil
|
||||
def aff_profil(request, user):
|
||||
"""View used to display the machines on a user's profile."""
|
||||
machines = (
|
||||
Machine.objects.filter(user=user)
|
||||
.select_related("user")
|
||||
.prefetch_related("interface_set__domain__extension")
|
||||
.prefetch_related("interface_set__ipv4__ip_type__extension")
|
||||
.prefetch_related("interface_set__machine_type")
|
||||
.prefetch_related("interface_set__domain__related_domain__extension")
|
||||
)
|
||||
machines = SortTable.sort(
|
||||
machines,
|
||||
request.GET.get("col"),
|
||||
request.GET.get("order"),
|
||||
SortTable.MACHINES_INDEX,
|
||||
)
|
||||
nb_machines = machines.count()
|
||||
pagination_large_number = GeneralOption.get_cached_value("pagination_large_number")
|
||||
machines = re2o_paginator(request, machines, pagination_large_number)
|
||||
|
||||
context = {
|
||||
"users":user,
|
||||
"machines_list": machines,
|
||||
"nb_machines":nb_machines,
|
||||
}
|
||||
|
||||
return render_to_string(
|
||||
"machines/aff_profil.html",context=context,request=request,using=None
|
||||
)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@login_required
|
||||
@can_view_all(IpType)
|
||||
|
|
|
@ -26,6 +26,7 @@ from __future__ import unicode_literals
|
|||
import datetime
|
||||
|
||||
from django.contrib import messages
|
||||
from django.contrib.messages import get_messages
|
||||
from django.http import HttpRequest
|
||||
from preferences.models import GeneralOption, OptionalMachine
|
||||
from django.utils.translation import get_language
|
||||
|
@ -47,9 +48,11 @@ def context_user(request):
|
|||
global_message = GeneralOption.get_cached_value("general_message_en")
|
||||
if global_message:
|
||||
if isinstance(request, HttpRequest):
|
||||
messages.warning(request, global_message)
|
||||
if global_message not in [msg.message for msg in get_messages(request)]:
|
||||
messages.warning(request, global_message)
|
||||
else:
|
||||
messages.warning(request._request, global_message)
|
||||
if global_message not in [msg.message for msg in get_messages(request._request)]:
|
||||
messages.warning(request._request, global_message)
|
||||
if user.is_authenticated():
|
||||
interfaces = user.user_interfaces()
|
||||
else:
|
||||
|
|
|
@ -193,7 +193,7 @@ def aff_tickets(request):
|
|||
|
||||
|
||||
# Canonic views for optional apps
|
||||
def profil(request, user):
|
||||
def aff_profil(request, user):
|
||||
"""View used to display the tickets on a user's profile."""
|
||||
tickets_list = Ticket.objects.filter(user=user).all().order_by("-date")
|
||||
nbr_tickets = tickets_list.count()
|
||||
|
@ -214,7 +214,7 @@ def profil(request, user):
|
|||
"nbr_tickets_unsolved": nbr_tickets_unsolved,
|
||||
}
|
||||
return render_to_string(
|
||||
"tickets/profil.html", context=context, request=request, using=None
|
||||
"tickets/aff_profil.html", context=context, request=request, using=None
|
||||
)
|
||||
|
||||
|
||||
|
|
|
@ -407,63 +407,12 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading clearfix profil" data-parent="#accordion" data-toggle="collapse"
|
||||
data-target="#machines">
|
||||
<h3 class="panel-title pull-left">
|
||||
<i class="fa fa-desktop"></i>
|
||||
{% trans "Machines" %}
|
||||
<span class="badge">{{ nb_machines }}</span>
|
||||
</h3>
|
||||
</div>
|
||||
<div id="machines" class="panel-collapse collapse">
|
||||
<div class="panel-body">
|
||||
<a class="btn btn-primary btn-sm" role="button" href="{% url 'machines:new-machine' users.id %}">
|
||||
<i class="fa fa-desktop"></i>
|
||||
{% trans "Add a machine" %}
|
||||
</a>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
{% if machines_list %}
|
||||
{% include 'machines/aff_machines.html' with machines_list=machines_list %}
|
||||
{% else %}
|
||||
<p>{% trans "No machine" %}</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading clearfix profil" data-parent="#accordion" data-toggle="collapse"
|
||||
data-target="#subscriptions">
|
||||
<h3 class="panel-title pull-left">
|
||||
<i class="fa fa-eur"></i>
|
||||
{% trans "Subscriptions" %}
|
||||
</h3>
|
||||
</div>
|
||||
<div id="subscriptions" class="panel-collapse collapse">
|
||||
<div class="panel-body">
|
||||
{% can_create Facture %}
|
||||
<a class="btn btn-primary btn-sm" role="button" href="{% url 'cotisations:new-facture' users.id %}">
|
||||
<i class="fa fa-eur"></i>
|
||||
{% trans "Add a subscription" %}
|
||||
</a>
|
||||
{% if user_solde %}
|
||||
<a class="btn btn-primary btn-sm" role="button" href="{% url 'cotisations:credit-solde' users.id %}">
|
||||
<i class="fa fa-eur"></i>
|
||||
{% trans "Edit the balance" %}
|
||||
</a>
|
||||
{% endif%}
|
||||
{% acl_end %}
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
{% if facture_list %}
|
||||
{% include 'cotisations/aff_cotisations.html' with facture_list=facture_list %}
|
||||
{% else %}
|
||||
<p>{% trans "No invoice" %}</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
{% for template in apps_templates_list %}
|
||||
{{ template }}
|
||||
{% endfor %}
|
||||
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading clearfix profil" data-parent="#accordion" data-toggle="collapse" data-target="#bans">
|
||||
<h3 class="panel-title pull-left">
|
||||
|
@ -569,9 +518,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||
</div>
|
||||
</div>
|
||||
|
||||
{% for template in optionnal_templates_list %}
|
||||
{{ template }}
|
||||
{% endfor %}
|
||||
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
|
|
@ -77,7 +77,7 @@ from machines.models import Machine
|
|||
from preferences.models import OptionalUser, GeneralOption, AssoOption
|
||||
from importlib import import_module
|
||||
from django.conf import settings
|
||||
from re2o.settings_local import OPTIONNAL_APPS_RE2O
|
||||
from re2o.settings import LOCAL_APPS, OPTIONNAL_APPS_RE2O
|
||||
from re2o.views import form
|
||||
from re2o.utils import all_has_access, permission_tree
|
||||
from re2o.base import re2o_paginator, SortTable
|
||||
|
@ -1314,8 +1314,8 @@ def index_serviceusers(request):
|
|||
def mon_profil(request):
|
||||
"""Shortcuts view to profil view, with correct arguments.
|
||||
Returns the view profil with users argument, users is set to
|
||||
default request.user.
|
||||
|
||||
default request.user.
|
||||
|
||||
Parameters:
|
||||
request (django request): Standard django request.
|
||||
|
||||
|
@ -1346,40 +1346,18 @@ def profil(request, users, **_kwargs):
|
|||
|
||||
Returns:
|
||||
Django User Profil Form.
|
||||
|
||||
"""
|
||||
machines = (
|
||||
Machine.objects.filter(user=users)
|
||||
.select_related("user")
|
||||
.prefetch_related("interface_set__domain__extension")
|
||||
.prefetch_related("interface_set__ipv4__ip_type__extension")
|
||||
.prefetch_related("interface_set__machine_type")
|
||||
.prefetch_related("interface_set__domain__related_domain__extension")
|
||||
)
|
||||
machines = SortTable.sort(
|
||||
machines,
|
||||
request.GET.get("col"),
|
||||
request.GET.get("order"),
|
||||
SortTable.MACHINES_INDEX,
|
||||
)
|
||||
|
||||
optionnal_apps = [import_module(app) for app in OPTIONNAL_APPS_RE2O]
|
||||
optionnal_templates_list = [
|
||||
app.views.profil(request, users)
|
||||
for app in optionnal_apps
|
||||
if hasattr(app.views, "profil")
|
||||
# Generate the template list for all apps of re2o if relevant
|
||||
apps = [import_module(app) for app in LOCAL_APPS + OPTIONNAL_APPS_RE2O]
|
||||
apps_templates_list = [
|
||||
app.views.aff_profil(request, users)
|
||||
for app in apps
|
||||
if hasattr(app.views, "aff_profil")
|
||||
]
|
||||
|
||||
pagination_large_number = GeneralOption.get_cached_value("pagination_large_number")
|
||||
nb_machines = machines.count()
|
||||
machines = re2o_paginator(request, machines, pagination_large_number)
|
||||
factures = Facture.objects.filter(user=users)
|
||||
factures = SortTable.sort(
|
||||
factures,
|
||||
request.GET.get("col"),
|
||||
request.GET.get("order"),
|
||||
SortTable.COTISATIONS_INDEX,
|
||||
)
|
||||
nb_machines = users.user_interfaces().count()
|
||||
|
||||
bans = Ban.objects.filter(user=users)
|
||||
bans = SortTable.sort(
|
||||
bans,
|
||||
|
@ -1405,10 +1383,8 @@ def profil(request, users, **_kwargs):
|
|||
"users/profil.html",
|
||||
{
|
||||
"users": users,
|
||||
"machines_list": machines,
|
||||
"nb_machines": nb_machines,
|
||||
"optionnal_templates_list": optionnal_templates_list,
|
||||
"facture_list": factures,
|
||||
"nb_machines":nb_machines,
|
||||
"apps_templates_list": apps_templates_list,
|
||||
"ban_list": bans,
|
||||
"white_list": whitelists,
|
||||
"user_solde": user_solde,
|
||||
|
|
Loading…
Reference in a new issue