Commit 4670b51c authored by Birin Sanchez's avatar Birin Sanchez
Browse files

* Make recovery email non unique.

* Remove non_unique_email command.
* Add command populate_recovery_email.
Signed-off-by: Birin Sanchez's avatarBirin Sanchez <>
parent 0f69fcc9
Pipeline #12706 passed with stage
in 40 seconds
from import BaseCommand
from purist.models import User
class Command(BaseCommand):
help = 'Shows what recovery emails are used in more than one account.'
def handle(self, *args, **options):
sql_query = 'SELECT id,email,COUNT(email) AS count from purist_user \
GROUP BY email HAVING COUNT(email) > 1'
query = User.objects.raw(sql_query)
msg1 = "\nRecovery email '{}' is used {} times by the following users:"
msg2 = ' {}'
for item in query:
print(msg1.format(, item.count))
users = User.objects.filter(
for user in users:
from import BaseCommand
from purist.models import User
import time
class Command(BaseCommand):
help = "Populate (recovery email) with User.get_identity() for \
users that did not add a recovery email a the time of registration."
def add_arguments(self, parser):
help='Number of seconds to wait between users. \
Default is 0.',
def handle(self, *args, **options):
wait_time = options['wait']
usrs_empty = User.objects.filter(email='')
self.stdout.write('Processing users with no recovery email')
for user in usrs_empty: = user.get_identity()
self.stdout.write(' User {}:'.format(user.username))
self.stdout.write(' New recovery email: {}'.format(
# -*- coding: utf-8 -*-
# Generated by Django 1.11.20 on 2019-05-22 15:42
from __future__ import unicode_literals
from django.db import migrations, models
import purist.models
class Migration(migrations.Migration):
dependencies = [
('purist', '0005_add_billing_email'),
operations = [
field=models.EmailField(max_length=254, verbose_name='email address'),
field=models.CharField(error_messages={'unique': 'An account with that address already exists.'}, help_text='Start with a letter, followed by letters or numbers.', max_length=150, unique=True, validators=[purist.models.UsernameValidator()], verbose_name='username'),
......@@ -81,7 +81,7 @@ class User(AbstractUser):
'unique': _("An account with that address already exists."),
email = models.EmailField(_('email address'), blank=False, unique=True) # recovery email address
email = models.EmailField(_('email address'), blank=False, unique=False) # recovery email address
tunnel_user = models.CharField(max_length=250, default=None, null=True)
tunnel_password = models.CharField(max_length=250, default=None, null=True)
account_type = EnumIntegerField(enum=AccountType,
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment