def get(self, request, *args, **kwargs):
        meetingid = 0
        arit = 0
        respData = {"users":[], "extra":""}
        
        try:
            meetingid = int(kwargs['pk'])
        except:
            pass
        
        clubid = 0
        if 'c_pk' in  kwargs:
            clubid = int(kwargs['c_pk'])
        if not MeetingUtil.validateClubMeetingPermission(request, clubid, meetingid):
            return Response({"msg":"club-meeting no matching"}, status=status.HTTP_400_BAD_REQUEST)
        
        extra = self.get_extra_ar(request, clubid, meetingid)
        if extra:
            respData["extra"] = extra
            
        if request.GET.get("arit"):
            try:
                arit = int(request.GET.get("arit"))
            except:
                pass

        arids = self.get_ars(request,clubid,meetingid,arit)
        if len(arids) > 0:
            respData["users"] = arids
            return Response(respData)
        
        return Response(respData)
    def post(self, request, *args, **kwargs):
        respData = {}        
        
        try:
            meetingid = int(kwargs['m_pk'])
            clubid = 0
            if 'c_pk' in  kwargs:
                clubid = int(kwargs['c_pk'])
            if not MeetingUtil.validateClubMeetingPermission(request, clubid, meetingid):
                return Response({"msg":"club-meeting no matching"}, status=status.HTTP_400_BAD_REQUEST)      
            pk = int(kwargs['pk'])
            
            status = int(request.DATA["status"])
            if pk is 0:
                items = VoteItem.objects.filter(meeting_id__exact=meetingid)
                for item in items:
                    item.status=status
                    item.save()
                respData["code"] = "ok"
                return Response(respData)
            else:
                item = VoteItem.objects.get(id__exact=pk)
                item.status=status
                item.save()
                respData["code"] = "ok"
                return Response(respData)
            
        except:
            pass


        return Response(respData,status=status.HTTP_400_BAD_REQUEST)
    def get(self, request, *args, **kwargs):
        respData = {}
        
        try:
            mid = int(kwargs['pk'])
            clubid = 0
            if 'c_pk' in  kwargs:
                clubid = int(kwargs['c_pk'])
            if not MeetingUtil.validateClubMeetingPermission(request, clubid, 0):
                return Response({"msg":"club-meeting no matching"}, status=status.HTTP_400_BAD_REQUEST)
        except:
            pass

        if mid == 0:
            rankings = RoleLiker.objects.select_related().values('liker_roleTaken').filter(like__exact=1).annotate(total=Count('roleTaken')).order_by('-total')
        else:
            rankings = RoleLiker.objects.select_related().values('liker_roleTaken').filter(meeting_id__exact=mid,like__exact=1).annotate(total=Count('roleTaken')).order_by('-total')
            
        for ranking in rankings:
            roleTaken = RoleTaken.objects.get(id__exact=ranking["roleTaken"])
            ranking["title"] = roleTaken.title
            ranking["name"] = roleTaken.ownerName()
            
        data_dict = self.ValuesQuerySetToDict(rankings)
        str_json = simplejson.dumps(data_dict)
        data_json = simplejson.loads(str_json)
        respData["ranking"] = data_json
        
        return Response(respData) 
    def post(self, request, *args, **kwargs):
        respData = {}                
        try:
            meetingid = int(kwargs['m_pk'])
            clubid = 0
            if 'c_pk' in  kwargs:
                clubid = int(kwargs['c_pk'])
            if not MeetingUtil.validateClubMeetingPermission(request, clubid, meetingid):
                return Response({"msg":"club-meeting no matching"}, status=status.HTTP_400_BAD_REQUEST)      
            pk = int(kwargs['pk'])
            
            optionid = int(request.DATA["option"])
            myvote = self.get_vote_existing(pk, request.user.id)
            if myvote is not None:
                if myvote.option.id != optionid:
                    myvote.option = VoteOption.objects.get(id__exact=optionid)
                    myvote.save();
                    respData["code"] = "ok"
                else:
                    respData["code"] = "ok"
                    respData["msg"] = "already voted"
                return Response(respData)
            else:
                myvote = Vote()
                myvote.item = VoteItem.objects.get(id__exact=pk)
                myvote.option = VoteOption.objects.get(id__exact=optionid)
                myvote.voter = Person.objects.get(id__exact=request.user.id)
                myvote.save()
                respData["code"] = "ok"
                return Response(respData)
        except:
            pass

        return Response(respData,status=status.HTTP_400_BAD_REQUEST)
 def get(self, request, *args, **kwargs):
     pk = kwargs['pk']
     clubid = 0
     if 'c_pk' in  kwargs:
         clubid = int(kwargs['c_pk'])
     if not MeetingUtil.validateClubMeetingPermission(request, clubid, pk):
         return Response({"club-meeting no matching"}, status=status.HTTP_400_BAD_REQUEST)
     roleTaken = self.get_object(pk)
     serializer = RoleTakenNormalSerializer(roleTaken)
     return Response(serializer.data)
    def get(self, request, *args, **kwargs):
        respData = {}
        
        try:
            meetingid = int(kwargs['m_pk'])
            clubid = 0
            if 'c_pk' in  kwargs:
                clubid = int(kwargs['c_pk'])
            if not MeetingUtil.validateClubMeetingPermission(request, clubid, meetingid):
                return Response({"msg":"club-meeting no matching"}, status=status.HTTP_400_BAD_REQUEST)
            pk = int(kwargs['pk'])
            
            results = []
            if pk is 0:
                items = VoteItem.objects.filter(meeting_id__exact=meetingid)
                for item in items:
                    rankings = Vote.objects.select_related().values('option').filter(item_id__exact=item.id).annotate(total=Count('option')).order_by('-total')
                    for ranking in rankings:
                        option = VoteOption.objects.get(id__exact=ranking["option"])
                        ranking["name"] = option.name
                        ranking["desc"] = option.desc
                    data_dict = self.ValuesQuerySetToDict(rankings)
                    str_json = simplejson.dumps(data_dict)
                    data_json = simplejson.loads(str_json)
                    itemSerializer = VoteItemSerializer(item, many=False)
                    itemjson = itemSerializer.data
                    itemjson["ranking"] = data_json
                    results.append(itemjson)
            else:
                rankings = Vote.objects.select_related().values('option').filter(item_id__exact=pk).annotate(total=Count('option')).order_by('-total')
                item = VoteItem.objects.get(id__exact=pk)
                itemSerializer = VoteItemSerializer(item, many=False)
                itemjson = itemSerializer.data
                for ranking in rankings:
                    option = VoteOption.objects.get(id__exact=ranking["option"])
                    ranking["name"] = option.name
                    ranking["desc"] = option.desc
                data_dict = self.ValuesQuerySetToDict(rankings)
                str_json = simplejson.dumps(data_dict)
                data_json = simplejson.loads(str_json)
                itemjson["ranking"]=data_json
                results.append(itemjson)
            respData["items"] = results

            return Response(respData)
            
        except:
            pass
        
        return Response(respData, status=status.HTTP_400_BAD_REQUEST)
 def get(self, request, *args, **kwargs):
     respData = {} 
     pk = kwargs['pk']
     clubid = 0
     if 'c_pk' in  kwargs:
         clubid = int(kwargs['c_pk'])
     if not MeetingUtil.validateClubMeetingPermission(request, clubid, pk):
         respData["msg"] = "Club-Meeting not matching"
         return Response(respData, status=status.HTTP_400_BAD_REQUEST)
     meeting = self.get_meeting_object(pk)
     if meeting:
         if meeting.rt_meeting:
             serializer = RoleTakenNormalSerializer(meeting.rt_meeting.all(), many=True)
             respData = serializer.data
             
         return Response(respData)
     else:
         return Response(respData, status=status.HTTP_400_BAD_REQUEST)
    def post(self, request, *args, **kwargs):
        meetingid = 0
        action = 99999
        respData = {"code":"Attendance vote error!"}        
        
        try:
            meetingid = int(kwargs['pk'])
            action = int(request.GET.get("action"))
        except:
            pass
        
        clubid = 0
        if 'c_pk' in  kwargs:
            clubid = int(kwargs['c_pk'])
        if not MeetingUtil.validateClubMeetingPermission(request, clubid, meetingid):
            return Response({"msg":"club-meeting no matching"}, status=status.HTTP_400_BAD_REQUEST)

        if action == 1:
            if self.get_av_existing(request, clubid, meetingid)==False:
                requestDATA = {}
                requestDATA["owner"] = request.user.id
                requestDATA["meeting"] = meetingid
                requestDATA["av"] = True
                
                serializer = AddMeetingAvSerializer(data=requestDATA)
                if serializer.is_valid():
                    serializer.save()
                    respData["code"] = "ok"
                    return Response(respData)
                
                return Response(respData,status=status.HTTP_400_BAD_REQUEST)
            else:
                respData["code"] = "ok"
                return Response(respData)
        
        elif action == 0:
            self.delete_av(request,clubid,meetingid)
            respData["code"] = "ok"
            return Response(respData)
        
        else:
            return Response(respData,status=status.HTTP_400_BAD_REQUEST)
    def get(self, request, *args, **kwargs):
        respData = {"stats":[]}
        aid = 0
        
        try:
            roleid = int(kwargs['pk'])
            meetingid = int(kwargs['m_pk'])
            clubid = 0
            if 'c_pk' in  kwargs:
                clubid = int(kwargs['c_pk'])
            if not MeetingUtil.validateClubMeetingPermission(request, clubid, meetingid):
                return Response({"msg":"club-meeting no matching"}, status=status.HTTP_400_BAD_REQUEST)
            aid = int(request.GET.get("aid"))
        except:
            pass

        stats = self.get_stats(request,meetingid,aid,roleid)
        respData["stats"] = stats
        
        return Response(respData) 
Exemplo n.º 10
0
    def get(self, request, *args, **kwargs):
        respData = {}
        
        try:
            meetingid = int(kwargs['m_pk'])
            clubid = 0
            if 'c_pk' in  kwargs:
                clubid = int(kwargs['c_pk'])
            if not MeetingUtil.validateClubMeetingPermission(request, clubid, meetingid):
                return Response({"msg":"club-meeting no matching"}, status=status.HTTP_400_BAD_REQUEST)
            
            meeting = self.get_meeting_object(meetingid)
            if meeting and meeting.voteitem_meeting:
                serializer = VoteItemFullSerializer(meeting.voteitem_meeting.all(), many=True)
                respData["mid"] = meeting.id
                respData["items"] = serializer.data
                return Response(respData)
            else:
                return Response(respData, status=status.HTTP_400_BAD_REQUEST)
        except:
            pass

        return Response(respData, status=status.HTTP_400_BAD_REQUEST)
 def post(self, request, *args, **kwargs):
     # update meeting request which is from web 
     respData = {"meetingid":0,"msg":"","refresh":False,"nversion":0}
     pk = 0
     
     try:
         pk = kwargs['pk']
         clubid = 0
         if 'c_pk' in  kwargs:
             clubid = int(kwargs['c_pk'])
     except:
         respData["meetingid"] = 0
         respData["msg"] = "Meeting id is invalid!"
         return Response(respData, status=status.HTTP_400_BAD_REQUEST)     
     
     if not MeetingUtil.validateClubMeetingPermission(request, clubid, pk):
         respData["msg"] = "Club-Meeting not matching"
         return Response({respData}, status=status.HTTP_400_BAD_REQUEST)   
     
     (validate,errcode) = self.validate_post_data(request)
     
     if validate:
         (meetingid,ecode,refresh,nversion) = MeetingUtil.updateMeeting(pk,request,clubid)        
         if meetingid != 0:
             respData["meetingid"] = meetingid
             respData["msg"] = ecode
             respData["nversion"] = nversion
             return Response(respData)
         else:
             respData["meetingid"] = meetingid
             respData["msg"] = ecode
             respData["refresh"] = refresh
             return Response(respData,status=status.HTTP_400_BAD_REQUEST)
     else:
         respData["meetingid"] = 0
         respData["msg"] = errcode
         return Response(respData, status=status.HTTP_400_BAD_REQUEST)
