diff --git a/taiga/users/admin.py b/taiga/users/admin.py index 212231fe..74f7be46 100644 --- a/taiga/users/admin.py +++ b/taiga/users/admin.py @@ -118,7 +118,7 @@ class UserAdmin(DjangoUserAdmin): (None, {"fields": ("username", "password")}), (_("Personal info"), {"fields": ("full_name", "email", "bio", "photo")}), (_("Extra info"), {"fields": ("color", "lang", "timezone", "token", "colorize_tags", - "email_token", "new_email")}), + "email_token", "new_email", "accepted_terms", "read_new_terms")}), (_("Permissions"), {"fields": ("is_active", "is_superuser")}), (_("Restrictions"), {"fields": (("max_private_projects", "max_memberships_private_projects"), ("max_public_projects", "max_memberships_public_projects"))}), diff --git a/taiga/users/migrations/0026_auto_20180514_1513.py b/taiga/users/migrations/0026_auto_20180514_1513.py new file mode 100644 index 00000000..68f5568f --- /dev/null +++ b/taiga/users/migrations/0026_auto_20180514_1513.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.2 on 2018-05-14 15:13 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('users', '0025_user_uuid'), + ] + + operations = [ + migrations.AddField( + model_name='user', + name='accepted_terms', + field=models.BooleanField(default=True, verbose_name='accepted terms'), + ), + migrations.AddField( + model_name='user', + name='read_new_terms', + field=models.BooleanField(default=False, verbose_name='read new terms'), + ), + ] diff --git a/taiga/users/models.py b/taiga/users/models.py index ceb0ee1e..8d4db071 100644 --- a/taiga/users/models.py +++ b/taiga/users/models.py @@ -152,6 +152,8 @@ class User(AbstractBaseUser, PermissionsMixin): max_length=500, null=True, blank=True, verbose_name=_("photo")) date_joined = models.DateTimeField(_("date joined"), default=timezone.now) + accepted_terms = models.BooleanField(_("accepted terms"), default=True) + read_new_terms = models.BooleanField(_("new terms read"), default=False) lang = models.CharField(max_length=20, null=True, blank=True, default="", verbose_name=_("default language")) theme = models.CharField(max_length=100, null=True, blank=True, default="", diff --git a/taiga/users/serializers.py b/taiga/users/serializers.py index 8621147e..2b4458c8 100644 --- a/taiga/users/serializers.py +++ b/taiga/users/serializers.py @@ -80,6 +80,8 @@ class UserAdminSerializer(UserSerializer): email = Field() uuid = Field() date_joined = Field() + read_new_terms = Field() + accepted_terms = Field() max_private_projects = Field() max_public_projects = Field() max_memberships_private_projects = Field() diff --git a/taiga/users/validators.py b/taiga/users/validators.py index 45c42be0..8b649446 100644 --- a/taiga/users/validators.py +++ b/taiga/users/validators.py @@ -64,8 +64,15 @@ class UserAdminValidator(UserValidator): # IMPORTANT: Maintain the UserSerializer Meta up to date # with this info (including here the email) fields = ("username", "full_name", "color", "bio", "lang", - "theme", "timezone", "is_active", "email") + "theme", "timezone", "is_active", "email", "read_new_terms") + def validate_read_new_terms(self, attrs, source): + value = attrs[source] + if not value: + raise ValidationError( + _("Read new terms has to be true'")) + + return attrs class RecoveryValidator(validators.Validator): token = serializers.CharField(max_length=200)