コード例 #1
0
ファイル: views.py プロジェクト: ProjektZpi/Zpi
def join_json(request):  
#Zapisywanie do bazy
    user= request.user
    event_id=request.POST.get('event_id')
    event = Event.objects.get(id=event_id)
    calendar=Calendar(user=user, event=event)
    calendar.save()


    to_json = {
               
               }
    json = simplejson.dumps(to_json);

   #odswiezenie statystyk
    update_statistic = update(event_id)
    
    return HttpResponse(json, mimetype='application/json')
コード例 #2
0
ファイル: views.py プロジェクト: ProjektZpi/Zpi
def add_feedback_json(request):


    #Zapisywanie do bazy
        user= request.user
        event_id=request.POST.get('event_id')
        event = Event.objects.get(id=event_id)
        atmosphere=request.POST.get('atmosphere')
        organisation=request.POST.get('organisation')
        if atmosphere==None:
            atmosphere=0
        if organisation==None:
            organisation=0
        event_feedbacks=EventFeedback(user=user, event=event, atmosphere=atmosphere, organisation=organisation)
        event_feedbacks.save()


         
       #odświeżanie statystyk
       
        event_to_feedback = Event.objects.get(id=event_id)
        atmosphere=EventFeedback.objects.filter(event=event_to_feedback).aggregate(Avg('atmosphere'))
        organisation=EventFeedback.objects.filter(event=event_to_feedback).aggregate(Avg('organisation'))
        
       
        
        if atmosphere["atmosphere__avg"]==None:     
            atmosphere_number="Brak oceny"
            atmosphere_avg=""
        else:
            atmosphere_number=atmosphere["atmosphere__avg"]
            atmosphere_avg=" \n"
        
            atmosphere_counter=0
            for i in range(int(atmosphere["atmosphere__avg"]*4-1)):
                    atmosphere_avg+="<input type='radio' class='star {split:4}' name='atmosphere_star' disabled='disabled'/> \n"
                    atmosphere_counter=atmosphere_counter+1
            atmosphere_avg+="<input type='radio' class='star {split:4}' name='atmosphere_star'  disabled='disabled' checked='checked'/> \n"
            atmosphere_counter=atmosphere_counter+1
            for i in range(int(20-(atmosphere["atmosphere__avg"]*4))):
                 if atmosphere_counter<20:  
                    atmosphere_avg+="<input type='radio' class='star {split:4}' name='atmosphere_star'  disabled='disabled'/> \n"
                    atmosphere_counter=atmosphere_counter+1
           
                    
        if organisation["organisation__avg"]==None:     
            organisation_number="Brak oceny"
            organisation_avg=""
        else:    
            organisation_number=organisation["organisation__avg"]
            organisation_avg=" \n"
            organisation_counter=0
            for i in range(int(organisation["organisation__avg"]*4-1)):
                    organisation_avg+="<input type='radio' class='star {split:4}' name='organisation_star' disabled='disabled'/> \n"
                    organisation_counter=organisation_counter+1
            organisation_avg+="<input type='radio' class='star {split:4}' name='organisation_star'  disabled='disabled' checked='checked'/> \n"
            organisation_counter=organisation_counter+1
            for i in range(int(20-(organisation["organisation__avg"]*4))):
                    if organisation_counter<20:
                        organisation_avg+="<input type='radio' class='star {split:4}' name='organisation_star'  disabled='disabled'/> \n"
                        organisation_counter=organisation_counter+1  
              
            to_json = {
                       "info":"Ocena została dodana",
                       "atmosphere_number":atmosphere_number,
                       "atmosphere_avg":atmosphere_avg,
                        "organisation_number":organisation_number,
                       "organisation_avg": organisation_avg
                       }
            json = simplejson.dumps(to_json);
            
            #odświeżenie statystyk autora
            update_statistic = update(event_id)
            
            
            return HttpResponse(json, mimetype='application/json')