示例#1
0
    def create_user(self, username, email, password, active=False,
                    send_email=True):
        """
        A simple wrapper that creates a new :class:`User`.

        :param username:
        String containing the username of the new user.

        :param email:
        String containing the email address of the new user.

        :param password:
        String containing the password for the new user.

        :param active:
        Boolean that defines if the user requires activation by clicking
        on a link in an e-mail. Defauts to ``True``.

        :param send_email:
        Boolean that defines if the user should be send an email. You could
        set this to ``False`` when you want to create a user in your own
        code, but don't want the user to activate through email.

        :return: :class:`User` instance representing the new user.

        """
        now = utils.get_datetime_now()

        new_user = User.objects.create_user(username, email, password)
        new_user.is_active = active
        new_user.save()

        lutefisk_profile = self.create_lutefisk_profile(new_user)

        # All users have an empty profile
        profile_model = utils.get_profile_model()
        try:
            new_profile = new_user.get_profile()
        except profile_model.DoesNotExist:
            new_profile = profile_model(user=new_user)
            new_profile.save(using=self._db)

        if send_email:
            lutefisk_profile.send_activation_email()
            
        return new_user
示例#2
0
# -*- coding: utf-8 -*-

from django.contrib import admin

from lutefisk import utils

admin.site.register(utils.get_profile_model())

# Local Variables:
# indent-tabs-mode: nil
# End:
# vim: ai et sw=4 ts=4