コード例 #1
0
    def create_event_registration(self, event_to_register_for=None):
        registration = EventRegistration()

        registration.member = Member.objects.order_by("?")[0]

        possible_event = (event_to_register_for if event_to_register_for else
                          self.get_event_to_register_for(registration.member))
        while not possible_event:
            self.stdout.write("No possible events to register for")
            self.stdout.write("Creating a new event")
            self.create_event()
            possible_event = self.get_event_to_register_for(
                registration.member)

        registration.event = possible_event

        registration.date = registration.event.registration_start

        registration.save()

        return registration
コード例 #2
0
ファイル: views.py プロジェクト: shahidhk/saarang_erp
def register(request,eventId):
    email = request.session.get('saaranguser_email')
    try:
        user = SaarangUser.objects.get(email=email)
    except:
        messages.error(request, 'Please login to continue')
        return render(request, 'main/login.html', {})
    event = get_object_or_404(Event,id=eventId)
    emailId = email
    #if user.activate_status == 1:
    #    messages.warning(request,'Please complete your profile to register for the event. Profile can be found by clicking your email at the bottom right corner.')
    #    return render(request, 'main/register_response.html')
    if event.is_team:
        return HttpResponseRedirect(reverse('list_teams',kwargs={'eventId':eventId,}))#,kwargs={'eventId':eventId,'teamId':teamId,}))
    else:
        if(EventRegistration.objects.filter(participant=user,event=event)):
            messages.info(request,'Already registered for the event.')
        else:
            if not event.registration_open:
                messages.info(request,'Registration is closed for the event.')
            else:
                if user.activate_status == 2 or user.activate_status == 1:
                    eventreg = EventRegistration()
                    eventreg.participant = user
                    eventreg.event = event
                    eventreg.options = ''
                    eventreg.save()
                    messages.success(request,'Registered successfully.')
                    mail.send(
                        [emailId], template='email/main/register_event',
                        context={'event_name':event.long_name, }
                        )
                #elif user.activate_status == 1:
                #    messages.warning(request,'Please complete your profile to register for the event.')
                else:
                    messages.warning(request,'Click on the activation mail sent to activate your profile.')

        return render(request, 'main/register_response.html')