Ajout snippets pour forms des templates

This commit is contained in:
Aurélien Delobelle 2016-09-03 23:44:45 +02:00
parent 04932dd22a
commit 9e7b6cccf5
10 changed files with 54 additions and 75 deletions

View file

@ -202,7 +202,7 @@ textarea {
padding:15px;
}
.form-only #id_trigramme {
.form-only .account_create #id_trigramme {
display:block;
width:200px;
height:80px;

View file

@ -14,7 +14,9 @@
</div>
<div class="buttons">
<a class="btn btn-primary btn-lg" href="{% url 'kfet.account.create' %}">Créer un compte</a>
<a class="btn btn-primary btn-lg" href="{% url 'kfet.account.group' %}">Permissions</a>
{% if perms.kfet.manage_perms %}
<a class="btn btn-primary btn-lg" href="{% url 'kfet.account.group' %}">Permissions</a>
{% endif %}
{% if perms.kfet.view_negs %}
<a class="btn btn-primary btn-lg" href="{% url 'kfet.account.negative' %}">Négatifs</a>
{% endif %}

View file

@ -32,12 +32,7 @@
{% include 'kfet/account_create_form.html' %}
</div>
{% if not perms.kfet.add_account %}
<div class="form-group">
<label for="password" class="col-sm-2 control-label">Authentification</label>
<div class="col-sm-10">
<input type="password" name="KFETPASSWORD" id="password" class="form-control">
</div>
</div>
{% include 'kfet/form_authentication_snippet.html' %}
{% endif %}
</div>
</form>

View file

@ -1,39 +1,9 @@
{% load widget_tweaks %}
{% for field in user_form %}
<div class="form-group">
<label for="{{ field.id_for_label }}" class="col-sm-2 control-label">{{ field.label }}</label>
<div class="col-sm-10">
{{ field|add_class:'form-control' }}
<span class="help-block">{{ field.errors }}</span>
</div>
</div>
{% endfor %}
{% for field in cof_form %}
<div class="form-group">
<label for="{{ field.id_for_label }}" class="col-sm-2 control-label">{{ field.label }}</label>
<div class="col-sm-10">
{{ field|add_class:'form-control' }}
<span class="help-block">{{ field.errors }}</span>
</div>
</div>
{% endfor %}
{% for field in account_form %}
<div class="form-group">
<label for="{{ field.id_for_label }}" class="col-sm-2 control-label">{{ field.label }}</label>
<div class="col-sm-10">
{{ field|add_class:'form-control' }}
<span class="help-block">{{ field.errors }}</span>
</div>
</div>
{% endfor %}
{% include 'kfet/form_snippet.html' with form=user_form %}
{% include 'kfet/form_snippet.html' with form=cof_form %}
{% include 'kfet/form_snippet.html' with form=account_form %}
{% if user_form %}
<div class="form-group">
<div class="col-sm-6 col-sm-offset-3 text-center">
<input type="submit" value="Enregistrer" class="btn btn-primary btn-lg">
</div>
</div>
{% include 'kfet/form_submit_snippet.html' with value="Enregistrer" %}
{% endif %}

View file

@ -1,4 +1,6 @@
{% extends "kfet/base.html" %}
{% load widget_tweaks %}
{% load staticfiles %}
{% block extra_head %}
{{ negative_form.media }}
@ -22,38 +24,24 @@
{% block content %}
<div class="row">
<div class="col-sm-4 col-md-3 col-content-left">
<div class="content-left">
{% include 'kfet/left_account.html' %}
</div>
</div>
<div class="col-sm-8 col-md-9 col-content-right">
{% include "kfet/base_messages.html" %}
<div class="content-right">
<div class="content-right-block">
<form action="{% url 'kfet.account.update' account.trigramme %}" method="post">
{% csrf_token %}
{{ user_form.as_p }}
{{ cof_form.as_p }}
{{ account_form.as_p }}
{{ group_form.as_p }}
{{ pwd_form.as_p }}
{{ negative_form.non_field_errors }}
{% for field in negative_form %}
{{ field.errors }}
{{ field.label_tag }}
<div style="position:relative">{{ field }}</div>
{% if field.help_text %}
<p class="help">{{ field.help_text|safe }}</p>
{% endif %}
{% endfor %}
{% if perms.kfet.is_team %}
<input type="password" name="KFETPASSWORD">
{% endif %}
<input type="submit" value="Mettre à jour">
</form>
</div>
{% include "kfet/base_messages.html" %}
<div class="row form-only">
<div class="col-sm-12 col-md-8 col-md-offset-2">
<div class="content-form">
<form action="{% url 'kfet.account.update' account.trigramme %}" method="post" class="form-horizontal">
{% csrf_token %}
{% include 'kfet/form_snippet.html' with form=user_form %}
{% include 'kfet/form_snippet.html' with form=cof_form %}
{% include 'kfet/form_snippet.html' with form=account_form %}
{% include 'kfet/form_snippet.html' with form=group_form %}
{% include 'kfet/form_snippet.html' with form=pwd_form %}
{% include 'kfet/form_snippet.html' with form=negative_form %}
{% if perms.kfet.is_team %}
{% include 'kfet/form_authentication_snippet.html' %}
{% endif %}
{% include 'kfet/form_submit_snippet.html' with value="Mettre à jour" %}
</form>
</div>
</div>
</div>

View file

@ -0,0 +1,6 @@
<div class="form-group">
<label for="password" class="col-sm-2 control-label">Authentification</label>
<div class="col-sm-10">
<input type="password" name="KFETPASSWORD" id="password" class="form-control">
</div>
</div>

View file

@ -0,0 +1,9 @@
{% load widget_tweaks %}
<div class="form-group">
<label for="{{ field.id_for_label }}" class="col-sm-2 control-label">{{ field.label }}</label>
<div class="col-sm-10">
{{ field|add_class:'form-control' }}
<span class="help-block">{{ field.errors }}</span>
</div>
</div>

View file

@ -0,0 +1,3 @@
{% for field in form %}
{% include 'kfet/form_field_snippet.html' with field=field %}
{% endfor %}

View file

@ -0,0 +1,5 @@
<div class="form-group">
<div class="col-sm-6 col-sm-offset-3 text-center">
<input type="submit" value="{{ value }}" class="btn btn-primary btn-lg">
</div>
</div>

View file

@ -213,7 +213,8 @@ $(document).ready(function() {
content += '</ul>';
}
if ('negative' in data['errors'])
content += '<a class="btn btn-primary" href="/k-fet/accounts/'+account_data['trigramme']+'/edit" target="_blank">Autorisation de négatif requise</a>';
for (var i=0; i<data['errors']['negative'].length; i++) {
content += '<a class="btn btn-primary" href="/k-fet/accounts/'+data['errors']['negative'][i]+'/edit" target="_blank">Autorisation de négatif requise pour '+data['errors']['negative'][i]+'</a>';
return content;
}