Ejemplo n.º 1
0
def check_duplicate_emails(app_configs=None, **kwargs):
    from accounts.utils import get_duplicate_emails
    errors = []
    try:
        if len(get_duplicate_emails()):
            errors.append(
                checks.Warning(
                    _("There are user accounts with duplicate emails. This "
                      "will not be allowed in Pootle 2.8."),
                    hint=_("Try using 'pootle find_duplicate_emails', and "
                           "then update user emails with 'pootle "
                           "update_user_email username email'. You might also "
                           "want to consider using pootle merge_user or "
                           "purge_user commands"),
                    id="pootle.W017"))
    except (OperationalError, ProgrammingError):
        # no accounts set up - most likely in a test
        pass
    return errors
Ejemplo n.º 2
0
def check_duplicate_emails(app_configs=None, **kwargs):
    from accounts.utils import get_duplicate_emails
    errors = []
    try:
        if len(get_duplicate_emails()):
            errors.append(
                checks.Warning(
                    _("There are user accounts with duplicate emails. This "
                      "will not be allowed in Pootle 2.8."),
                    hint=_("Try using 'pootle find_duplicate_emails', and "
                           "then update user emails with 'pootle "
                           "update_user_email username email'. You might also "
                           "want to consider using pootle merge_user or "
                           "purge_user commands"),
                    id="pootle.W017"
                )
            )
    except (OperationalError, ProgrammingError):
        # no accounts set up - most likely in a test
        pass
    return errors
Ejemplo n.º 3
0
    def handle(self, *args, **kwargs):
        duplicates = get_duplicate_emails()
        if not duplicates:
            self.stdout.write("There are no accounts with duplicate emails\n")
            return

        for email in duplicates:
            users = User.objects.hide_meta().filter(email=email).order_by("-last_login")
            if email:
                self.stdout.write("The following users have the email: %s\n" % email)
            else:
                self.stdout.write("The following users have no email set:\n")
            for user in users:
                args = (
                    user.username,
                    " " * (25 - len(user.username)),
                    user.last_login.strftime("%Y-%m-%d %H:%M"),
                    (user.is_superuser and "\t\tthis user is a Superuser" or ""),
                )
                self.stdout.write(" %s%slast login: %s%s\n" % args)
            self.stdout.write("\n")
Ejemplo n.º 4
0
    def handle(self, *args, **kwargs):
        duplicates = get_duplicate_emails()
        if not duplicates:
            self.stdout.write("There are no accounts with duplicate emails\n")
            return

        for email in duplicates:
            users = (User.objects.hide_meta().filter(
                email=email).order_by("-last_login"))
            if email:
                self.stdout.write("The following users have the email: %s\n" %
                                  email)
            else:
                self.stdout.write("The following users have no email set:\n")
            for user in users:
                args = (user.username, " " * (25 - len(user.username)),
                        user.last_login.strftime('%Y-%m-%d %H:%M'),
                        (user.is_superuser and "\t\tthis user is a Superuser"
                         or ""))
                self.stdout.write(" %s%slast login: %s%s\n" % args)
            self.stdout.write("\n")