8
0
Fork 0
mirror of https://gitlab2.federez.net/re2o/re2o synced 2024-11-23 11:53:12 +00:00

Les nouveau users ne sont pas adhérents et n'ont pas de home

This commit is contained in:
grisel-davy 2018-08-30 17:25:15 +02:00 committed by chirac
parent 3e679757af
commit fa3aca906f
5 changed files with 40 additions and 7 deletions

View file

@ -421,7 +421,7 @@ class UserViewSet(viewsets.ReadOnlyModelViewSet):
class HomeCreationViewSet(viewsets.ReadOnlyModelViewSet):
"""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
class ClubViewSet(viewsets.ReadOnlyModelViewSet):

View file

@ -243,6 +243,9 @@ def facture_post_save(**kwargs):
"""
facture = kwargs['instance']
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)
@ -473,6 +476,11 @@ def vente_post_save(**kwargs):
purchase.cotisation.save()
user = purchase.facture.user
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

View 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),
),
]

View file

@ -186,10 +186,12 @@ class User(RevMixin, FieldPermissionModelMixin, AbstractBaseUser,
STATE_ACTIVE = 0
STATE_DISABLED = 1
STATE_ARCHIVE = 2
STATE_NOT_YET_ACTIVE = 3
STATES = (
(0, 'STATE_ACTIVE'),
(1, 'STATE_DISABLED'),
(2, 'STATE_ARCHIVE'),
(3, 'STATE_NOT_YET_ACTIVE'),
)
surname = models.CharField(max_length=255)
@ -231,7 +233,7 @@ class User(RevMixin, FieldPermissionModelMixin, AbstractBaseUser,
blank=True
)
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)
telephone = models.CharField(max_length=15, blank=True, null=True)
uid_number = models.PositiveIntegerField(
@ -329,7 +331,7 @@ class User(RevMixin, FieldPermissionModelMixin, AbstractBaseUser,
@property
def is_active(self):
""" 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
def is_staff(self):

View file

@ -211,11 +211,14 @@ with this program; if not, write to the Free Software Foundation, Inc.,
{% endif %}
<th>{% trans "State" %}</th>
{% 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 %}
<td><i class="text-danger">{% trans "Disabled" %}</i></td>
{% else %}
<td><i class="text-warning">{% trans "Archived" %}</i></td>
<td><i class="text-success">{% trans "Disabled" %}</i></td>
{% elif users.state == 2 %}
<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 %}
</tr>
<tr>