Beispiel #1
0
    def handle(self, *args, **options):
        # Prevent user to be automatically created
        post_save.disconnect(sync_ckan_on_save, sender=User, dispatch_uid="youckan.ckan.sync_user")

        if options['all']:
            for user in User.objects.all():
                self.stdout.write('Sending reset password mail to {0}'.format(user.email))
                mail.reset_password(user)
        else:
            email = args[0]
            user = User.objects.get(email=email)
            self.stdout.write('Sending reset password mail to {0}'.format(user.email))
            mail.reset_password(user)
Beispiel #2
0
    def handle(self, *args, **options):
        # Prevent user to be automatically created
        post_save.disconnect(sync_ckan_on_save, sender=User, dispatch_uid="youckan.ckan.sync_user")

        update_ckan_user = options['update']
        notify = options['notify']

        response = client.action('user_list', timeout=60)
        for userdata in response['result']:
            try:
                user = self.create_user(userdata)
            except Exception as e:
                self.stdout.write('Error creating user {0}: {1}'.format(userdata['id'], e))
                user = None
            ckan_id = userdata['id']
            if not user:
                self.stdout.write('Skipping user {id}'.format(**userdata))
                continue
            if update_ckan_user:
                self.update_ckan_user(user, ckan_id)
            if notify:
                self.stdout.write('Sending reset password mail to {0}'.format(user.email))
                mail.reset_password(user)