8
0
Fork 0
mirror of https://gitlab.federez.net/re2o/re2o synced 2024-06-02 07:52:23 +00:00

Merge branch 'master' into 'Dname'

# Conflicts:
#   re2o/templatetags/acl.py
This commit is contained in:
chirac 2018-07-29 13:57:53 +02:00
commit 95dc427dc4
9 changed files with 128 additions and 121 deletions

View file

@ -30,26 +30,12 @@ with this program; if not, write to the Free Software Foundation, Inc.,
<table class="table table-striped">
<thead>
<tr>
<td>{{ article.name }}</td>
<td>{{ article.prix }}</td>
<td>{{ article.type_cotisation }}</td>
<td>{{ article.duration }}</td>
<td>{{ article.type_user }}</td>
<td>{{ article.available_for_everyone }}</td>
<td class="text-right">
{% can_edit article %}
<a class="btn btn-primary btn-sm" role="button" title="{% trans "Edit" %}" href="{% url 'cotisations:edit-article' article.id %}">
<i class="fa fa-edit"></i>
</a>
{% acl_end %}
{% history_button article %}
</td>
<th>{% trans "Article" %}</th>
<th>{% trans "Price" %}</th>
<th>{% trans "Cotisation type" %}</th>
<th>{% trans "Duration (month)" %}</th>
<th>{% trans "Concerned users" %}</th>
<th>{% trans "Available for everyone" %}</th>
<th>{% trans "Available for everyone" | tick %}</th>
<th></th>
</tr>
</thead>
@ -60,16 +46,14 @@ with this program; if not, write to the Free Software Foundation, Inc.,
<td>{{ article.type_cotisation }}</td>
<td>{{ article.duration }}</td>
<td>{{ article.type_user }}</td>
<td>{{ article.available_for_everyone|tick }}</td>
<td>{{ article.available_for_everyone }}</td>
<td class="text-right">
{% can_edit article %}
<a class="btn btn-primary btn-sm" role="button" title="{% trans "Edit" %}" href="{% url 'cotisations:edit-article' article.id %}">
<i class="fa fa-edit"></i>
</a>
{% acl_end %}
<a class="btn btn-info btn-sm" role="button" title="{% trans "Historique" %}" href="{% url 'cotisations:history' 'article' article.id %}">
<i class="fa fa-history"></i>
</a>
{% history_button article %}
</td>
</tr>
{% endfor %}

View file

@ -30,19 +30,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
<table class="table table-striped">
<thead>
<tr>
<td>{{ paiement.moyen }}</td>
<td>{{ paiement.available_for_everyone }}</td>
<td>
{{paiement.get_payment_method_name}}
</td>
<td class="text-right">
{% can_edit paiement %}
<a class="btn btn-primary btn-sm" role="button" title="{% trans "Edit" %}" href="{% url 'cotisations:edit-paiement' paiement.id %}">
<i class="fa fa-edit"></i>
</a>
{% acl_end %}
{% history_button paiement %}
</td>
<th>{% trans "Payment type" %}</th>
<th>{% trans "Is available for everyone" %}</th>
<th>{% trans "Custom payment method" %}</th>
@ -62,9 +49,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
<i class="fa fa-edit"></i>
</a>
{% acl_end %}
<a class="btn btn-info btn-sm" role="button" title="{% trans "Historique" %}" href="{% url 'cotisations:history' 'paiement' paiement.id %}">
<i class="fa fa-history"></i>
</a>
{% history_button paiement %}
</td>
</tr>
{% endfor %}

View file

@ -54,7 +54,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
{% include 'buttons/edit.html' with href='machines:edit-extension' id=extension.id %}
{% acl_end %}
{% history_button extension %}
{% include 'buttons/history.html' with href='machines:history' name='extension' id=extension.id %}
</td>
</tr>
{% endfor %}

View file

@ -55,7 +55,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
{% include 'buttons/edit.html' with href='machines:edit-iptype' id=type.id %}
{% acl_end %}
{% history_button type %}
{% include 'buttons/history.html' with href='machines:history' name='iptype' id=type.id %}
</td>
</tr>
{% endfor %}

View file

@ -49,7 +49,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
{% include 'buttons/edit.html' with href='machines:edit-nas' id=nas.id %}
{% acl_end %}
{% history_button nas %}
{% include 'buttons/history.html' with href='machines:history' name='nas' id=nas.id %}
</td>
</tr>
{% endfor %}

View file

