Пример #1
0
 def get_context_data(self, **kwargs):
     context = super().get_context_data(**kwargs)
     members_insc = self.model.objects.filter(
         role__exact='', confirmed=True,
         session=Inscription.current_session()
     ).order_by('member__name', 'member__family_name')
     context['member_list'] = members_insc
     admin_insc = self.model.objects.exclude(role__exact='').filter(
         session=Inscription.current_session()
     ).order_by('role', 'member__name', 'member__family_name')
     context['admin_list'] = admin_insc
     return context
Пример #2
0
def inscription(request):
    if request.method == 'POST':
        try:
            member = Member.objects.get(email=request.POST['email'])
        except:
            member = Member()
        member_form = MemberForm(request.POST, instance=member)
        inscription_form = InscriptionForm(request.POST)
        if any(insc.is_current() for insc in Inscription.objects.filter(member=member)):
            info(request, 'Already inscripted on the current session!')
        elif member_form.is_valid() and inscription_form.is_valid():
            member = member_form.save()
            inscription = inscription_form.save(commit=False)
            inscription.member = member
            inscription.session = Inscription.current_session()
            inscription.save()
            success(request, 'Inscription created!')
        else:
            error(request, 'Error when creating inscription!')
    else:
        member_form = MemberForm()
        inscription_form = InscriptionForm()

    return render(request, 'inscription/index.html', {
        'member_form': member_form,
        'inscription_form': inscription_form,
    })
Пример #3
0
def inscription(request):
    if request.method == 'POST':
        try:
            member = Member.objects.get(email=request.POST['email'])
        except:
            member = Member()
        member_form = MemberForm(request.POST, instance=member)
        inscription_form = InscriptionForm(request.POST)
        if any(insc.is_current()
               for insc in Inscription.objects.filter(member=member)):
            info(request, 'Already inscripted on the current session!')
        elif member_form.is_valid() and inscription_form.is_valid():
            member = member_form.save()
            inscription = inscription_form.save(commit=False)
            inscription.member = member
            inscription.session = Inscription.current_session()
            inscription.save()
            success(request, 'Inscription created!')
        else:
            error(request, 'Error when creating inscription!')
    else:
        member_form = MemberForm()
        inscription_form = InscriptionForm()

    return render(request, 'inscription/index.html', {
        'member_form': member_form,
        'inscription_form': inscription_form,
    })
Пример #4
0
def register_list(request, event_id=None):
    registers = list(Register.objects.filter(event__id=event_id).order_by(
        'member__name'))
    event = registers[0] if len(registers) else get_object_or_404(Event,
                                                                  pk=event_id)
    others = list(Inscription.objects.filter(
        session=Inscription.current_session()).order_by('member__name'))
    registers_insc = [r.inscription for r in registers]
    others = [other for other in others if other not in registers_insc]
    return render(request, 'event/register_list.html', {
        'register_list': registers,
        'other_list': others,
        'event': event,
    })
Пример #5
0
def register_list(request, event_id=None):
    registers = list(Register.objects.filter(event__id=event_id).order_by(
        'member__name'))
    event = registers[0] if len(registers) else get_object_or_404(Event,
                                                                  pk=event_id)
    others = list(Inscription.objects.filter(
        session=Inscription.current_session()).order_by('member__name'))
    registers_insc = [r.inscription for r in registers]
    others = [other for other in others if other not in registers_insc]
    return render(request, 'event/register_list.html', {
        'register_list': registers,
        'other_list': others,
        'event': event,
    })
Пример #6
0
def register(request, event_id):
    event = get_object_or_404(Event, pk=event_id)
    if event.end and event.end < timezone.now():
        return render(request, 'event/ended.html', {'event': event})
    if request.method == 'POST':
        try:
            member = Member.objects.get(email=request.POST['email'])
        except:
            member = Member()
        member_form = MemberForm(request.POST, instance=member)
        inscription_form = InscriptionForm(request.POST)
        insc = [insc for insc in Inscription.objects.filter(member=member)
                if insc.is_current()]
        insc = insc[0] if len(insc) == 1 else None
        if not insc and member_form.is_valid() and inscription_form.is_valid():
            member = member_form.save()
            insc = inscription_form.save(commit=False)
            insc.member = member
            insc.session = Inscription.current_session()
            insc.save()
        if insc:
            try:
                Register.objects.create(member=member, event=event)
                success(request, 'You have successfully registered')
            except:
                info(request, 'You has already registred!')
        else:
            error(request, 'Error when registering!')
    else:
        member_form = MemberForm()
        inscription_form = InscriptionForm()

    return render(request, 'event/register.html', {
        'member_form': member_form,
        'inscription_form': inscription_form,
        'forms': [member_form, inscription_form],
        'event': event,
    })
Пример #7
0
def register(request, event_id):
    event = get_object_or_404(Event, pk=event_id)
    if event.end and event.end < timezone.now():
        return render(request, 'event/ended.html', {'event': event})
    if request.method == 'POST':
        try:
            member = Member.objects.get(email=request.POST['email'])
        except:
            member = Member()
        member_form = MemberForm(request.POST, instance=member)
        inscription_form = InscriptionForm(request.POST)
        insc = [insc for insc in Inscription.objects.filter(member=member)
                if insc.is_current()]
        insc = insc[0] if len(insc) == 1 else None
        if not insc and member_form.is_valid() and inscription_form.is_valid():
            member = member_form.save()
            insc = inscription_form.save(commit=False)
            insc.member = member
            insc.session = Inscription.current_session()
            insc.save()
        if insc:
            try:
                Register.objects.create(member=member, event=event)
                success(request, 'You have successfully registered')
            except:
                info(request, 'You has already registred!')
        else:
            error(request, 'Error when registering!')
    else:
        member_form = MemberForm()
        inscription_form = InscriptionForm()

    return render(request, 'event/register.html', {
        'member_form': member_form,
        'inscription_form': inscription_form,
        'forms': [member_form, inscription_form],
        'event': event,
    })