forked from DGNum/gestioCOF
Merge branch 'master' into test/views
This commit is contained in:
commit
3d22a1b029
17 changed files with 252 additions and 98 deletions
|
@ -5,7 +5,6 @@ from decimal import Decimal
|
|||
|
||||
from django import forms
|
||||
from django.core.exceptions import ValidationError
|
||||
from django.core.validators import MinLengthValidator
|
||||
from django.contrib.auth.models import User, Group, Permission
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
from django.forms import modelformset_factory, widgets
|
||||
|
@ -110,21 +109,16 @@ class CofRestrictForm(CofForm):
|
|||
class Meta(CofForm.Meta):
|
||||
fields = ['departement']
|
||||
|
||||
class UserForm(forms.ModelForm):
|
||||
def __init__(self, *args, **kwargs):
|
||||
from_clipper = kwargs.pop('from_clipper', False)
|
||||
new_user = kwargs.get('instance') is None and not from_clipper
|
||||
super(UserForm, self).__init__(*args, **kwargs)
|
||||
if new_user:
|
||||
self.fields['username'].validators = [MinLengthValidator(9)]
|
||||
|
||||
class UserForm(forms.ModelForm):
|
||||
class Meta:
|
||||
model = User
|
||||
model = User
|
||||
fields = ['username', 'first_name', 'last_name', 'email']
|
||||
help_texts = {
|
||||
'username': ''
|
||||
}
|
||||
|
||||
|
||||
class UserRestrictForm(UserForm):
|
||||
class Meta(UserForm.Meta):
|
||||
fields = ['first_name', 'last_name']
|
||||
|
@ -173,10 +167,22 @@ class GroupForm(forms.ModelForm):
|
|||
name = self.cleaned_data['name']
|
||||
return 'K-Fêt %s' % name
|
||||
|
||||
def clean_permissions(self):
|
||||
kfet_perms = self.cleaned_data['permissions']
|
||||
# TODO: With Django >=1.11, the QuerySet method 'difference' can be used.
|
||||
# other_groups = self.instance.permissions.difference(
|
||||
# self.fields['permissions'].queryset
|
||||
# )
|
||||
other_perms = self.instance.permissions.exclude(
|
||||
pk__in=[p.pk for p in self.fields['permissions'].queryset],
|
||||
)
|
||||
return list(kfet_perms) + list(other_perms)
|
||||
|
||||
class Meta:
|
||||
model = Group
|
||||
model = Group
|
||||
fields = ['name', 'permissions']
|
||||
|
||||
|
||||
class AccountNegativeForm(forms.ModelForm):
|
||||
class Meta:
|
||||
model = AccountNegative
|
||||
|
|
19
kfet/migrations/0054_update_promos.py
Normal file
19
kfet/migrations/0054_update_promos.py
Normal file
|
@ -0,0 +1,19 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('kfet', '0053_created_at'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='account',
|
||||
name='promo',
|
||||
field=models.IntegerField(blank=True, choices=[(1980, 1980), (1981, 1981), (1982, 1982), (1983, 1983), (1984, 1984), (1985, 1985), (1986, 1986), (1987, 1987), (1988, 1988), (1989, 1989), (1990, 1990), (1991, 1991), (1992, 1992), (1993, 1993), (1994, 1994), (1995, 1995), (1996, 1996), (1997, 1997), (1998, 1998), (1999, 1999), (2000, 2000), (2001, 2001), (2002, 2002), (2003, 2003), (2004, 2004), (2005, 2005), (2006, 2006), (2007, 2007), (2008, 2008), (2009, 2009), (2010, 2010), (2011, 2011), (2012, 2012), (2013, 2013), (2014, 2014), (2015, 2015), (2016, 2016), (2017, 2017)], default=2017, null=True),
|
||||
),
|
||||
]
|
15
kfet/migrations/0057_merge.py
Normal file
15
kfet/migrations/0057_merge.py
Normal file
|
@ -0,0 +1,15 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('kfet', '0056_change_account_meta'),
|
||||
('kfet', '0054_update_promos'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
]
|
|
@ -14,10 +14,16 @@
|
|||
|
||||
.kfetopen .base {
|
||||
height: 50px;
|
||||
padding: 15px;
|
||||
max-width: 16px;
|
||||
|
||||
display: inline-flex;
|
||||
margin-left: 5px;
|
||||
margin-right: 5px;
|
||||
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-content: center;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.kfetopen .details {
|
||||
|
@ -34,10 +40,23 @@
|
|||
height: 10px;
|
||||
border-radius: 50%;
|
||||
transition: background 0.15s;
|
||||
margin: 3px;
|
||||
}
|
||||
|
||||
.kfetopen .warning {
|
||||
margin-left: 15px;
|
||||
display: none;
|
||||
}
|
||||
|
||||
@media (min-width: 576px) {
|
||||
.kfetopen .base {
|
||||
max-width: none;
|
||||
margin-left: 15px;
|
||||
margin-right: 15px;
|
||||
}
|
||||
|
||||
.kfetopen .warning {
|
||||
margin-left: 15px;
|
||||
}
|
||||
}
|
||||
|
||||
.kfetopen .status-text {
|
||||
|
|
|
@ -74,10 +74,10 @@ OpenKfet.prototype = {
|
|||
if (this.admin) {
|
||||
this.add_class(this.admin_status);
|
||||
if (this.force_close) {
|
||||
this.dom.warning.addClass('in');
|
||||
this.dom.warning.show().addClass('in');
|
||||
this.dom.force_close_btn.html(this.force_text['deactivate']);
|
||||
} else {
|
||||
this.dom.warning.removeClass('in');
|
||||
this.dom.warning.removeClass('in').hide();
|
||||
this.dom.force_close_btn.html(this.force_text['activate']);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -94,7 +94,7 @@
|
|||
{% endif %}
|
||||
<li class="divider"></li>
|
||||
<li>
|
||||
<a href="{% url "cof-logout" %}?next=/k-fet/">
|
||||
<a href="{% url "cof-logout" %}?next={% slugurl "k-fet" %}">
|
||||
<span class="glyphicon glyphicon-log-out"></span><span>Déconnexion</span>
|
||||
</a>
|
||||
</li>
|
||||
|
@ -103,7 +103,7 @@
|
|||
{% endif %}
|
||||
{% if user.is_authenticated and not perms.kfet.is_team %}
|
||||
<li>
|
||||
<a href="{% url "cof-logout" %}?next=/k-fet/" title="Déconnexion">
|
||||
<a href="{% url "cof-logout" %}?next={% slugurl "k-fet" %}" title="Déconnexion">
|
||||
<span class="glyphicon glyphicon-log-out"></span>
|
||||
</a>
|
||||
</li>
|
||||
|
|
|
@ -268,10 +268,10 @@ def get_account_create_forms(request=None, username=None, login_clipper=None,
|
|||
|
||||
# Form créations
|
||||
if request:
|
||||
user_form = UserForm(request.POST, initial=user_initial, from_clipper=True)
|
||||
user_form = UserForm(request.POST, initial=user_initial)
|
||||
cof_form = CofForm(request.POST, initial=cof_initial)
|
||||
else:
|
||||
user_form = UserForm(initial=user_initial, from_clipper=True)
|
||||
user_form = UserForm(initial=user_initial)
|
||||
cof_form = CofForm(initial=cof_initial)
|
||||
|
||||
# Protection (read-only) des champs username et login_clipper
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue