Exemple #1
0
def getQR(request, slug ):
    
    if request.user.is_authenticated(): 
        #comprovo que el ticket existeix i no l'ha fet servir ningú
        #TODO -> enviar a pantalla avís si no és vàlid
        
        try:
            qr = QR.objects.get_subclass( slug = slug )
        except QR.DoesNotExist:
            url = reverse( 'visitant:play_estat')
            messages.error(request, u'QR no vàlid!' )
            return HttpResponseRedirect( url  )
        
        #prenem el visitant
        visitant = hlp_visitant_checkUser( request.user )
        
        #assigno el codi al visitant       
        try: 
            qr.bind_to_owner( visitant )
            messages.success(request, u'QR capturat!' )
        except ValidationError, e:            
            for message in e.messages:
                messages.error(request, message )
        except IntegrityError:
            messages.error(request, u'Aquest QR ja havia estat capturat!' )
Exemple #2
0
def estat(request):
    
    visitant = None
    premis_actius = None
    plantilla = None
    collaboradors_actius = Collaborador.objects.all()
    qr_pendent_error = None
    
    if request.user.is_authenticated():

        visitant = hlp_visitant_checkUser( request.user )
        premis_actius = Premi.objects_actius.all()
        plantilla = 'play_estat_auth.html'

    else:
        visitant = None
        premis_actius = Premi.objects_actius.all()
        plantilla = 'play_estat_noauth.html'
    
    
    #mostro estat de l'usuari:
    return render_to_response( plantilla,
                               {'visitant': visitant,
                                'qr_pendent_error': qr_pendent_error,
                                'premis_actius': premis_actius,
                                'collaboradors_actius':collaboradors_actius,
                                },
                               context_instance=RequestContext(request))
Exemple #3
0
def index(request):
    if request.user.is_authenticated():
        
        hlp_visitant_checkUser( request.user )

        if hasattr(request.user, 'collaborador'):
            #collaborador
            url = reverse( 'collaborador:manage_estat')
            return HttpResponseRedirect( url  )

        #visitant
        url = reverse( 'visitant:play_estat')
        return HttpResponseRedirect( url  )

    #no autenticat
    return visitant_estat( request )                
Exemple #4
0
def premis(request):
    visitant = hlp_visitant_checkUser( request.user )

    #mostro estat de l'usuari:
    return render_to_response( 'play_premisitant.html',
                               {'visitant': visitant,
                                'qr_pendent_error': qr_pendent_error,
                                },
                               context_instance=RequestContext(request))
Exemple #5
0
def els_meus_qrs( request ):
    

    visitant = hlp_visitant_checkUser( request.user )   
    
    #q_clinex = Q( qrclinex__usat_per = visitant )
    #q_mosqueter = Q( qrmosqueter__qrmosqueter_visitant__visitant = visitant )    
    #elsMeusQRs = QR.objects.filter( q_clinex | q_mosqueter   ).select_subclasses()
    
    table = Tables2_CapturesVisitant( visitant.capturadeqr_set.order_by( '-capturat_amb_data' ) )
    RequestConfig(request, paginate={"klass":DiggPaginator , "per_page": 5}).configure(table)
    return render(request, 'table2.html', {'table': table})
Exemple #6
0
def getPremi(request, pk_premi ):
    
    visitant = hlp_visitant_checkUser( request.user )   
    
    #frmFact = modelform_factory( CapturaDePremi, fields = ('captures_qr', ) )
    premi = get_object_or_404( Premi, pk = pk_premi)
    
    captura = CapturaDePremi( premi = premi, visitant = visitant, codi_de_recollida = str(pk_premi) )  #TODO
    if request.method == 'POST':
        #frm = frmFact( request.POST, instance = captura )
        frm = getPremiForm( request.POST )
        frm.fields['captures_qr'].queryset = visitant.capturadeqr_set.filter( bescanviat_cache = False, caduca_dia__gte = date.today() )
        if frm.is_valid():
            try:
                #captura = frm.save( commit = False )
                premi.bind_to_owner( frm.cleaned_data["captures_qr"]  )
                url = reverse( 'visitant:play_estat' )
                messages.success(request, u'Premi capturat.')
                return HttpResponseRedirect( url )

            except ValidationError, e:
                frm._errors.setdefault(NON_FIELD_ERRORS, []).extend(  e.messages  )
Exemple #7
0
def afegir_qrs_pendents( request ):
    #si hi ha un qr pendent l'afegeixo:
    visitant = hlp_visitant_checkUser( request.user )
    qr_pendent_error = None
    qr_pendent = None
    slug_pendent =request.session.get( 'slug_pendent', None )
    if bool( slug_pendent ):
        try:
            qr_pendent = QR.objects.get_subclass( slug = slug_pendent )
        except QR.DoesNotExists:
            qr_pendent_error = u"Aquest QR ja s'ha fet servir ó està caducat." 

    if bool( qr_pendent ):
        try:
            qr_pendent.bind_to_owner( visitant )            
        except ValidationError:
            qr_pendent_error = u"Aquest QR ja s'ha fet servir ó està caducat."
        except IntegrityError:
            qr_pendent_error = u"Aquest QR ja s'ha fet servir."
        del request.session['slug_pendent']

    return qr_pendent_error
Exemple #8
0
def capturesDePremisList( request ):
    visitant = hlp_visitant_checkUser( request.user )   
    
    table = Tables2_CapturaDePremi( visitant.capturadepremi_set.order_by( 'data_max_recollida_cache' ) )
    RequestConfig(request, paginate={"klass":DiggPaginator , "per_page": 5}).configure(table)
    return render(request, 'table2.html', {'table': table})