8
0
Fork 0
mirror of https://gitlab2.federez.net/re2o/re2o synced 2024-11-24 20:33:11 +00:00

Ajoute un reglage pour set tous les comptes actifs à l'initialisation

This commit is contained in:
Gabriel Detraz 2019-01-05 18:32:54 +01:00 committed by root
parent 20e1ee3bb4
commit 0b1c35900f
5 changed files with 31 additions and 1 deletions

View file

@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.10.7 on 2019-01-05 17:15
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('preferences', '0056_4_radiusoption'),
]
operations = [
migrations.AddField(
model_name='optionaluser',
name='all_users_active',
field=models.BooleanField(default=False, help_text='If True, all new created and connected users are active. If False, only when a valid registration has been paid'),
),
]

View file

@ -116,6 +116,11 @@ class OptionalUser(AclMixin, PreferencesModel):
default=False, default=False,
help_text=_("A new user can create their account on Re2o") help_text=_("A new user can create their account on Re2o")
) )
all_users_active = models.BooleanField(
default=False,
help_text=_("If True, all new created and connected users are active.\
If False, only when a valid registration has been paid")
)
class Meta: class Meta:
permissions = ( permissions = (

View file

@ -122,6 +122,10 @@ with this program; if not, write to the Free Software Foundation, Inc.,
<th>{% trans "Delete not yet active users after" %}</th> <th>{% trans "Delete not yet active users after" %}</th>
<td>{{ useroptions.delete_notyetactive }} days</td> <td>{{ useroptions.delete_notyetactive }} days</td>
</tr> </tr>
<tr>
<th>{% trans "All users are active by default" %}</th>
<td>{{ useroptions.all_users_active|tick }}</td>
</tr>
</table> </table>
<h4 id="users">{% trans "Users general permissions" %}</h4> <h4 id="users">{% trans "Users general permissions" %}</h4>

View file

@ -117,6 +117,7 @@ class PassForm(FormRevMixin, FieldPermissionFormMixin, forms.ModelForm):
"""Changement du mot de passe""" """Changement du mot de passe"""
user = super(PassForm, self).save(commit=False) user = super(PassForm, self).save(commit=False)
user.set_password(self.cleaned_data.get("passwd1")) user.set_password(self.cleaned_data.get("passwd1"))
user.set_active()
user.save() user.save()

View file

@ -337,7 +337,7 @@ class User(RevMixin, FieldPermissionModelMixin, AbstractBaseUser,
def set_active(self): def set_active(self):
"""Enable this user if he subscribed successfully one time before""" """Enable this user if he subscribed successfully one time before"""
if self.state == self.STATE_NOT_YET_ACTIVE: if self.state == self.STATE_NOT_YET_ACTIVE:
if self.facture_set.filter(valid=True).filter(Q(vente__type_cotisation='All') | Q(vente__type_cotisation='Adhesion')).exists(): if self.facture_set.filter(valid=True).filter(Q(vente__type_cotisation='All') | Q(vente__type_cotisation='Adhesion')).exists() or OptionalUser.get_cached_value('all_users_active'):
self.state = self.STATE_ACTIVE self.state = self.STATE_ACTIVE
self.save() self.save()