Esempio n. 1
0
    def register(self, request, **kwargs):
        """
        Override of the register method.
        Creates an inactive auth.User record; adds first_name and last_name;
        Also creates a UserProfile record, with some of the compulsory information in it.
        """
        username, email, password = kwargs['username'], kwargs[
            'email'], kwargs['password1']
        if Site._meta.installed:
            site = Site.objects.get_current()
        else:
            site = RequestSite(request)
        new_user = RegistrationProfile.objects.create_inactive_user(
            username, email, password, site)

        # add first and last name to created inactive user
        new_user.first_name = request.POST['first_name']
        new_user.last_name = request.POST['last_name']
        new_user.save()

        # create
        if 'uses_niuckname' in request.POST:
            uses_nickname = True
        else:
            uses_nickname = False
        new_profile = UserProfile(user=new_user,
                                  city=request.POST['city'],
                                  uses_nickname=uses_nickname)
        new_profile.save()

        signals.user_registered.send(sender=self.__class__,
                                     user=new_user,
                                     request=request)
        return new_user
Esempio n. 2
0
    def register(self, request, **kwargs):
        """
        Override of the register method.
        Creates an inactive auth.User record; adds first_name and last_name;
        Also creates a UserProfile record, with some of the compulsory information in it.
        """
        username, email, password = kwargs['username'], kwargs['email'], kwargs['password1']
        if Site._meta.installed:
            site = Site.objects.get_current()
        else:
            site = RequestSite(request)
        new_user = RegistrationProfile.objects.create_inactive_user(username, email, password, site)

        # add first and last name to created inactive user
        new_user.first_name = request.POST['first_name']
        new_user.last_name = request.POST['last_name']
        new_user.save()

        # create
        if 'uses_niuckname' in request.POST:
            uses_nickname = True
        else:
            uses_nickname = False
        new_profile = UserProfile(user=new_user,
                                  city=request.POST['city'],
                                  uses_nickname=uses_nickname)
        new_profile.save()

        signals.user_registered.send(sender=self.__class__,
                                     user=new_user,
                                     request=request)
        return new_user
Esempio n. 3
0
def user_created(sender, user, request, **kwargs):
    """
    As soon as a new ``User`` is created, the correspondent
    ``UserProfile`` must be created too. Necessary information is
    supposed to be found in POST data.
    """
    form = UserRegistrationForm(request.POST)
    user.first_name = form.data['first_name']
    user.last_name = form.data['last_name']
    user.save()

    print "ciao sono qua"

    extra_data = UserProfile(user=user)
    extra_data.says_is_politician = form.data[
        'says_is_politician'] if 'says_in_politician' in form.data else False
    extra_data.uses_nickname = form.data[
        'uses_nickname'] if 'uses_nickname' in form.data else False
    extra_data.wants_newsletter = False
    extra_data.wants_newsletter = form.data[
        'wants_newsletter'] if 'wants_newsletter' in form.data else False
    extra_data.location = Location.objects.get(
        pk=form.data['location']) if form.data['location'] != '' else None
    extra_data.description = form.data['description']
    extra_data.image = request.FILES[
        'image'] if 'image' in request.FILES else None
    extra_data.save()
Esempio n. 4
0
def user_created(sender, user, request, **kwargs):
    """
    As soon as a new ``User`` is created, the correspondent
    ``UserProfile`` must be created too. Necessary information is
    supposed to be found in POST data.
    """
    form = UserRegistrationForm(request.POST)
    user.first_name = form.data['first_name']
    user.last_name = form.data['last_name']
    user.save()


    print "ciao sono qua"

    extra_data = UserProfile(user=user)
    extra_data.says_is_politician = form.data['says_is_politician'] if 'says_in_politician' in form.data else False
    extra_data.uses_nickname = form.data['uses_nickname'] if 'uses_nickname' in form.data else False
    extra_data.wants_newsletter = False
    extra_data.wants_newsletter = form.data['wants_newsletter'] if 'wants_newsletter' in form.data else False
    extra_data.location = Location.objects.get(pk=form.data['location']) if form.data['location'] != '' else None
    extra_data.description = form.data['description']
    extra_data.image = request.FILES['image'] if 'image' in request.FILES else None
    extra_data.save()