@ -47,7 +47,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
{% include 'buttons/edit.html' with href='machines:edit-service' id=service.id %}
{% acl_end %}
{% history_button service %}
{% include 'buttons/history.html' with href='machines:history' name='service' id=service.id %}
</td>
</tr>
{% endfor %}

View file

@ -74,83 +74,42 @@ import sys
from django import template
from django.template.base import Node, NodeList
from django.contrib.contenttypes.models import ContentType
import cotisations
import machines
import preferences
import topologie
import users
register = template.Library()
MODEL_NAME = {
# cotisations
'Facture': cotisations.models.Facture,
'Vente': cotisations.models.Vente,
'Article': cotisations.models.Article,
'Banque': cotisations.models.Banque,
'Paiement': cotisations.models.Paiement,
'Cotisation': cotisations.models.Cotisation,
# machines
'Machine': machines.models.Machine,
'MachineType': machines.models.MachineType,
'IpType': machines.models.IpType,
'Vlan': machines.models.Vlan,
'Nas': machines.models.Nas,
'SOA': machines.models.SOA,
'Extension': machines.models.Extension,
'Mx': machines.models.Mx,
'Ns': machines.models.Ns,
'Txt': machines.models.Txt,
'DName': machines.models.DName,
'Srv': machines.models.Srv,
'Interface': machines.models.Interface,
'Domain': machines.models.Domain,
'IpList': machines.models.IpList,
'Ipv6List': machines.models.Ipv6List,
'machines.Service': machines.models.Service,
'Service_link': machines.models.Service_link,
'OuverturePortList': machines.models.OuverturePortList,
'OuverturePort': machines.models.OuverturePort,
# preferences
'OptionalUser': preferences.models.OptionalUser,
'OptionalMachine': preferences.models.OptionalMachine,
'OptionalTopologie': preferences.models.OptionalTopologie,
'GeneralOption': preferences.models.GeneralOption,
'preferences.Service': preferences.models.Service,
'AssoOption': preferences.models.AssoOption,
'MailMessageOption': preferences.models.MailMessageOption,
# topologie
'Stack': topologie.models.Stack,
'Switch': topologie.models.Switch,
'AccessPoint': topologie.models.AccessPoint,
'ModelSwitch': topologie.models.ModelSwitch,
'ConstructorSwitch': topologie.models.ConstructorSwitch,
'Port': topologie.models.Port,
'Room': topologie.models.Room,
'Building': topologie.models.Building,
'SwitchBay': topologie.models.SwitchBay,
# users
'User': users.models.User,
'Adherent': users.models.Adherent,
'Club': users.models.Club,
'ServiceUser': users.models.ServiceUser,
'School': users.models.School,
'ListRight': users.models.ListRight,
'ListShell': users.models.ListShell,
'Ban': users.models.Ban,
'Whitelist': users.models.Whitelist,
}
def get_model(model_name):
"""Retrieve the model object from its name"""
splitted = model_name.split('.')
if len(splitted) > 1:
try:
app_label, name = splitted
except ValueError:
raise template.TemplateSyntaxError(
"%r is an inconsistent model name" % model_name
)
else:
app_label, name = None, splitted[0]
try:
return MODEL_NAME[model_name]
except KeyError:
if app_label is not None:
content_type = ContentType.objects.get(
model=name.lower(),
app_label=app_label
)
else:
content_type = ContentType.objects.get(model=name.lower())
except ContentType.DoesNotExist:
raise template.TemplateSyntaxError(
"%r is not a valid model for an acl tag" % model_name
)
except ContentType.MultipleObjectsReturned:
raise template.TemplateSyntaxError(
"More than one model found for %r. Try with `app.model`."
% model_name
)
return content_type.model_class()
def get_callback(tag_name, obj=None):

View file

