Ejemplo n.º 1
0
def add_developer(request):
    form = UserProfileForm()
    
    if request.method == 'POST':
        form = UserProfileForm(request.POST)
        if form.is_valid():
			#user_profile = form.save()
			data = form.cleaned_data
			site = Site.objects.get_current()
			new_user = RegistrationProfile.objects.create_inactive_user(data['username'] , data['email'],data['password'], site , send_email = False)
			userprofileobj = UserProfile(user = new_user, role_id=11, displayName = data['username'], thumbnailURL= '/static/main/img/user.png ')
			userprofileobj.save()

			s_admins = User.objects.filter(is_superuser = 1)
			for s_admin in s_admins:
				notify.send(new_user, recipient=s_admin, verb='signed_up' )

			return HttpResponseRedirect('/')
    


    return render(request, "userprofiles/registration.html", {
        'form': form, 
        'action' : 'Create'
    })
Ejemplo n.º 2
0
def add_user(request):
    form = UserProfileForm()
    user_formset = userProfileFormset(instance=RegistrationProfile())

    if request.method == 'POST':
        form = UserProfileForm(request.POST)
        if form.is_valid():
            #user_profile = form.save()
            data = form.cleaned_data
            site = Site.objects.get_current()
            new_user_instance = UserModel().objects.create_user(
                **form.cleaned_data)
            new_user = RegistrationProfile.objects.create_inactive_user(
                new_user=new_user_instance,
                site=site,
                send_email=False,
                request=request,
            )
            #new_user = RegistrationProfile.objects.create_inactive_user(data['username'] , data['email'],data['password'], site)
            #signals.user_registered.send(sender=self.__class__, user=new_user,request=request)
            user_formset = userProfileFormset(request.POST,
                                              request.FILES,
                                              instance=new_user_instance)

            if user_formset.is_valid():
                user_formset.save()
                return render(request,
                              "userprofiles/registration_complete.html", {})

    return render(request, "userprofiles/registration.html", {
        'form': form,
        'user_formset': user_formset,
        'action': 'Create'
    })
def add_user(request):
    form = UserProfileForm()
    user_formset = userProfileFormset(instance=RegistrationProfile())
    
    if request.method == 'POST':
        form = UserProfileForm(request.POST)
        if form.is_valid():
			#user_profile = form.save()
			data = form.cleaned_data
			site = Site.objects.get_current()
			new_user_instance = UserModel().objects.create_user(**form.cleaned_data)
			new_user = RegistrationProfile.objects.create_inactive_user(
				new_user=new_user_instance,
				site=site,
				send_email=False,
				request=request,
				)
			#new_user = RegistrationProfile.objects.create_inactive_user(data['username'] , data['email'],data['password'], site)
			#signals.user_registered.send(sender=self.__class__, user=new_user,request=request)
			user_formset = userProfileFormset(request.POST, request.FILES, instance=new_user_instance)

			if user_formset.is_valid():
				user_formset.save()
				return render(request, "userprofiles/registration_complete.html", {	
				})
    
    return render(request, "userprofiles/registration.html", {
        'form': form, 
        'user_formset': user_formset,
        'action' : 'Create'
    })
Ejemplo n.º 4
0
def edit_user_profile(request):
    if request.method == "POST":
        form = UserProfileForm(data=request.POST, instance=request.user.profile)
    else:
        form = UserProfileForm(instance=request.user.profile)

    if form.is_valid():
        form.save()
        return render(request, 'accounts/user_profile.html')
    else:
        print "This isn't right"
    return render(request, 'accounts/edit_profile.html', {"form": form})
Ejemplo n.º 5
0
Archivo: views.py Proyecto: ng/tbonline
def update_profile(request):
    if request.user.is_authenticated():
        if request.method == "POST":
            user_form = UserForm(request.POST,
                                 instance=request.user,)
            profile_form = UserProfileForm(request.POST,
                                           request.FILES,
                                           instance=request.user.userprofile)
            
            if user_form.is_valid() and profile_form.is_valid():
                user_form.save()
                profile_form.save()
        else:
            try:
                profile = request.user.userprofile
            except UserProfile.DoesNotExist:
                profile = UserProfile(user=request.user)
                profile.save()
                
        profile_form = UserProfileForm(instance=request.user.userprofile)
        user_form = UserForm(instance=request.user)

        context = {'user_form':user_form,
                   'profile_form':profile_form,
                   }
        return render_to_response('userprofiles/edit_profile.html',
                                  context,
                                  RequestContext(request))
def confirmcheckout(request, orderid):
    """
    Handle successful checkouts
    """
    save_info = request.session.get('save_info')
    order = get_object_or_404(Userorders, orderid=orderid)

    if request.user.is_authenticated:
        profile = UserProfile.objects.get(user=request.user)
        # Attach the user's profile to the order
        order.userprofile = profile
        order.save()

        # Save the user's info
        if save_info:
            profile_data = {
                'userphone': order.phone,
                'useraddress1': order.address1,
                'useraddress2': order.address2,
                'usertown': order.town,
                'usercounty': order.county,
                'userpostalcode': order.postalcode,
                'usercountry': order.country,
            }
            user_profile_form = UserProfileForm(profile_data, instance=profile)
            if user_profile_form.is_valid():
                user_profile_form.save()


    messages.success(request, f'\
        Order Successful. \
        A confirmation \
        email will be sent to {order.emailaddress}.')
    
  
    if 'basket' in request.session:
        del request.session['basket']

    template = 'checkout/confirmcheckout.html'
    context = {
        'order': order,
    }

    return render(request, template, context)
Ejemplo n.º 7
0
def edit_user_profile(request):
    if request.method == "POST":
        form = UserProfileForm(data=request.POST,
                               instance=request.user.profile)
    else:
        form = UserProfileForm(instance=request.user.profile)

    if form.is_valid():
        form.save()
        return render(request, 'accounts/user_profile.html')
    else:
        print "This isn't right"
    return render(request, 'accounts/edit_profile.html', {"form": form})
Ejemplo n.º 8
0
def register(request, event_id = None):
  profile = None
  registration = None
  request.session['user_registered'] = None
  event = get_event(event_id)
  request.session['event_id'] = event.id

  if request.session.has_key('login_email'):
    profile, registration = get_user_profile_registration(event, request.session['login_email'])
    if profile and registration:
      request.session['user_registered'] = "True"
      if registration.completed_exit_survey == "True":
        request.session['thank_you'] = "thanks"
  else:
    request.session['login_email'] = None

  login_form = LoginForm()
  logout_form = LogoutForm()
  register_event_form = RegisterEventForm()
  user_profile_form = UserProfileForm()

  if request.method == "POST":
    login_form = LoginForm(request.POST)
    logout_form = LogoutForm(request.POST)
    register_event_form = RegisterEventForm(request.POST)
    user_profile_form = UserProfileForm(request.POST)

    if user_profile_form.is_valid():
      if not user_profile_exists(user_profile_form.cleaned_data['email']):
        usr = user_profile_form.save(commit=False)
        usr.ip_address = request.META['REMOTE_ADDR']
        usr.save()
        login_user(request, user_profile_form.cleaned_data['email'])
        register_user_for_event(request, event, usr)
        return HttpResponseRedirect(reverse('event', args=[event_id]))
      else:
        # the user already exists
        # TO DO
        user_profile_form = UserProfileForm()
        pass
    elif login_form.is_valid():
      if user_profile_exists(login_form.cleaned_data['email']):
        login_user(request, login_form.cleaned_data['email'])
        #if is_first_redirect(request):
        #  return HttpResponseRedirect(reverse('register', args=[event_id, settings.REGISTRATION_MESSAGE]))
        #else:
        return HttpResponseRedirect(reverse('event', args=[event_id]))
      else:
        # Do Nothing (page will reload with no one logged in)
        login_form = LoginForm()
        logout_form = LogoutForm()
        pass
    elif logout_form.is_valid():
      logout_user(request)
      login_form = LoginForm()
      user_profile_form = UserProfileForm()
      register_event_form = RegisterEventForm()
    
    if user_is_logged_in(request):
      if register_event_form.is_valid():
        register_user_for_event(request, event, profile)
        return HttpResponseRedirect(reverse('event', args=[event_id]))

  context_data = {
    'event': event,
    'login_form': login_form,
    'logout_form': logout_form,
    'register_event_form': register_event_form,
    'user_profile_form': user_profile_form,
  }

  return render_to_response('register.html', context_data, context_instance = RequestContext(request))