mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-23 20:03:11 +00:00
Save que si l'objet a été modifié
This commit is contained in:
parent
a553789bad
commit
543037b667
4 changed files with 100 additions and 84 deletions
|
@ -249,7 +249,9 @@ def edit_facture(request, facture, factureid):
|
||||||
)
|
)
|
||||||
vente_form = vente_form_set(request.POST or None, queryset=ventes_objects)
|
vente_form = vente_form_set(request.POST or None, queryset=ventes_objects)
|
||||||
if facture_form.is_valid() and vente_form.is_valid():
|
if facture_form.is_valid() and vente_form.is_valid():
|
||||||
|
if facture_form.changed_data:
|
||||||
facture_form.save()
|
facture_form.save()
|
||||||
|
if vente_form.changed_data:
|
||||||
vente_form.save()
|
vente_form.save()
|
||||||
messages.success(request, "La facture a bien été modifiée")
|
messages.success(request, "La facture a bien été modifiée")
|
||||||
return redirect(reverse('cotisations:index'))
|
return redirect(reverse('cotisations:index'))
|
||||||
|
@ -321,6 +323,7 @@ def edit_article(request, article_instance, articleid):
|
||||||
Réservé au trésorier"""
|
Réservé au trésorier"""
|
||||||
article = ArticleForm(request.POST or None, instance=article_instance)
|
article = ArticleForm(request.POST or None, instance=article_instance)
|
||||||
if article.is_valid():
|
if article.is_valid():
|
||||||
|
if article.changed_data:
|
||||||
article.save()
|
article.save()
|
||||||
messages.success(request, "Type d'article modifié")
|
messages.success(request, "Type d'article modifié")
|
||||||
return redirect(reverse('cotisations:index-article'))
|
return redirect(reverse('cotisations:index-article'))
|
||||||
|
@ -359,6 +362,7 @@ def edit_paiement(request, paiement_instance, paiementid):
|
||||||
"""Edition d'un moyen de paiement"""
|
"""Edition d'un moyen de paiement"""
|
||||||
paiement = PaiementForm(request.POST or None, instance=paiement_instance)
|
paiement = PaiementForm(request.POST or None, instance=paiement_instance)
|
||||||
if paiement.is_valid():
|
if paiement.is_valid():
|
||||||
|
if paiement.changed_data:
|
||||||
paiement.save()
|
paiement.save()
|
||||||
messages.success(request, "Type de paiement modifié")
|
messages.success(request, "Type de paiement modifié")
|
||||||
return redirect(reverse('cotisations:index-paiement'))
|
return redirect(reverse('cotisations:index-paiement'))
|
||||||
|
@ -407,6 +411,7 @@ def edit_banque(request, banque_instance, banqueid):
|
||||||
"""Edite le nom d'une banque"""
|
"""Edite le nom d'une banque"""
|
||||||
banque = BanqueForm(request.POST or None, instance=banque_instance)
|
banque = BanqueForm(request.POST or None, instance=banque_instance)
|
||||||
if banque.is_valid():
|
if banque.is_valid():
|
||||||
|
if banque.changed_data:
|
||||||
banque.save()
|
banque.save()
|
||||||
messages.success(request, "Banque modifiée")
|
messages.success(request, "Banque modifiée")
|
||||||
return redirect(reverse('cotisations:index-banque'))
|
return redirect(reverse('cotisations:index-banque'))
|
||||||
|
|
|
@ -277,8 +277,11 @@ def edit_interface(request, interface_instance, interfaceid):
|
||||||
new_machine = machine_form.save(commit=False)
|
new_machine = machine_form.save(commit=False)
|
||||||
new_interface = interface_form.save(commit=False)
|
new_interface = interface_form.save(commit=False)
|
||||||
new_domain = domain_form.save(commit=False)
|
new_domain = domain_form.save(commit=False)
|
||||||
|
if machine_form.changed_data:
|
||||||
new_machine.save()
|
new_machine.save()
|
||||||
|
if interface_form.changed_data:
|
||||||
new_interface.save()
|
new_interface.save()
|
||||||
|
if domain_form.changed_data:
|
||||||
new_domain.save()
|
new_domain.save()
|
||||||
messages.success(request, "La machine a été modifiée")
|
messages.success(request, "La machine a été modifiée")
|
||||||
return redirect(reverse(
|
return redirect(reverse(
|
||||||
|
@ -375,6 +378,7 @@ def edit_ipv6list(request, ipv6list_instance, ipv6listid):
|
||||||
"""Edition d'une ipv6"""
|
"""Edition d'une ipv6"""
|
||||||
ipv6 = Ipv6ListForm(request.POST or None, instance=ipv6list_instance, user=request.user)
|
ipv6 = Ipv6ListForm(request.POST or None, instance=ipv6list_instance, user=request.user)
|
||||||
if ipv6.is_valid():
|
if ipv6.is_valid():
|
||||||
|
if ipv6.changed_data:
|
||||||
ipv6.save()
|
ipv6.save()
|
||||||
messages.success(request, "Ipv6 modifiée")
|
messages.success(request, "Ipv6 modifiée")
|
||||||
return redirect(reverse(
|
return redirect(reverse(
|
||||||
|
@ -416,6 +420,7 @@ def edit_iptype(request, iptype_instance, iptypeid):
|
||||||
|
|
||||||
iptype = EditIpTypeForm(request.POST or None, instance=iptype_instance)
|
iptype = EditIpTypeForm(request.POST or None, instance=iptype_instance)
|
||||||
if iptype.is_valid():
|
if iptype.is_valid():
|
||||||
|
if iptype.changed_data:
|
||||||
iptype.save()
|
iptype.save()
|
||||||
messages.success(request, "Type d'ip modifié")
|
messages.success(request, "Type d'ip modifié")
|
||||||
return redirect(reverse('machines:index-iptype'))
|
return redirect(reverse('machines:index-iptype'))
|
||||||
|
@ -451,9 +456,9 @@ def add_machinetype(request):
|
||||||
@login_required
|
@login_required
|
||||||
@can_edit(MachineType)
|
@can_edit(MachineType)
|
||||||
def edit_machinetype(request, machinetype_instance, machinetypeid):
|
def edit_machinetype(request, machinetype_instance, machinetypeid):
|
||||||
|
|
||||||
machinetype = MachineTypeForm(request.POST or None, instance=machinetype_instance)
|
machinetype = MachineTypeForm(request.POST or None, instance=machinetype_instance)
|
||||||
if machinetype.is_valid():
|
if machinetype.is_valid():
|
||||||
|
if machinetype.changed_data:
|
||||||
machinetype.save()
|
machinetype.save()
|
||||||
messages.success(request, "Type de machine modifié")
|
messages.success(request, "Type de machine modifié")
|
||||||
return redirect(reverse('machines:index-machinetype'))
|
return redirect(reverse('machines:index-machinetype'))
|
||||||
|
@ -477,7 +482,6 @@ def del_machinetype(request, instances):
|
||||||
@login_required
|
@login_required
|
||||||
@can_create(Extension)
|
@can_create(Extension)
|
||||||
def add_extension(request):
|
def add_extension(request):
|
||||||
|
|
||||||
extension = ExtensionForm(request.POST or None)
|
extension = ExtensionForm(request.POST or None)
|
||||||
if extension.is_valid():
|
if extension.is_valid():
|
||||||
extension.save()
|
extension.save()
|
||||||
|
@ -488,9 +492,9 @@ def add_extension(request):
|
||||||
@login_required
|
@login_required
|
||||||
@can_edit(Extension)
|
@can_edit(Extension)
|
||||||
def edit_extension(request, extension_instance, extensionid):
|
def edit_extension(request, extension_instance, extensionid):
|
||||||
|
|
||||||
extension = ExtensionForm(request.POST or None, instance=extension_instance)
|
extension = ExtensionForm(request.POST or None, instance=extension_instance)
|
||||||
if extension.is_valid():
|
if extension.is_valid():
|
||||||
|
if extension.changed_data:
|
||||||
extension.save()
|
extension.save()
|
||||||
messages.success(request, "Extension modifiée")
|
messages.success(request, "Extension modifiée")
|
||||||
return redirect(reverse('machines:index-extension'))
|
return redirect(reverse('machines:index-extension'))
|
||||||
|
@ -514,7 +518,6 @@ def del_extension(request, instances):
|
||||||
@login_required
|
@login_required
|
||||||
@can_create(SOA)
|
@can_create(SOA)
|
||||||
def add_soa(request):
|
def add_soa(request):
|
||||||
|
|
||||||
soa = SOAForm(request.POST or None)
|
soa = SOAForm(request.POST or None)
|
||||||
if soa.is_valid():
|
if soa.is_valid():
|
||||||
soa.save()
|
soa.save()
|
||||||
|
@ -525,9 +528,9 @@ def add_soa(request):
|
||||||
@login_required
|
@login_required
|
||||||
@can_edit(SOA)
|
@can_edit(SOA)
|
||||||
def edit_soa(request, soa_instance, soaid):
|
def edit_soa(request, soa_instance, soaid):
|
||||||
|
|
||||||
soa = SOAForm(request.POST or None, instance=soa_instance)
|
soa = SOAForm(request.POST or None, instance=soa_instance)
|
||||||
if soa.is_valid():
|
if soa.is_valid():
|
||||||
|
if soa.changed_data:
|
||||||
soa.save()
|
soa.save()
|
||||||
messages.success(request, "SOA modifié")
|
messages.success(request, "SOA modifié")
|
||||||
return redirect(reverse('machines:index-extension'))
|
return redirect(reverse('machines:index-extension'))
|
||||||
|
@ -551,7 +554,6 @@ def del_soa(request, instances):
|
||||||
@login_required
|
@login_required
|
||||||
@can_create(Mx)
|
@can_create(Mx)
|
||||||
def add_mx(request):
|
def add_mx(request):
|
||||||
|
|
||||||
mx = MxForm(request.POST or None)
|
mx = MxForm(request.POST or None)
|
||||||
if mx.is_valid():
|
if mx.is_valid():
|
||||||
mx.save()
|
mx.save()
|
||||||
|
@ -562,9 +564,9 @@ def add_mx(request):
|
||||||
@login_required
|
@login_required
|
||||||
@can_edit(Mx)
|
@can_edit(Mx)
|
||||||
def edit_mx(request, mx_instance, mxid):
|
def edit_mx(request, mx_instance, mxid):
|
||||||
|
|
||||||
mx = MxForm(request.POST or None, instance=mx_instance)
|
mx = MxForm(request.POST or None, instance=mx_instance)
|
||||||
if mx.is_valid():
|
if mx.is_valid():
|
||||||
|
if mx.changed_data:
|
||||||
mx.save()
|
mx.save()
|
||||||
messages.success(request, "Mx modifié")
|
messages.success(request, "Mx modifié")
|
||||||
return redirect(reverse('machines:index-extension'))
|
return redirect(reverse('machines:index-extension'))
|
||||||
|
@ -588,7 +590,6 @@ def del_mx(request, instances):
|
||||||
@login_required
|
@login_required
|
||||||
@can_create(Ns)
|
@can_create(Ns)
|
||||||
def add_ns(request):
|
def add_ns(request):
|
||||||
|
|
||||||
ns = NsForm(request.POST or None)
|
ns = NsForm(request.POST or None)
|
||||||
if ns.is_valid():
|
if ns.is_valid():
|
||||||
ns.save()
|
ns.save()
|
||||||
|
@ -599,9 +600,9 @@ def add_ns(request):
|
||||||
@login_required
|
@login_required
|
||||||
@can_edit(Ns)
|
@can_edit(Ns)
|
||||||
def edit_ns(request, ns_instance, nsid):
|
def edit_ns(request, ns_instance, nsid):
|
||||||
|
|
||||||
ns = NsForm(request.POST or None, instance=ns_instance)
|
ns = NsForm(request.POST or None, instance=ns_instance)
|
||||||
if ns.is_valid():
|
if ns.is_valid():
|
||||||
|
if ns.changed_data:
|
||||||
ns.save()
|
ns.save()
|
||||||
messages.success(request, "Ns modifié")
|
messages.success(request, "Ns modifié")
|
||||||
return redirect(reverse('machines:index-extension'))
|
return redirect(reverse('machines:index-extension'))
|
||||||
|
@ -625,7 +626,6 @@ def del_ns(request, instances):
|
||||||
@login_required
|
@login_required
|
||||||
@can_create(Txt)
|
@can_create(Txt)
|
||||||
def add_txt(request):
|
def add_txt(request):
|
||||||
|
|
||||||
txt = TxtForm(request.POST or None)
|
txt = TxtForm(request.POST or None)
|
||||||
if txt.is_valid():
|
if txt.is_valid():
|
||||||
txt.save()
|
txt.save()
|
||||||
|
@ -636,9 +636,9 @@ def add_txt(request):
|
||||||
@login_required
|
@login_required
|
||||||
@can_edit(Txt)
|
@can_edit(Txt)
|
||||||
def edit_txt(request, txt_instance, txtid):
|
def edit_txt(request, txt_instance, txtid):
|
||||||
|
|
||||||
txt = TxtForm(request.POST or None, instance=txt_instance)
|
txt = TxtForm(request.POST or None, instance=txt_instance)
|
||||||
if txt.is_valid():
|
if txt.is_valid():
|
||||||
|
if txt.changed_data:
|
||||||
txt.save()
|
txt.save()
|
||||||
messages.success(request, "Txt modifié")
|
messages.success(request, "Txt modifié")
|
||||||
return redirect(reverse('machines:index-extension'))
|
return redirect(reverse('machines:index-extension'))
|
||||||
|
@ -662,7 +662,6 @@ def del_txt(request, instances):
|
||||||
@login_required
|
@login_required
|
||||||
@can_create(Srv)
|
@can_create(Srv)
|
||||||
def add_srv(request):
|
def add_srv(request):
|
||||||
|
|
||||||
srv = SrvForm(request.POST or None)
|
srv = SrvForm(request.POST or None)
|
||||||
if srv.is_valid():
|
if srv.is_valid():
|
||||||
srv.save()
|
srv.save()
|
||||||
|
@ -673,9 +672,9 @@ def add_srv(request):
|
||||||
@login_required
|
@login_required
|
||||||
@can_edit(Srv)
|
@can_edit(Srv)
|
||||||
def edit_srv(request, srv_instance, srvid):
|
def edit_srv(request, srv_instance, srvid):
|
||||||
|
|
||||||
srv = SrvForm(request.POST or None, instance=srv_instance)
|
srv = SrvForm(request.POST or None, instance=srv_instance)
|
||||||
if srv.is_valid():
|
if srv.is_valid():
|
||||||
|
if srv.changed_data:
|
||||||
srv.save()
|
srv.save()
|
||||||
messages.success(request, "Srv modifié")
|
messages.success(request, "Srv modifié")
|
||||||
return redirect(reverse('machines:index-extension'))
|
return redirect(reverse('machines:index-extension'))
|
||||||
|
@ -700,7 +699,6 @@ def del_srv(request, instances):
|
||||||
@can_create(Domain)
|
@can_create(Domain)
|
||||||
@can_edit(Interface)
|
@can_edit(Interface)
|
||||||
def add_alias(request, interface, interfaceid):
|
def add_alias(request, interface, interfaceid):
|
||||||
|
|
||||||
alias = AliasForm(request.POST or None, user=request.user)
|
alias = AliasForm(request.POST or None, user=request.user)
|
||||||
if alias.is_valid():
|
if alias.is_valid():
|
||||||
alias = alias.save(commit=False)
|
alias = alias.save(commit=False)
|
||||||
|
@ -716,9 +714,9 @@ def add_alias(request, interface, interfaceid):
|
||||||
@login_required
|
@login_required
|
||||||
@can_edit(Domain)
|
@can_edit(Domain)
|
||||||
def edit_alias(request, domain_instance, domainid):
|
def edit_alias(request, domain_instance, domainid):
|
||||||
|
|
||||||
alias = AliasForm(request.POST or None, instance=domain_instance, user=request.user)
|
alias = AliasForm(request.POST or None, instance=domain_instance, user=request.user)
|
||||||
if alias.is_valid():
|
if alias.is_valid():
|
||||||
|
if alias.changed_data:
|
||||||
domain_instance = alias.save()
|
domain_instance = alias.save()
|
||||||
messages.success(request, "Alias modifié")
|
messages.success(request, "Alias modifié")
|
||||||
return redirect(reverse(
|
return redirect(reverse(
|
||||||
|
@ -749,7 +747,6 @@ def del_alias(request, interface, interfaceid):
|
||||||
@login_required
|
@login_required
|
||||||
@can_create(Service)
|
@can_create(Service)
|
||||||
def add_service(request):
|
def add_service(request):
|
||||||
|
|
||||||
service = ServiceForm(request.POST or None)
|
service = ServiceForm(request.POST or None)
|
||||||
if service.is_valid():
|
if service.is_valid():
|
||||||
service.save()
|
service.save()
|
||||||
|
@ -760,9 +757,9 @@ def add_service(request):
|
||||||
@login_required
|
@login_required
|
||||||
@can_edit(Service)
|
@can_edit(Service)
|
||||||
def edit_service(request, service_instance, serviceid):
|
def edit_service(request, service_instance, serviceid):
|
||||||
|
|
||||||
service = ServiceForm(request.POST or None, instance=service_instance)
|
service = ServiceForm(request.POST or None, instance=service_instance)
|
||||||
if service.is_valid():
|
if service.is_valid():
|
||||||
|
if service.changed_data:
|
||||||
service.save()
|
service.save()
|
||||||
messages.success(request, "Service modifié")
|
messages.success(request, "Service modifié")
|
||||||
return redirect(reverse('machines:index-service'))
|
return redirect(reverse('machines:index-service'))
|
||||||
|
@ -786,7 +783,6 @@ def del_service(request, instances):
|
||||||
@login_required
|
@login_required
|
||||||
@can_create(Vlan)
|
@can_create(Vlan)
|
||||||
def add_vlan(request):
|
def add_vlan(request):
|
||||||
|
|
||||||
vlan = VlanForm(request.POST or None)
|
vlan = VlanForm(request.POST or None)
|
||||||
if vlan.is_valid():
|
if vlan.is_valid():
|
||||||
vlan.save()
|
vlan.save()
|
||||||
|
@ -797,9 +793,9 @@ def add_vlan(request):
|
||||||
@login_required
|
@login_required
|
||||||
@can_edit(Vlan)
|
@can_edit(Vlan)
|
||||||
def edit_vlan(request, vlan_instance, vlanid):
|
def edit_vlan(request, vlan_instance, vlanid):
|
||||||
|
|
||||||
vlan = VlanForm(request.POST or None, instance=vlan_instance)
|
vlan = VlanForm(request.POST or None, instance=vlan_instance)
|
||||||
if vlan.is_valid():
|
if vlan.is_valid():
|
||||||
|
if vlan.changed_data:
|
||||||
vlan.save()
|
vlan.save()
|
||||||
messages.success(request, "Vlan modifié")
|
messages.success(request, "Vlan modifié")
|
||||||
return redirect(reverse('machines:index-vlan'))
|
return redirect(reverse('machines:index-vlan'))
|
||||||
|
@ -823,7 +819,6 @@ def del_vlan(request, instances):
|
||||||
@login_required
|
@login_required
|
||||||
@can_create(Nas)
|
@can_create(Nas)
|
||||||
def add_nas(request):
|
def add_nas(request):
|
||||||
|
|
||||||
nas = NasForm(request.POST or None)
|
nas = NasForm(request.POST or None)
|
||||||
if nas.is_valid():
|
if nas.is_valid():
|
||||||
nas.save()
|
nas.save()
|
||||||
|
@ -834,9 +829,9 @@ def add_nas(request):
|
||||||
@login_required
|
@login_required
|
||||||
@can_edit(Nas)
|
@can_edit(Nas)
|
||||||
def edit_nas(request, nas_instance, nasid):
|
def edit_nas(request, nas_instance, nasid):
|
||||||
|
|
||||||
nas = NasForm(request.POST or None, instance=nas_instance)
|
nas = NasForm(request.POST or None, instance=nas_instance)
|
||||||
if nas.is_valid():
|
if nas.is_valid():
|
||||||
|
if nas.changed_data:
|
||||||
nas.save()
|
nas.save()
|
||||||
messages.success(request, "Nas modifié")
|
messages.success(request, "Nas modifié")
|
||||||
return redirect(reverse('machines:index-nas'))
|
return redirect(reverse('machines:index-nas'))
|
||||||
|
@ -951,7 +946,6 @@ def index_portlist(request):
|
||||||
@login_required
|
@login_required
|
||||||
@can_edit(OuverturePortList)
|
@can_edit(OuverturePortList)
|
||||||
def edit_portlist(request, ouvertureportlist_instance, ouvertureportlistid):
|
def edit_portlist(request, ouvertureportlist_instance, ouvertureportlistid):
|
||||||
|
|
||||||
port_list = EditOuverturePortListForm(request.POST or None, instance=ouvertureportlist_instance)
|
port_list = EditOuverturePortListForm(request.POST or None, instance=ouvertureportlist_instance)
|
||||||
port_formset = modelformset_factory(
|
port_formset = modelformset_factory(
|
||||||
OuverturePort,
|
OuverturePort,
|
||||||
|
@ -962,7 +956,10 @@ def edit_portlist(request, ouvertureportlist_instance, ouvertureportlistid):
|
||||||
validate_min=True,
|
validate_min=True,
|
||||||
)(request.POST or None, queryset=ouvertureportlist_instance.ouvertureport_set.all())
|
)(request.POST or None, queryset=ouvertureportlist_instance.ouvertureport_set.all())
|
||||||
if port_list.is_valid() and port_formset.is_valid():
|
if port_list.is_valid() and port_formset.is_valid():
|
||||||
|
if port_list.changed_data:
|
||||||
pl = port_list.save()
|
pl = port_list.save()
|
||||||
|
else:
|
||||||
|
pl = ouvertureportlist_instance
|
||||||
instances = port_formset.save(commit=False)
|
instances = port_formset.save(commit=False)
|
||||||
for to_delete in port_formset.deleted_objects:
|
for to_delete in port_formset.deleted_objects:
|
||||||
to_delete.delete()
|
to_delete.delete()
|
||||||
|
@ -983,7 +980,6 @@ def del_portlist(request, port_list_instance, ouvertureportlistid):
|
||||||
@login_required
|
@login_required
|
||||||
@can_create(OuverturePortList)
|
@can_create(OuverturePortList)
|
||||||
def add_portlist(request):
|
def add_portlist(request):
|
||||||
|
|
||||||
port_list = EditOuverturePortListForm(request.POST or None)
|
port_list = EditOuverturePortListForm(request.POST or None)
|
||||||
port_formset = modelformset_factory(
|
port_formset = modelformset_factory(
|
||||||
OuverturePort,
|
OuverturePort,
|
||||||
|
@ -1019,6 +1015,7 @@ def configure_ports(request, interface_instance, interfaceid):
|
||||||
messages.error(request, "Attention, l'ipv4 n'est pas publique, l'ouverture n'aura pas d'effet en v4")
|
messages.error(request, "Attention, l'ipv4 n'est pas publique, l'ouverture n'aura pas d'effet en v4")
|
||||||
interface = EditOuverturePortConfigForm(request.POST or None, instance=interface_instance)
|
interface = EditOuverturePortConfigForm(request.POST or None, instance=interface_instance)
|
||||||
if interface.is_valid():
|
if interface.is_valid():
|
||||||
|
if interface.changed_data:
|
||||||
interface.save()
|
interface.save()
|
||||||
messages.success(request, "Configuration des ports mise à jour.")
|
messages.success(request, "Configuration des ports mise à jour.")
|
||||||
return redirect(reverse('machines:index'))
|
return redirect(reverse('machines:index'))
|
||||||
|
|
|
@ -102,6 +102,9 @@ class AccessPoint(AclMixin, Machine):
|
||||||
("view_accesspoint", "Peut voir une borne"),
|
("view_accesspoint", "Peut voir une borne"),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return str(self.interface_set.first())
|
||||||
|
|
||||||
|
|
||||||
class Switch(AclMixin, Machine):
|
class Switch(AclMixin, Machine):
|
||||||
""" Definition d'un switch. Contient un nombre de ports (number),
|
""" Definition d'un switch. Contient un nombre de ports (number),
|
||||||
|
|
|
@ -152,6 +152,7 @@ def edit_club_admin_members(request, club_instance, clubid):
|
||||||
membres d'un club"""
|
membres d'un club"""
|
||||||
club = ClubAdminandMembersForm(request.POST or None, instance=club_instance)
|
club = ClubAdminandMembersForm(request.POST or None, instance=club_instance)
|
||||||
if club.is_valid():
|
if club.is_valid():
|
||||||
|
if club.changed_data:
|
||||||
club.save()
|
club.save()
|
||||||
messages.success(request, "Le club a bien été modifié")
|
messages.success(request, "Le club a bien été modifié")
|
||||||
return redirect(reverse(
|
return redirect(reverse(
|
||||||
|
@ -180,6 +181,7 @@ def edit_info(request, user, userid):
|
||||||
user=request.user
|
user=request.user
|
||||||
)
|
)
|
||||||
if user.is_valid():
|
if user.is_valid():
|
||||||
|
if user.changed_data:
|
||||||
user.save()
|
user.save()
|
||||||
messages.success(request, "L'user a bien été modifié")
|
messages.success(request, "L'user a bien été modifié")
|
||||||
return redirect(reverse(
|
return redirect(reverse(
|
||||||
|
@ -202,6 +204,7 @@ def state(request, user, userid):
|
||||||
user.unarchive()
|
user.unarchive()
|
||||||
elif state.cleaned_data['state'] == User.STATE_DISABLED:
|
elif state.cleaned_data['state'] == User.STATE_DISABLED:
|
||||||
user.state = User.STATE_DISABLED
|
user.state = User.STATE_DISABLED
|
||||||
|
if user.changed_data:
|
||||||
user.save()
|
user.save()
|
||||||
messages.success(request, "Etat changé avec succès")
|
messages.success(request, "Etat changé avec succès")
|
||||||
return redirect(reverse(
|
return redirect(reverse(
|
||||||
|
@ -216,6 +219,7 @@ def state(request, user, userid):
|
||||||
def groups(request, user, userid):
|
def groups(request, user, userid):
|
||||||
group = GroupForm(request.POST or None, instance=user)
|
group = GroupForm(request.POST or None, instance=user)
|
||||||
if group.is_valid():
|
if group.is_valid():
|
||||||
|
if group.changed_data:
|
||||||
group.save()
|
group.save()
|
||||||
messages.success(request, "Groupes changés avec succès")
|
messages.success(request, "Groupes changés avec succès")
|
||||||
return redirect(reverse(
|
return redirect(reverse(
|
||||||
|
@ -233,6 +237,7 @@ def password(request, user, userid):
|
||||||
pour tous si droit bureau """
|
pour tous si droit bureau """
|
||||||
u_form = PassForm(request.POST or None, instance=user, user=request.user)
|
u_form = PassForm(request.POST or None, instance=user, user=request.user)
|
||||||
if u_form.is_valid():
|
if u_form.is_valid():
|
||||||
|
if u_form.changed_data:
|
||||||
u_form.save()
|
u_form.save()
|
||||||
messages.success(request, "Le mot de passe a changé")
|
messages.success(request, "Le mot de passe a changé")
|
||||||
return redirect(reverse(
|
return redirect(reverse(
|
||||||
|
@ -277,6 +282,7 @@ def edit_serviceuser(request, user, userid):
|
||||||
user_object = user.save(commit=False)
|
user_object = user.save(commit=False)
|
||||||
if user.cleaned_data['password']:
|
if user.cleaned_data['password']:
|
||||||
user_object.set_password(user.cleaned_data['password'])
|
user_object.set_password(user.cleaned_data['password'])
|
||||||
|
if user.changed_data:
|
||||||
user_object.save()
|
user_object.save()
|
||||||
messages.success(request, "L'user a bien été modifié")
|
messages.success(request, "L'user a bien été modifié")
|
||||||
return redirect(reverse('users:index-serviceusers'))
|
return redirect(reverse('users:index-serviceusers'))
|
||||||
|
@ -329,6 +335,7 @@ def edit_ban(request, ban_instance, banid):
|
||||||
Syntaxe : JJ/MM/AAAA , heure optionnelle, prend effet immédiatement"""
|
Syntaxe : JJ/MM/AAAA , heure optionnelle, prend effet immédiatement"""
|
||||||
ban = BanForm(request.POST or None, instance=ban_instance)
|
ban = BanForm(request.POST or None, instance=ban_instance)
|
||||||
if ban.is_valid():
|
if ban.is_valid():
|
||||||
|
if ban.changed_data:
|
||||||
ban.save()
|
ban.save()
|
||||||
messages.success(request, "Bannissement modifié")
|
messages.success(request, "Bannissement modifié")
|
||||||
return redirect(reverse('users:index'))
|
return redirect(reverse('users:index'))
|
||||||
|
@ -375,6 +382,7 @@ def edit_whitelist(request, whitelist_instance, whitelistid):
|
||||||
instance=whitelist_instance
|
instance=whitelist_instance
|
||||||
)
|
)
|
||||||
if whitelist.is_valid():
|
if whitelist.is_valid():
|
||||||
|
if whitelist.changed_data:
|
||||||
whitelist.save()
|
whitelist.save()
|
||||||
messages.success(request, "Whitelist modifiée")
|
messages.success(request, "Whitelist modifiée")
|
||||||
return redirect(reverse('users:index'))
|
return redirect(reverse('users:index'))
|
||||||
|
@ -401,6 +409,7 @@ def edit_school(request, school_instance, schoolid):
|
||||||
la base de donnée, need cableur"""
|
la base de donnée, need cableur"""
|
||||||
school = SchoolForm(request.POST or None, instance=school_instance)
|
school = SchoolForm(request.POST or None, instance=school_instance)
|
||||||
if school.is_valid():
|
if school.is_valid():
|
||||||
|
if school.changed_data:
|
||||||
school.save()
|
school.save()
|
||||||
messages.success(request, "Établissement modifié")
|
messages.success(request, "Établissement modifié")
|
||||||
return redirect(reverse('users:index-school'))
|
return redirect(reverse('users:index-school'))
|
||||||
|
@ -448,6 +457,7 @@ def edit_shell(request, shell_instance, listshellid):
|
||||||
""" Editer un shell à partir du listshellid"""
|
""" Editer un shell à partir du listshellid"""
|
||||||
shell = ShellForm(request.POST or None, instance=shell_instance)
|
shell = ShellForm(request.POST or None, instance=shell_instance)
|
||||||
if shell.is_valid():
|
if shell.is_valid():
|
||||||
|
if shell.changed_data:
|
||||||
shell.save()
|
shell.save()
|
||||||
messages.success(request, "Le shell a été modifié")
|
messages.success(request, "Le shell a été modifié")
|
||||||
return redirect(reverse('users:index-shell'))
|
return redirect(reverse('users:index-shell'))
|
||||||
|
@ -492,6 +502,7 @@ def edit_listright(request, listright_instance, listrightid):
|
||||||
instance=listright_instance
|
instance=listright_instance
|
||||||
)
|
)
|
||||||
if listright.is_valid():
|
if listright.is_valid():
|
||||||
|
if listright.changed_data:
|
||||||
listright.save()
|
listright.save()
|
||||||
messages.success(request, "Droit modifié")
|
messages.success(request, "Droit modifié")
|
||||||
return redirect(reverse('users:index-listright'))
|
return redirect(reverse('users:index-listright'))
|
||||||
|
|
Loading…
Reference in a new issue