Exemplo n.º 1
0
    def register(self, request, **cleaned_data):

        username, email, password = cleaned_data['username'], cleaned_data[
            'email'], cleaned_data['password1']
        if Site._meta.installed:
            site = Site.objects.get_current()
        else:
            site = RequestSite(request)

        user = RegistrationProfile.objects.create_inactive_user(
            username, email, password, site)
        user.first_name = cleaned_data.get('first_name')
        user.last_name = cleaned_data.get('last_name')
        user.save()

        signals.user_registered.send(sender=self.__class__,
                                     user=user,
                                     request=request)

        try:
            user.get_profile()
        except Profile.DoesNotExist:
            profile = Profile(
                user=user,
                phone=cleaned_data.get('phone', ''),
                organization=cleaned_data.get('organization', ''),
                is_a=cleaned_data.get('is_a', ''),
                interests=cleaned_data.get('interests', ''),
                notify=cleaned_data.get('notify'),
            )
            profile.save()

        return user
Exemplo n.º 2
0
    def register(self, request, **cleaned_data):

        username, email, password = cleaned_data['username'], cleaned_data['email'], cleaned_data['password1']
        if Site._meta.installed:
            site = Site.objects.get_current()
        else:
            site = RequestSite(request)

        user = RegistrationProfile.objects.create_inactive_user(username, email,
                                                                password, site)
        user.first_name = cleaned_data.get('first_name')
        user.last_name = cleaned_data.get('last_name')
        user.save()

        signals.user_registered.send(sender=self.__class__,
                                     user=user,
                                     request=request)

        try:
            user.get_profile()
        except Profile.DoesNotExist:
            profile = Profile(
                user=user,
                phone=cleaned_data.get('phone', ''),
                organization=cleaned_data.get('organization', ''),
                is_a=cleaned_data.get('is_a', ''),
                interests=cleaned_data.get('interests', ''),
                notify=cleaned_data.get('notify'),
            )
            profile.save()

        return user
Exemplo n.º 3
0
def create_profile(request, user=None, *args, **kwargs):

    settings = request.session.get('account_settings')

    if settings is not None and user is not None:

        try:

            user.get_profile()

        except Profile.DoesNotExist:

            profile = Profile(user=user,
                              phone=settings['phone'],
                              organization=settings['organization'],
                              is_a=settings['is_a'],
                              interests=settings['interests'],
                              notify=settings['notify'] or False)
            profile.save()
Exemplo n.º 4
0
def create_profile(request, user=None, *args, **kwargs):

	settings = request.session.get('account_settings')

	if settings is not None and user is not None:

		try:

			user.get_profile()

		except Profile.DoesNotExist:

			profile = Profile(
				user=user,
				phone=settings['phone'],
				organization=settings['organization'],
				is_a=settings['is_a'],
				interests=settings['interests'],
				notify=settings['notify'] or False
			)
			profile.save()
Exemplo n.º 5
0
    def form_valid(self, request, form):

        resp = super(RegisterPlusView, self).form_valid(request, form)

        try:
            user = User.objects.get(username=form.cleaned_data['username'])
            user.get_profile()
        except User.DoesNotExist:
            pass
        except Profile.DoesNotExist:
            profile = Profile(
                user=user,
                phone=form.cleaned_data.get('phone', ''),
                organization=form.cleaned_data.get('organization', ''),
                is_a=form.cleaned_data.get('is_a', ''),
                interests=form.cleaned_data.get('interests', ''),
                notify=form.cleaned_data.get('notify'),
            )
            profile.save()

        return resp