@ -28,19 +28,101 @@ with this program; if not, write to the Free Software Foundation, Inc.,
{% load logs_extra %}
{% block title %}Profil{% endblock %}
{% block content %}
<h2>{{ users.surname }} {{users.name}}</h2>
<p>Vous êtes {% if users.end_adhesion != None %}<span class="label label-success">
un {{ users.class_name | lower}}</span>{% else %}<span class="label label-danger">
non adhérent</span>{% endif %} et votre connexion est {% if users.has_access %}
<span class="label label-success">active</span>{% else %}<span class="label label-danger">désactivée</span>{% endif %}.</p>
{% if user_solde %}
<p>Votre solde est de <span class="badge">{{ users.solde }}€</span>.
<a class="btn btn-primary btn-sm" role="button" href="{% url 'cotisations:credit-solde' users.pk%}">
<i class="fa fa-euro-sign"></i>
Recharger
</a>
</p>
{% endif %}
<div align="center">
<h2>Bienvenue {{users.name}} {{ users.surname }}</h2>
</div>
<div class="dashboard_container">
<div class="row">
{% if solde_activated %}
<div class="col-sm-6 col-md-4">
{% else %}
<div class="col-sm-6 col-md-6">
{% endif %}
<div class="col-12">
{% if users.is_ban%}
<div class="panel panel-danger">
<div class="panel-heading dashboard">Votre compte est banni</div>
<div class="panel-body dashboard">
<i class="text-danger">Fin du ban : {{user.end_ban|date:"d M Y"}}</i>
</div>
</div>
{% elif not users.is_adherent%}
<div class="panel panel-danger">
<div class="panel-heading dashboard">Non Connécté</div>
<div class="panel-body dashboard">
<a class="btn btn-danger btn-sm" role="button" href="{% url 'cotisations:credit-solde' users.id %}">
<i class="fas fa-sign-in-alt"></i>
Adhérer
</a>
</div>
{% else %}
<div class="panel panel-success">
<div class="panel-heading dashboard">Connécté</div>
<div class="panel-body dashboard">
<i class="text-success">Fin de connexion: {{user.end_adhesion|date:"d M Y"}}</i>
</div>
</div>
{% endif %}
</div>
</div>
{% if solde_activated %}
<div class="col-sm-6 col-md-4">
<div class="col-12">
<div class="col-12">
<div class="panel panel-info">
<div class="panel-heading dashboard" data-parent="#accordion" data-toggle="collapse" data-target="#collapse4">
{{user.solde}} <i class="fas fa-euro-sign"></i>
</div>
<div class="panel-body dashboard">
<a class="btn btn-primary btn-sm" role="button" href="{% url 'cotisations:credit-solde' users.id %}">
<i class="fa fa-euro-sign"></i>
Modifier le solde
</a>
</div>
</div>
</div>
</div>
</div>
{% endif %}
{% if solde_activated %}
<div class="col-sm-6 col-md-4">
{% else %}
<div class="col-sm-6 col-md-6">
{% endif %}
<div class="col-12">
{% if nb_machines %}
<div class="panel panel-info">
<div class="panel-heading dashboard" data-parent="#accordion" data-toggle="collapse" data-target="#collapse3">
<span class="badge">{{nb_machines}}</span>
Machines
<i class="fa fa-desktop"></i>
</div>
<div class="panel-body dashboard">
<a class="btn btn-primary btn-sm" role="button" href="{% url 'machines:new-machine' users.id %}">
<i class="fa fa-desktop"></i>
Ajouter une machine
</a>
</div>
</div>
{% else %}
<div class="panel panel-warning">
<div class="panel-heading dashboard">Aucune machine</div>
<div class="panel-body dashboard">
<a class="btn btn-warning btn-sm" role="button" href="{% url 'machines:new-machine' users.id %}">
<i class="fa fa-desktop"></i>
Ajouter une machine
</a>
</div>
</div>
{% endif %}
</div>
</div>
</div>
</div>
<div class="panel-group" id="accordion">
<div class="panel panel-default">

View file

@ -51,7 +51,7 @@ from reversion import revisions as reversion
from cotisations.models import Facture, Paiement
from machines.models import Machine
from preferences.models import GeneralOption
from preferences.models import OptionalUser, GeneralOption, AssoOption
from re2o.views import form
from re2o.utils import (
all_has_access,
@ -112,8 +112,7 @@ def new_user(request):
GTU_sum_up = GeneralOption.get_cached_value('GTU_sum_up')
GTU = GeneralOption.get_cached_value('GTU')
if user.is_valid():
user = user.save(commit=False)
user.save()
user = user.save()
user.reset_passwd_mail(request)
messages.success(request, "L'utilisateur %s a été crée, un mail\
pour l'initialisation du mot de passe a été envoyé" % user.pseudo)
@ -914,6 +913,8 @@ def profil(request, users, **_kwargs):
'ban_list': bans,
'white_list': whitelists,
'user_solde': user_solde,
'solde_activated': Paiement.objects.filter(is_balance=True).exists(),
'asso_name': AssoOption.objects.first().name
}
)