mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-30 08:32:26 +00:00
Les nouveau users ne sont pas adhérents et n'ont pas de home
This commit is contained in:
parent
3e679757af
commit
fa3aca906f
5 changed files with 40 additions and 7 deletions
|
@ -421,7 +421,7 @@ class UserViewSet(viewsets.ReadOnlyModelViewSet):
|
||||||
class HomeCreationViewSet(viewsets.ReadOnlyModelViewSet):
|
class HomeCreationViewSet(viewsets.ReadOnlyModelViewSet):
|
||||||
"""Exposes infos of `users.models.Users` objects to create homes.
|
"""Exposes infos of `users.models.Users` objects to create homes.
|
||||||
"""
|
"""
|
||||||
queryset = users.User.objects.all()
|
queryset = users.User.objects.filter(state = 0)
|
||||||
serializer_class = serializers.HomeCreationSerializer
|
serializer_class = serializers.HomeCreationSerializer
|
||||||
|
|
||||||
class ClubViewSet(viewsets.ReadOnlyModelViewSet):
|
class ClubViewSet(viewsets.ReadOnlyModelViewSet):
|
||||||
|
|
|
@ -243,6 +243,9 @@ def facture_post_save(**kwargs):
|
||||||
"""
|
"""
|
||||||
facture = kwargs['instance']
|
facture = kwargs['instance']
|
||||||
user = facture.user
|
user = facture.user
|
||||||
|
if facture.valid and facture.vente_set.filter(Q(type_cotisation='All') | Q(type_cotisation='Adhesion')).exists():
|
||||||
|
user.state = 0
|
||||||
|
user.save()
|
||||||
user.ldap_sync(base=False, access_refresh=True, mac_refresh=False)
|
user.ldap_sync(base=False, access_refresh=True, mac_refresh=False)
|
||||||
|
|
||||||
|
|
||||||
|
@ -473,6 +476,11 @@ def vente_post_save(**kwargs):
|
||||||
purchase.cotisation.save()
|
purchase.cotisation.save()
|
||||||
user = purchase.facture.user
|
user = purchase.facture.user
|
||||||
user.ldap_sync(base=False, access_refresh=True, mac_refresh=False)
|
user.ldap_sync(base=False, access_refresh=True, mac_refresh=False)
|
||||||
|
if purchase.facture.valid and (purchase.type_cotisation == 'All' or purchase.type_cotisation == 'Adhesion'):
|
||||||
|
user = purchase.facture.user
|
||||||
|
if user.state == 3:
|
||||||
|
user.state = 0
|
||||||
|
user.save()
|
||||||
|
|
||||||
|
|
||||||
# TODO : change vente to purchase
|
# TODO : change vente to purchase
|
||||||
|
|
20
users/migrations/0077_auto_20180824_1750.py
Normal file
20
users/migrations/0077_auto_20180824_1750.py
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Generated by Django 1.10.7 on 2018-08-24 15:50
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('users', '0076_auto_20180818_1321'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='user',
|
||||||
|
name='state',
|
||||||
|
field=models.IntegerField(choices=[(0, 'STATE_ACTIVE'), (1, 'STATE_DISABLED'), (2, 'STATE_ARCHIVE'), (3, 'STATE_NOT_YET_ACTIVE')], default=3),
|
||||||
|
),
|
||||||
|
]
|
|
@ -186,10 +186,12 @@ class User(RevMixin, FieldPermissionModelMixin, AbstractBaseUser,
|
||||||
STATE_ACTIVE = 0
|
STATE_ACTIVE = 0
|
||||||
STATE_DISABLED = 1
|
STATE_DISABLED = 1
|
||||||
STATE_ARCHIVE = 2
|
STATE_ARCHIVE = 2
|
||||||
|
STATE_NOT_YET_ACTIVE = 3
|
||||||
STATES = (
|
STATES = (
|
||||||
(0, 'STATE_ACTIVE'),
|
(0, 'STATE_ACTIVE'),
|
||||||
(1, 'STATE_DISABLED'),
|
(1, 'STATE_DISABLED'),
|
||||||
(2, 'STATE_ARCHIVE'),
|
(2, 'STATE_ARCHIVE'),
|
||||||
|
(3, 'STATE_NOT_YET_ACTIVE'),
|
||||||
)
|
)
|
||||||
|
|
||||||
surname = models.CharField(max_length=255)
|
surname = models.CharField(max_length=255)
|
||||||
|
@ -231,7 +233,7 @@ class User(RevMixin, FieldPermissionModelMixin, AbstractBaseUser,
|
||||||
blank=True
|
blank=True
|
||||||
)
|
)
|
||||||
pwd_ntlm = models.CharField(max_length=255)
|
pwd_ntlm = models.CharField(max_length=255)
|
||||||
state = models.IntegerField(choices=STATES, default=STATE_ACTIVE)
|
state = models.IntegerField(choices=STATES, default=STATE_NOT_YET_ACTIVE)
|
||||||
registered = models.DateTimeField(auto_now_add=True)
|
registered = models.DateTimeField(auto_now_add=True)
|
||||||
telephone = models.CharField(max_length=15, blank=True, null=True)
|
telephone = models.CharField(max_length=15, blank=True, null=True)
|
||||||
uid_number = models.PositiveIntegerField(
|
uid_number = models.PositiveIntegerField(
|
||||||
|
@ -329,7 +331,7 @@ class User(RevMixin, FieldPermissionModelMixin, AbstractBaseUser,
|
||||||
@property
|
@property
|
||||||
def is_active(self):
|
def is_active(self):
|
||||||
""" Renvoie si l'user est à l'état actif"""
|
""" Renvoie si l'user est à l'état actif"""
|
||||||
return self.state == self.STATE_ACTIVE
|
return self.state == self.STATE_ACTIVE or self.state == self.STATE_NOT_YET_ACTIVE
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_staff(self):
|
def is_staff(self):
|
||||||
|
|
|
@ -211,11 +211,14 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<th>{% trans "State" %}</th>
|
<th>{% trans "State" %}</th>
|
||||||
{% if users.state == 0 %}
|
{% if users.state == 0 %}
|
||||||
<td><i class="text-success">{% trans "Active" %}</i></td>
|
<td><i class="text-warning">{% trans "Active" %}</i></td>
|
||||||
{% elif users.state == 1 %}
|
{% elif users.state == 1 %}
|
||||||
<td><i class="text-danger">{% trans "Disabled" %}</i></td>
|
<td><i class="text-success">{% trans "Disabled" %}</i></td>
|
||||||
{% else %}
|
{% elif users.state == 2 %}
|
||||||
<td><i class="text-warning">{% trans "Archived" %}</i></td>
|
<td><i class="text-danger">{% trans "Archived" %}</i></td>
|
||||||
|
{% elif users.state == 3 %}
|
||||||
|
<td><i class="text-danger">{% trans "Not yet Member" %}</i></td>
|
||||||
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
|
|
Loading…
Reference in a new issue