def test2(request): p = Participant(name= request.POST['pid'], extype=2) # duplication problem try: p.save() except: return HttpResponse("Duplication Problem!") data={} data['pid'] = request.POST['pid'] return render_to_response("core/test2.html", data, context_instance=RequestContext(request))
def test1(request): p = Participant(name= request.POST['pid'], extype=1) # duplication problem try: p.save() except: return HttpResponse("Duplication Problem!") # how to collect the like_id # ajax data={} data['pid'] = request.POST['pid'] return render_to_response("core/test1.html", data, context_instance=RequestContext(request))
def view(request, id): event = Event.objects.all().get(pk=id) mail = None external = not request.user.email.endswith('@epita.fr') internals = User.objects.filter(email__endswith='@epita.fr') count = 0 participants = Participant.objects.filter(event=event) if external: participants = participants.exclude(user__in=internals) count = event.ext_capacity else: participants = participants.filter(user__in=internals) count = event.int_capacity if participants.filter( user__exact=request.user) or participants.count() == count: return redirect(reverse('core:my_events')) if request.user.is_authenticated: mail = request.user.email if "epita" in mail: event_price = event.int_price else: event_price = event.ext_price if request.method == 'POST': form = registration_form(request.POST) if form.is_valid(): participant = Participant() participant.mail = form.cleaned_data['mail'] participant.user = request.user participant.paid = event_price participant.event = event if event_price == 0: participant.save() return redirect(reverse('core:mail', args=[participant.id])) return render( request, 'payment.html', { 'form': form, 'id': id, 'event_price': event_price, 'event': event, 'participant': participant, 'PAYPAL_SANDBOX': PAYPAL_SANDBOX, 'PAYPAL_PRODUCTION': PAYPAL_PRODUCTION }) else: form = registration_form(initial={'mail': request.user.email}) return render(request, 'register.html', { 'form': form, 'id': id, 'event_price': event_price })
def mail(request): event_id = request.GET.get('event_id', None) member_id = request.GET.get('member_id', None) paid = request.GET.get('paid', None) email = request.GET.get('email', None) participant = Participant() participant.event = get_object_or_404(Event, id=event_id) participant.user = get_object_or_404(User, id=member_id) participant.paid = paid participant.mail = email participant.save() return redirect(reverse('core:mail', args=[participant.id]))
def create_participants(): """Create a fake participant, and optionally associated UDS and meds""" gender_list = list(Gender) race_list = list(Race) insurers = Insurer.objects.all() for _ in range(DEFAULT_NUMBER_PARTICIPANTS): last_four = fake.ssn(taxpayer_identification_number_type="SSN")[-4:] profile = fake.profile() gender = random.choice(gender_list) race = random.choice(race_list) participant = Participant( first_name=fake.first_name(), last_name=fake.last_name(), pp_id=fake.password( length=5, special_chars=False, digits=True, lower_case=False ), gender=gender.value, race=race.value, last_four_ssn=last_four, date_of_birth=profile["birthdate"], start_date=fake.date_time(), is_insured=random_bool(), insurer=random.choice(insurers), ) participant.full_clean() participant.save()
def create_participants(uds=True, medication=True): '''Create a fake participant, and optionally associated UDS and meds''' gender_list = list(Gender) race_list = list(Race) for _ in range(DEFAULT_NUMBER_PARTICIPANTS): last_four = fake.ssn(taxpayer_identification_number_type="SSN")[-4:] profile = fake.profile() gender = random.choice(gender_list) race = random.choice(race_list) participant = Participant( first_name=fake.first_name(), last_name=fake.last_name(), pp_id=fake.password(length=5, special_chars=False, digits=True, lower_case=False), gender=gender.value, race=race.value, last_four_ssn=last_four, date_of_birth=profile['birthdate'], start_date=fake.date_time(), ) participant.full_clean() participant.save() if uds: create_uds_results(participant) if medication: create_medication(participant)
def create_participants(): gender_list = list(Gender) race_list = list(Race) for _ in range(10): last_four = fake.ssn(taxpayer_identification_number_type="SSN")[-4:] profile = fake.profile() gender = random.choice(gender_list) race = random.choice(race_list) participant = Participant( first_name=fake.first_name(), last_name=fake.last_name(), pp_id="todo", gender=gender.value, race=race.value, last_four_ssn=last_four, date_of_birth=profile['birthdate'], start_date=fake.date_time(), ) participant.full_clean() participant.save() create_uds_results(participant) create_medication(participant)