Beispiel #1
0
def register(request, slug):

	e = Event.objects.get(slug=slug)
	u = request.user

	# if there are no non-cancelled registrations for this user/event and
	# registration is possible
	if (is_registered(u, e) == False and
		is_waitlisted(u, e) == False and
		e.is_registration_open() == True):
		# Since the event object will become aware of this registration
		# as soon as it saves, we need to cache the value. This might bite us?
		#
		# Check it:
		#
		# There's a class with a size of one with waitlist enabled. If
		# we save now the check to send the email will happen after the
		# class number gets counted and the waitlist email will be sent.
		waitlist_status = e.add_to_waitlist()
		t = Registration(student=u,
			event=e,
			date_registered=datetime.now(),
			waitlist=waitlist_status)
		t.save()

		# Email us with the needs of the student.
		if request.POST["student_needs"] != "":
			send_mail("(KCDC accommodation form) " + e.title,
				request.user.email+" requested the following: "+request.POST["student_needs"],
				request.user.email,
				["*****@*****.**"],
				fail_silently=False)

		if waitlist_status == False:
			send_registration_mail(e, 'registered', request.user.email)
			return HttpResponseRedirect("/classes/response/registered")
		else:
			send_registration_mail(e, 'waitlisted', request.user.email)
			return HttpResponseRedirect("/classes/response/waitlisted")

	else:
		return HttpResponseRedirect("/classes/response/error")
Beispiel #2
0
def register(request, slug):

    e = Event.objects.get(slug=slug)
    u = request.user

    # if there are no non-cancelled registrations for this user/event and
    # registration is possible
    if (is_registered(u, e) == False and is_waitlisted(u, e) == False
            and e.is_registration_open() == True):
        # Since the event object will become aware of this registration
        # as soon as it saves, we need to cache the value. This might bite us?
        #
        # Check it:
        #
        # There's a class with a size of one with waitlist enabled. If
        # we save now the check to send the email will happen after the
        # class number gets counted and the waitlist email will be sent.
        waitlist_status = e.add_to_waitlist()
        t = Registration(student=u,
                         event=e,
                         date_registered=datetime.now(),
                         waitlist=waitlist_status)
        t.save()

        # Email us with the needs of the student.
        if request.POST["student_needs"] != "":
            send_mail("(KCDC accommodation form) " + e.title,
                      request.user.email + " requested the following: " +
                      request.POST["student_needs"],
                      "*****@*****.**",
                      ["*****@*****.**"],
                      fail_silently=False)

        if waitlist_status == False:
            send_registration_mail(e, 'registered', request.user.email)
            return HttpResponseRedirect("/classes/response/registered")
        else:
            send_registration_mail(e, 'waitlisted', request.user.email)
            return HttpResponseRedirect("/classes/response/waitlisted")

    else:
        return HttpResponseRedirect("/classes/response/error")
Beispiel #3
0
def cancel(request, slug):

    e = Event.objects.get(slug=slug)

    if not is_cancelled(request.user, e) and (is_registered(request.user, e) or
                                              is_waitlisted(request.user, e)):
        # Gotta cache again... There's gotta be another way
        # to do this, this makes me feel gross.
        add_to_waitlist = e.add_to_waitlist()
        student_is_waitlisted = is_waitlisted(request.user, e)

        cancel_registration(request.user, e)
        if (add_to_waitlist == True and e.waitlist_status == True
                and not student_is_waitlisted and e.waitlist_count() > 0):
            student = promote_waitlistee(e)
            send_registration_mail(e, 'promoted', student.email)
        send_registration_mail(e, 'cancelled', request.user.email)
        return HttpResponseRedirect("/classes/response/cancelled")
    else:
        return HttpResponseRedirect("/classes/response/error")
Beispiel #4
0
def cancel(request, slug):

	e = Event.objects.get(slug=slug)

	if not is_cancelled(request.user, e) and (is_registered(request.user, e) or is_waitlisted(request.user, e)):
		# Gotta cache again... There's gotta be another way
		# to do this, this makes me feel gross.
		add_to_waitlist = e.add_to_waitlist()
		student_is_waitlisted = is_waitlisted(request.user, e)

		cancel_registration(request.user, e)
		if (add_to_waitlist == True and
			e.waitlist_status == True and
			not student_is_waitlisted and
			e.waitlist_count() > 0):
			student = promote_waitlistee(e)
			send_registration_mail(e, 'promoted', student.email)
		send_registration_mail(e, 'cancelled', request.user.email)
		return HttpResponseRedirect("/classes/response/cancelled")
	else:
		return HttpResponseRedirect("/classes/response/error")