Ejemplo n.º 1
0
def generate_codes(request):
    # ensure only admins...
    if request.user.has_module_perms('conference'):
        codes = []
    
        if request.method == 'POST':
            form = CodeGenerationForm(request.POST)
        
            if form.is_valid():
                start = form.cleaned_data['start'] 
                number = form.cleaned_data['number']
                type  = form.cleaned_data['type']
            
                # iterate through request codes, generating and saving to 
                # database if needed
                for i in range (start, start + number):
                    code = ConferenceCode(type=type, number=i)
                
                    code, created = ConferenceCode.objects.get_or_create(type=type, number=i, code=code.code)

                    if request.POST.get('action', None) == "void":
                        
                        code.expired = True
                        code.save()
                        codes.append("voided - " + code.code)
                    else:
                        codes.append(code.code)

                form = CodeGenerationForm()
        
        else:
            form = CodeGenerationForm()

        chapters = ChapterInfo.objects.all().order_by('chapter_name')
        
        """
        for c in chapters:
            l, created = LeadershipDaySpots.objects.get_or_create(chapter=c.network)
            used = ConferenceRegistration.objects.filter(submitted=True, cancelled=False, ldd_chapter=c.network)
            c.ldd = used.count()

        ldd = LeadershipDaySpots.objects.all()
        """
        
        return render_to_response('conference/codes.html',
                                  {'codes': codes,
                                   'form': form,
                                   'conf_codes': CONF_CODES,
                                   'conf_options': CONF_OPTIONS,
#                                   'room_choices': ROOM_CHOICES,
#                                   'ldd': ldd,
                                   'chapters': chapters
                                  },
                                  context_instance=RequestContext(request)
                                 )
    else:
        # we've gotten be more standard on whether we render a denied page,
        # or return HttpResponseForbidden - and, eventually, make the UI better
        # in either case.
        return render_to_response('denied.html', context_instance=RequestContext(request))
Ejemplo n.º 2
0
def generate_codes(request):
    # ensure only admins...
    if request.user.has_module_perms("conference"):
        codes = []

        if request.method == "POST":
            form = CodeGenerationForm(request.POST)

            if form.is_valid():
                start = form.cleaned_data["start"]
                number = form.cleaned_data["number"]
                type = form.cleaned_data["type"]

                # iterate through request codes, generating and saving to
                # database if needed
                for i in range(start, start + number):
                    code = ConferenceCode(type=type, number=i)

                    code, created = ConferenceCode.objects.get_or_create(type=type, number=i, code=code.code)

                    if request.POST.get("action", None) == "void":

                        code.expired = True
                        code.save()
                        codes.append("voided - " + code.code)
                    else:
                        codes.append(code.code)

                form = CodeGenerationForm()

        else:
            form = CodeGenerationForm()

        return render_to_response(
            "conference/codes.html",
            {
                "codes": codes,
                "form": form,
                "conf_codes": CONF_CODES,
                "conf_options": CONF_OPTIONS,
                "room_choices": ROOM_CHOICES,
            },
            context_instance=RequestContext(request),
        )
    else:
        # we've gotten be more standard on whether we render a denied page,
        # or return HttpResponseForbidden - and, eventually, make the UI better
        # in either case.
        return render_to_response("denied.html", context_instance=RequestContext(request))
Ejemplo n.º 3
0
def generate_codes(request):
    # ensure only admins...
    if request.user.has_module_perms('conference'):
        codes = []

        if request.method == 'POST':
            form = CodeGenerationForm(request.POST)

            if form.is_valid():
                start = form.cleaned_data['start']
                number = form.cleaned_data['number']
                type = form.cleaned_data['type']

                # iterate through request codes, generating and saving to
                # database if needed
                for i in range(start, start + number):
                    code = ConferenceCode(type=type, number=i)

                    code, created = ConferenceCode.objects.get_or_create(
                        type=type, number=i, code=code.code)

                    if request.POST.get('action', None) == "void":

                        code.expired = True
                        code.save()
                        codes.append("voided - " + code.code)
                    else:
                        codes.append(code.code)

                form = CodeGenerationForm()

        else:
            form = CodeGenerationForm()

        return render_to_response('conference/codes.html', {
            'codes': codes,
            'form': form,
            'conf_codes': CONF_CODES,
            'conf_options': CONF_OPTIONS,
            'room_choices': ROOM_CHOICES
        },
                                  context_instance=RequestContext(request))
    else:
        # we've gotten be more standard on whether we render a denied page,
        # or return HttpResponseForbidden - and, eventually, make the UI better
        # in either case.
        return render_to_response('denied.html',
                                  context_instance=RequestContext(request))
Ejemplo n.º 4
0
def lookup_code(request):
    if request.user.has_module_perms('conference'):
        if request.method == 'POST' and request.POST.get('code', None):
            code = get_object_or_none(ConferenceCode, code=request.POST['code'])
            
            if code and code.expired:
                return HttpResponse("voided")
            elif code:
                reg = ConferenceRegistration.objects.filter(code=code, cancelled=False)
                if reg.count():
                    return HttpResponse("used")
                else:
                    return HttpResponse("available")
            else:
                if ConferenceCode.isValid(request.POST['code']):
                    return HttpResponse("not issued")
                else:
                    return HttpResponse("invalid code")
    return HttpResponse("lookup error")
Ejemplo n.º 5
0
def lookup_code(request):
    if request.user.has_module_perms('conference'):
        if request.method == 'POST' and request.POST.get('code', None):
            code = get_object_or_none(ConferenceCode,
                                      code=request.POST['code'])

            if code and code.expired:
                return HttpResponse("voided")
            elif code:
                reg = ConferenceRegistration.objects.filter(code=code,
                                                            cancelled=False)
                if reg.count():
                    return HttpResponse("used")
                else:
                    return HttpResponse("available")
            else:
                if ConferenceCode.isValid(request.POST['code']):
                    return HttpResponse("not issued")
                else:
                    return HttpResponse("invalid code")
    return HttpResponse("lookup error")