コード例 #1
0
ファイル: forms.py プロジェクト: jarshwah/footytipping
 def save(self):
     data = self.cleaned_data
     user = data['user']
     competition = data['competition']
     r = Registration(user=user, competition=competition)
     r.save()
     return r
コード例 #2
0
ファイル: views.py プロジェクト: shaond/whichone
def add_phone(request, phone):
    '''Adds a new phone to our list of users and sends a verification SMS.

    Args:
        phone: mobile phone number in the format - 00 area_code phone_number
        eg. 0061424387059

    Returns:
        JSON status, either 'ok' or 'fail'.

    Raises:
        None
    '''

    if request.method == 'GET':
        registration = Registration()
        registration.phone = phone
        registration.pin = generate_pin(4)[0]
        registration.save()

        if sendsms(phone, registration.pin):
            return HttpResponse(json.dumps('ok'), mimetype='application/json')
        else:
            return HttpResponse(json.dumps('fail'),
                    mimetype='application/json')
    else:
        return HttpResponse(json.dumps('fail'),
                mimetype='application/json')
コード例 #3
0
ファイル: views.py プロジェクト: nmasur/creationdex
def register(request):
	basic = get_basic(request)
	if request.method == 'POST':
		form = RegisterForm(request.POST)
		if form.is_valid():
			username = request.POST['username']
			password = request.POST['password1']
			email = request.POST['email']
			user = User.objects.create_user(username, email, password)
			user.is_active = False
			user.save()
			characters = string.ascii_uppercase + string.digits + string.ascii_lowercase
			confirmation_code = ''.join(random.choice(characters) for x in range(30))
			register = Registration(user=user, confirmation_code=confirmation_code)
			register.save()
			user = authenticate(username=username, password=password)
			if user.is_active:
				login(request, user)
				return HttpResponseRedirect('/editprofile/')
			else:
				send_registration_confirmation(user)
				return HttpResponseRedirect('/accounts/notverified?id=' + str(user.id))
	else:
		if basic:
			return HttpResponseRedirect('/')
		form = RegisterForm()
	return render(request, 'register.html', {'form': form, 'basic': basic})
コード例 #4
0
ファイル: test.py プロジェクト: ncb000gt/raid-scheduler
def make_test_registrations():
	raid = Raid.objects.all()[0]
	raid.registered.clear()
	raid.has_rolled = False
	for player in User.objects.all():
		registration = Registration(player=player,
					    raid=raid,
					    standby=not random.randrange(10),
					    role=['dps', 'tank', 'healer'][random.randrange(3)])
		registration.save()
	raid.save()
コード例 #5
0
ファイル: views.py プロジェクト: TamaraCopple/kcdc3
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")
コード例 #6
0
ファイル: views.py プロジェクト: albokhitan/kcdc3
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")
コード例 #7
0
def register_user(user_id, tournament_id):
    """
    Registers a user into a tournament
    :param user_id: Id of a user
    :param tournament_id: Id of a tournament
    :return: True if user is registered and false otherwise
    """

    the_tournament = Tournament.objects.get(id=tournament_id)
    if the_tournament.current_participants < the_tournament.max_participants:
        the_user = User.objects.get(id=user_id)

        reg = Registration()
        reg.user = the_user
        reg.tournament = the_tournament
        reg.save()

        return True
    else:
        return False
コード例 #8
0
    def on_id_selection(self, section_id):

        try:
            reg = Registration(section_id=section_id,
                               student_id=self.__student_id)

            if reg.save():

                section_name = get_section_name(section_id)

                if section_name:
                    self.__view.print_message(
                        f'Successfully registered {self.__student_name} for {section_name}.'
                    )
                else:
                    self.__view.print_message(
                        'Successfully registered for section.')
            else:
                self.__view.print_message(f'Failed to register for section.')
        except IntegrityError:
            self.__view.print_message('Unable to register for section.')