Commit dfde9fb0 authored by Charlie Jacomme's avatar Charlie Jacomme

[compte] Vue pour l'ajout d'un adhérent, TBC

parent 85b162ff
......@@ -49,6 +49,9 @@ class CompteForm(BaseCompteForm):
else:
return ""
class NewCompteForm(CompteForm):
mail = forms.CharField(label=u'Email', max_length=40, validators=[validate_email], required=True)
class MailForm(forms.Form):
mailredirect = forms.CharField(label=u'Redirection des mails', max_length=40, required=False)
def __init__(self, ldap_user, *args, **kwargs):
......
{% extends "template.html" %}
{% block title %} Création d'adhérent {% endblock %}
{% block h1 %} Création d'un adhérent{% endblock %}
{% block content %}
<form class="form-full-width" method="post">{% csrf_token %}
<div class="error-container">
{{ form.non_field_errors }}
</div>
<h2>Informations personnelles</h2>
<div class="row">
<div class="four columns{% if form.nom.errors %} error{% endif %}">
{{ form.nom.label_tag}}
{{ form.nom }}
{{ form.nom.errors }}
</div>
<div class="four columns{% if form.prenom.errors %} error{% endif %}">
{{ form.prenom.label_tag}}
{{ form.prenom }}
{{ form.prenom.errors }}
</div>
<div class="four columns{% if form.tel.errors %} error{% endif %}">
{{ form.tel.label_tag}}
{{ form.tel }}
{{ form.tel.errors }}
</div>
</div>
<div class="row">
<div class="four columns{% if form.etabetudes.errors %} error{% endif %}">
{{ form.etabetudes.label_tag}}
{{ form.etabetudes }}
{{ form.etabetudes.errors }}
</div>
<div class="four columns{% if form.annetudes.errors %} error{% endif %}">
{{ form.annetudes.label_tag}}
{{ form.annetudes }}
{{ form.annetudes.errors }}
</div>
<div class="four columns{% if form.dometudes.errors %} error{% endif %}">
{{ form.dometudes.label_tag}}
{{ form.dometudes }}
{{ form.dometudes.errors }}
</div>
</div>
<div class="row">
<div class="four columns{% if form.mail.errors %} error{% endif %}">
{{ form.mail.label_tag}}
{{ form.mail }}
{{ form.mail.errors }}
</div>
</div>
<footer>
<div class="row">
<div class="six columns">
<input class="button-add" type="submit" value="Enregistrer les changements">
</div>
</div>
</footer>
</form>
{% endblock %}
......@@ -35,4 +35,5 @@ views.delete_alias, name='delete_alias'),
url('^demenagement/(?P<ptype>adh)/(?P<uid>[0-9]+)/(?P<confirm>confirm)/$', views.demenagement, name='demenagement'),
url('^delete/(?P<ptype>club)/(?P<uid>[0-9]+)/$', views.delete, name='delete'),
url('^delete/(?P<ptype>adh)/(?P<uid>[0-9]+)/$', views.delete, name='delete'),
url('^create/$', views.create, name='create'),
)
......@@ -28,7 +28,7 @@ from intranet import settings
from gestion.config import factures, cotisation
from forms import BaseCompteForm, CompteForm, BasePassForm, PassForm, MailForm, AliasForm, SoldeForm, VenteForm, AdhesionForm, ComptecransForm, DemenagementForm
from forms import BaseCompteForm, CompteForm, BasePassForm, PassForm, MailForm, AliasForm, SoldeForm, VenteForm, AdhesionForm, ComptecransForm, DemenagementForm, NewCompteForm
from django.forms.util import ErrorList
def is_cableur(user):
......@@ -57,7 +57,7 @@ class CableurMixin(object):
Mixin permettant de vérifier soit que l'utilisateur est cableur
"""
@method_decorator(login_required)
def dispatch(self, request, uid, *args, **kwargs):
def dispatch(self, request, uid=None, *args, **kwargs):
luser = conn_pool.get_user(request.user)
if request.user.groups.filter(name='crans_cableur'):
return super(CableurMixin, self).dispatch(request, uid=uid, *args, **kwargs)
......@@ -646,3 +646,32 @@ class DeleteCompteView(CableurMixin, View):
delete = DeleteCompteView.as_view()
class CreateCompteView(CableurMixin, View):
"""
Classe pour la suppression d'un compte
"""
template_name = "compte/create.html"
def get(self, request, *args, **kwargs):
form = NewCompteForm()
return render(request, self.template_name, {'form' : form})
def post(self, request, *args, **kwargs):
form = NewCompteForm(data=request.POST)
if form.is_valid():
aldif = {'chbre': ["????"]}
aldif['etudes'] = [unicode(form.cleaned_data['etabetudes']), unicode(form.cleaned_data['annetudes']), unicode(form.cleaned_data['dometudes'])]
# On boucle sur les champs "simples"
for field in form.changed_data:
aldif[field] = [form.cleaned_data[field]]
with conn_pool.get_conn(request.user).newAdherent(aldif) as adherent:
adherent.create()
return redirect(reverse('cablage:afficher'))
return render(request, self.template_name, {'form' : form})
create = CreateCompteView.as_view()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment