Beispiel #1
0
def new_user_email_signup(request, location_slug=None):
	if not request.method == 'POST':
		return HttpResponseRedirect('/404')
	print request.POST

	location = get_location(location_slug)
	# create new user
	form = NewUserForm(request.POST)
	if form.is_valid():
		new_user = form.save()
		new_user.save()
		notifications = new_user.event_notifications
		notifications.location_weekly.add(location)
		notifications.save()

		password = request.POST.get('password1')
		new_user = authenticate(username=new_user.username, password=password)
		login(request, new_user)
		messages.add_message(request, messages.INFO, 'Thanks! We\'ll send you weekly event updates for this location. You can update your preferences at any time on your <a href="/people/%s">profile</a> page' % new_user.username)
		return HttpResponse(status=200)
	else:
		errors = json.dumps({"errors": form.errors})
		return HttpResponse(json.dumps(errors))

	return HttpResponse(status=500); 
Beispiel #2
0
def new_user_email_signup(request, location_slug=None):
    if not request.method == 'POST':
        return HttpResponseRedirect('/404')
    print request.POST

    location = get_location(location_slug)
    # create new user
    form = NewUserForm(request.POST)
    if form.is_valid():
        new_user = form.save()
        new_user.save()
        notifications = new_user.event_notifications
        notifications.location_weekly.add(location)
        notifications.save()

        password = request.POST.get('password1')
        new_user = authenticate(username=new_user.username, password=password)
        login(request, new_user)
        messages.add_message(
            request, messages.INFO,
            'Thanks! We\'ll send you weekly event updates for this location. You can update your preferences at any time on your <a href="/people/%s">profile</a> page'
            % new_user.username)
        return HttpResponse(status=200)
    else:
        errors = json.dumps({"errors": form.errors})
        return HttpResponse(json.dumps(errors))

    return HttpResponse(status=500)
Beispiel #3
0
def rsvp_new_user(request, event_id, event_slug, location_slug=None):
	location = get_object_or_404(Location, slug=location_slug)
	if not request.method == 'POST':
		return HttpResponseRedirect('/404')

	print 'in rsvp_new_user'
	print request.POST
	# get email signup info and remove from form, since we tacked this field on
	# but it's not part of the user model. 
	weekly_updates = request.POST.get('weekly-email-notifications')
	notify_new = request.POST.get('new-event-notifications')
	if weekly_updates == 'on':
		weekly_updates = True
	else:
		weekly_updates = False
	print 'weekly updates?'
	print weekly_updates
	if notify_new == 'on':
		notify_new = True
	else:
		notify_new = False

	# create new user
	form = NewUserForm(request.POST)
	if form.is_valid():
		new_user = form.save()
		new_user.save()
		notifications = new_user.event_notifications
		if weekly_updates:
			# since the signup was related to a specific location we assume
			# they wanted weekly emails about the same location
			notifications.location_weekly.add(location)
		if notify_new:
			# since the signup was related to a specific location we assume
			# they wanted weekly emails about the same location
			notifications.location_publish.add(location)
		notifications.save()

		password = request.POST.get('password1')
		new_user = authenticate(username=new_user.username, password=password)
		login(request, new_user)
		# RSVP new user to the event
		event = Event.objects.get(id=event_id)
		event.attendees.add(new_user)
		print (event.attendees.all())
		event.save()
		messages.add_message(request, messages.INFO, 'Thanks! Your account has been created. Check your email for login info and how to update your preferences.')
		return HttpResponse(status=200)
	else:
		errors = json.dumps({"errors": form.errors})
		return HttpResponse(json.dumps(errors))

	return HttpResponse(status=500); 
Beispiel #4
0
def rsvp_new_user(request, event_id, event_slug, location_slug=None):
    location = get_location(location_slug)
    if not request.method == 'POST':
        return HttpResponseRedirect('/404')

    print 'in rsvp_new_user'
    print request.POST
    # get email signup info and remove from form, since we tacked this field on
    # but it's not part of the user model.
    weekly_updates = request.POST.get('email-notifications')
    if weekly_updates == 'on':
        weekly_updates = True
    else:
        weekly_updates = False
    print 'weekly updates?'
    print weekly_updates

    # create new user
    form = NewUserForm(request.POST)
    if form.is_valid():
        new_user = form.save()
        new_user.save()
        notifications = new_user.event_notifications
        if weekly_updates:
            # since the signup was related to a specific location we assume
            # they wanted weekly emails about the same location
            notifications.location_weekly.add(location)
        notifications.save()

        password = request.POST.get('password1')
        new_user = authenticate(username=new_user.username, password=password)
        login(request, new_user)
        # RSVP new user to the event
        event = Event.objects.get(id=event_id)
        event.attendees.add(new_user)
        print(event.attendees.all())
        event.save()
        messages.add_message(
            request, messages.INFO,
            'Thanks! Your account has been created. Check your email for login info and how to update your preferences.'
        )
        return HttpResponse(status=200)
    else:
        errors = json.dumps({"errors": form.errors})
        return HttpResponse(json.dumps(errors))

    return HttpResponse(status=500)