Exemplo n.º 12
0
    def post(self, request, *args, **kwargs):
        respData = {}
        items = request.DATA["items"]
        try:
            meetingid = int(kwargs['m_pk'])
            clubid = 0
            if 'c_pk' in  kwargs:
                clubid = int(kwargs['c_pk'])
            if not MeetingUtil.validateClubMeetingPermission(request, clubid, meetingid):
                return Response({"msg":"club-meeting no matching"}, status=status.HTTP_400_BAD_REQUEST)
            with transaction.commit_on_success():
                VoteItem.objects.filter(meeting_id__exact=meetingid).delete()
                items = request.DATA["items"]
                for item in items:
                    newItem = VoteItem()
                    newItem.meeting = Meeting.objects.get(id__exact=meetingid)
                    newItem.seq = int(item["seq"])
                    newItem.type = int(item["type"])
                    newItem.status = int(item["status"])
                    newItem.title = item["title"]
                    newItem.save()
                    options = item["options"]
                    for option in options:
                        newOption = VoteOption()
                        newOption.item = newItem
                        uid = int(option["owner"])
                        if(uid!=0):
                            newOption.owner = Person.objects.get(id__exact=uid)
                        newOption.name = option["name"]
                        newOption.desc = option["desc"]
                        newOption.save()

            respData["code"] = "ok"
            return Response(respData)
        except:
            pass
        return Response(respData,status=status.HTTP_400_BAD_REQUEST)
 def post(self, request, *args, **kwargs):
     # update meeting request which is from web
     respData = {"meetingid":0,"msg":""}
     pk = 0
     clubid = 0
     if 'c_pk' in  kwargs:
         clubid = int(kwargs['c_pk'])
     mstatus = 0
     
     try:
         pk = int(kwargs['pk'])
     except:
         respData["meetingid"] = 0
         respData["msg"] = "Meeting id is invalid!"
         return Response(respData, status=status.HTTP_400_BAD_REQUEST)
     
     if not MeetingUtil.validateClubMeetingPermission(request, clubid, pk):
         respData["msg"] = "Club-Meeting not matching"
         return Response(respData, status=status.HTTP_400_BAD_REQUEST)   
         
     if request.GET.get("s"):
         try:
             mstatus = int(request.GET.get("s"))
         except:
             pass
     
     meetingid = MeetingUtil.changeMeetingStatus(request,pk,mstatus)
 
     if meetingid != 0:
         respData["meetingid"] = meetingid
         respData["msg"] = "Meeting {} is updated successfully!".format(meetingid)
         return Response(respData)
     else:
         respData["meetingid"] = meetingid
         respData["msg"] = "Meeting doesn't exist or status is invalid!"
         return Response(respData,status=status.HTTP_400_BAD_REQUEST)
    def post(self, request, *args, **kwargs):
        roleid = 0
        respData = {"code":"comment error!"}        
        
        try:
            meetingid = int(kwargs['m_pk'])
            roleid = int(kwargs['pk'])
            clubid = 0
            if 'c_pk' in  kwargs:
                clubid = int(kwargs['c_pk'])
            if not MeetingUtil.validateClubMeetingPermission(request, clubid, meetingid):
                return Response({"msg":"club-meeting no matching"}, status=status.HTTP_400_BAD_REQUEST)
        except:
            pass
        
        evaluateeRole = RoleTaken.objects.get(id__exact = roleid)
        receiver = Person.objects.get(id__exact = evaluateeRole.ownerid)
        sender = Person.objects.get(id__exact = request.user.id)        
        try:
            msgfname = sender.displayname
        except:
            msgfname = sender.username        
        messageid = MessageUtil.sendFriendConversation(sender.id, msgfname, receiver.id, request.DATA["msg"])
                    
        request.DATA["meeting"] = meetingid
        request.DATA["roleTaken"] = roleid
        request.DATA["evaluator"] = request.user.id
        request.DATA["message"] = messageid
        
        serializer = RoleCommentSerializer(data=request.DATA)

        if serializer.is_valid():
            serializer.save()
            respData["code"] = "ok"
            return Response(respData)
        return Response(respData,status=status.HTTP_400_BAD_REQUEST)
    def post(self, request, *args, **kwargs):
        respData = {"err":""}
        action = 99999
        pk = kwargs['pk']
        clubid = 0
        meetingid=0
        if 'c_pk' in  kwargs:
            clubid = int(kwargs['c_pk'])
        if 'm_pk' in  kwargs:
            meetingid = int(kwargs['m_pk'])
        if not MeetingUtil.validateClubMeetingPermission(request, clubid, meetingid):
            respData['err'] = "club-meeting no matching"
            return Response(respData, status=status.HTTP_400_BAD_REQUEST)
        
        try:
            action = int(request.GET.get("action"))
        except:
            pass

        ##############temp code for authentication testing AnonymousUser
        
        #if isinstance(request.user,AnonymousUser):
        #    request.user = Person.objects.get(pk=1)
        #############################
        if action == 1:
            roleTaken = self.get_object(pk)
            
            if roleTaken.roletype == RoleEnum.CustomAll:
                respData['err'] = "Sorry, this role is not allowed to be taken."
                return Response(respData, status=status.HTTP_400_BAD_REQUEST)            
            
            #################################################
            if "userid" in request.DATA and request.DATA["userid"] > 0:
                request.DATA["owner"] = request.DATA["userid"]
            else:
                request.DATA["owner"] = request.user.id
            
            #---------conflicts while mult-persons try to take the same role with mobile/web---------
            if roleTaken.owner:
                if roleTaken.owner.id != request.DATA["owner"]:
                    respData['err'] = "Sorry, this role has been taken by {}.".format(roleTaken.name)
                    return Response(respData, status=status.HTTP_400_BAD_REQUEST)
            #------------------------------------------------------
                
            if roleTaken.roletype != RoleEnum.Speaker and "ctask" in request.DATA:
                del(request.DATA["ctask"])
                
            if roleTaken.roletype != RoleEnum.Speaker and roleTaken.roletype != RoleEnum.IE \
            and roleTaken.roletype != RoleEnum.TTM and roleTaken.roletype != RoleEnum.TTE \
            and roleTaken.roletype != RoleEnum.Workshop and roleTaken.roletype != RoleEnum.CustomWithTitle:
                del(request.DATA["title"])
            
            if roleTaken.roletype == RoleEnum.IE:
                if "ltask" not in request.DATA:
                    request.DATA["ltask"]=roleTaken.ltask                  

            if self.preValidateTask(roleTaken,request) == False:
                respData['err'] = "Invalid task"
                return Response(respData, status=status.HTTP_400_BAD_REQUEST)
            
            #################################################
            
            serializer = RoleTakenUpdSerializer(roleTaken, data=request.DATA)
            if serializer.is_valid():
                serializer.save()
                self.postProcessToRelatedRoles(serializer.object)
                self.postProcessToActivity(serializer.object)
                self.postProcessToAttendance(serializer.object)
                
                del(serializer.data["owner"])
                serializer.data["userid"] = roleTaken.userid
                serializer.data["name"] = roleTaken.name                
                return Response(serializer.data)
            
            respData['err'] = serializer.errors
            return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
        elif action == 0:
            roleTaken = self.get_object(pk)
            
            #################################################
            resetDATA = {}
            
            #---------conflicts while mult-persons try to take the same role with mobile/web---------
            if roleTaken.owner and roleTaken.owner.id != request.user.id:
                respData['err'] = "Sorry, this role has been taken by {}.".format(roleTaken.name)
                return Response(respData, status=status.HTTP_400_BAD_REQUEST)
            #------------------------------------------------------
            
            #handle title, Speaker/TTM/Workshop/CustomWithTitle are required
            if roleTaken.roletype == RoleEnum.Speaker or roleTaken.roletype == RoleEnum.TTM \
            or roleTaken.roletype == RoleEnum.Workshop or roleTaken.roletype == RoleEnum.CustomWithTitle:
                resetDATA["title"] = roleTaken.title.split(":")[0]+":"
            else:
                resetDATA["title"] = roleTaken.title
                
            #handle duration
            
                
            resetDATA["ctask"] = ""
            resetDATA["ltask"] = ""
            resetDATA["owner"] = None
            #################################################
            
            serializer = RoleTakenUpdSerializer(roleTaken, data=resetDATA)
            if serializer.is_valid():
                serializer.save()
                self.postProcessToRelatedRoles(serializer.object)
                self.postProcessToActivity(serializer.object)
                
                del(serializer.data["owner"])
                serializer.data["userid"] = 0
                serializer.data["name"] = ""
                
                return Response(serializer.data)
            
            respData['err'] = serializer.errors
            return Response(respData, status=status.HTTP_400_BAD_REQUEST)
            pass
        else:
            respData['err'] = "Invalid Action"
            return Response(status=status.HTTP_400_BAD_REQUEST)
    def post(self, request, *args, **kwargs):           
        meetingid = 0
        respData = {"code":"Attendance Record Error!"}        
        
        try:
            meetingid = int(kwargs['pk'])
        except:
            pass
        
        clubid = 0
        if 'c_pk' in  kwargs:
            clubid = int(kwargs['c_pk'])
        if not MeetingUtil.validateClubMeetingPermission(request, clubid, meetingid):
            return Response({"msg":"club-meeting no matching"}, status=status.HTTP_400_BAD_REQUEST)
        
        #we don't need such auto meeting mapping here
        if meetingid == 0:
            return Response(respData,status=status.HTTP_400_BAD_REQUEST)            
        
        try:
            mtg = Meeting.objects.get(id__exact=meetingid)
            if "extra" in request.DATA and request.DATA["extra"] :
                mtg.extraattd = request.DATA["extra"]
                mtg.save_nover()  # not changing meeting info. dont update version
            elif mtg.extraattd:
                mtg.extraattd = ""
                mtg.save_nover()  # not changing meeting info. dont update version
        except:
            pass
            
        if "users" in request.DATA:
            if len(request.DATA["users"]) > 0:
                errorIndication = False
                
                #pre handling: reset all ars to false of this meeting 
                self.reset_ars(meetingid)
                
                for userid in request.DATA["users"]:
                    serializer = None
                    requestDATA = {}
                    requestDATA["owner"] = userid
                    requestDATA["meeting"] = meetingid
                    requestDATA["ar"] = True
                    
                    ar = self.get_ar(meetingid,userid)
                    if ar:
                        serializer = AddMeetingArSerializer(ar,data=requestDATA)
                    else:
                        serializer = AddMeetingArSerializer(data=requestDATA)
                        
                    if serializer.is_valid():
                        serializer.save()
                    else:
                        errorIndication = True
                        
                #post handling: delete all ar&av with False
                self.clear_ars(meetingid)
                        
                if errorIndication == False:
                    respData["code"] = "ok"
                    return Response(respData)
                else:
                    return Response(respData,status=status.HTTP_400_BAD_REQUEST)
                    
            else:
                self.reset_ars(meetingid)
                self.clear_ars(meetingid)
                respData["code"] = "ok"
                return Response(respData)

        return Response(respData,status=status.HTTP_400_BAD_REQUEST)
    def post(self, request, *args, **kwargs):
        roleid = 0
        action = 99999
        aid = 0
        respData = {"code":"like error!"}        
        
        try:
            meetingid = int(kwargs['m_pk'])
            roleid = int(kwargs['pk'])
            clubid = 0
            if 'c_pk' in  kwargs:
                clubid = int(kwargs['c_pk'])
            if not MeetingUtil.validateClubMeetingPermission(request, clubid, meetingid):
                return Response({"msg":"club-meeting no matching"}, status=status.HTTP_400_BAD_REQUEST)
            action = int(request.GET.get("action"))
            aid = int(request.GET.get("aid"))            
        except:
            pass


        if action == 1:
            if self.get_like_existing(request, meetingid, aid, roleid)==False:
                requestDATA = {}
                arrelation = ARRelation.objects.get(roletaken_id__exact=roleid, activity_id__exact=aid)
                requestDATA["meeting"] = meetingid
                requestDATA["arrelation"] = arrelation.id
                requestDATA["evaluator"] = request.user.id
                requestDATA["like"] = 1
                                
                serializer = RoleLikerSerializer(data=requestDATA)
                if serializer.is_valid():
                    serializer.save()
                    respData["code"] = "ok"
                    
                    #send Club Conversation
                    role = RoleTaken.objects.get(id__exact = roleid)
                    owner = Person.objects.get(id__exact = role.ownerid)
                    sender = Person.objects.get(id__exact = request.user.id)
                    try:
                        msgfname = sender.displayname
                    except:
                        msgfname = sender.username
                    if(clubid != 0):
                        msgtouser = clubid
                    else:
                        msgtouser = role.meeting.term.club.id
                    msgcontent = owner.displayname + "'s " + role.title + " got ♥ from " + sender.displayname                    
                    MessageUtil.sendClubConversation(sender.id,msgfname, msgtouser, msgcontent)
                    
                    return Response(respData)
                
                return Response(respData,status=status.HTTP_400_BAD_REQUEST)
            else:
                self.update_like(request,meetingid,aid,roleid,1)
                respData["code"] = "ok"
                return Response(respData)
        
        elif action == 0:
            self.update_like(request,meetingid,aid,roleid,0)
            respData["code"] = "ok"
            return Response(respData)
        
        else:
            return Response(respData,status=status.HTTP_400_BAD_REQUEST)
    def post(self, request, *args, **kwargs):
        roleid = 0
        aid = 0
        respData = {"code":"stats error!"}        
        
        try:
            meetingid = int(kwargs['m_pk'])
            roleid = int(kwargs['pk'])
            clubid = 0
            if 'c_pk' in  kwargs:
                clubid = int(kwargs['c_pk'])
            if not MeetingUtil.validateClubMeetingPermission(request, clubid, meetingid):
                return Response({"msg":"club-meeting no matching"}, status=status.HTTP_400_BAD_REQUEST)
            aid = int(request.GET.get("aid"))
        except:
            pass
                
        timerPermission = True
        counterPermission = True
        passedPermission = True
        
        if "timer" in request.DATA:
            if self.set_stats_permission(request,meetingid,RoleEnum.Timer):
                timerPermission = True
            else:
                timerPermission = False

        if "ahcount" in request.DATA:
            if self.set_stats_permission(request,meetingid,RoleEnum.AhCounter):
                counterPermission = True 
            else:
                counterPermission = False 
                
        if "passed" in request.DATA:
            if self.set_evaluating_permission(request,meetingid,roleid):
                passedPermission = True
            else:
                passedPermission = False
        
        if  timerPermission is True and counterPermission is True and passedPermission is True:
            if(self.get_stats_existing(request, meetingid, aid, roleid)):
                self.update_stat(request,meetingid, aid, roleid)
                respData["code"] = "ok"
                if "passed" in request.DATA:
                    self.save_comments(clubid,roleid,request)
                return Response(respData)
            else:
                if aid is 0:
                    arrelation = ARRelation.objects.get(roletaken_id__exact=roleid)
                else:
                    arrelation = ARRelation.objects.get(roletaken_id__exact=roleid, activity_id__exact=aid)
                 
                request.DATA["meeting"] = meetingid
                request.DATA["arrelation"] = arrelation.id
                request.DATA["evaluator"] = request.user.id
                serializer = RoleEvaluatingSerializer(data=request.DATA)
                if serializer.is_valid():
                    serializer.save()
                    if "passed" in request.DATA:
                        self.save_comments(clubid,roleid,request)
                    respData["code"] = "ok"    
                    return Response(respData)
            
            return Response(respData,status=status.HTTP_400_BAD_REQUEST)
                   
        else:
            return Response(respData,status=status.HTTP_400_BAD_REQUEST)