Beispiel #1
0
 def update_a_complaint(self,key,method):
     if self.ex:
         cm = Complaint.objects.get(titleid=self.ex, userid=self.us,state="NORMAL")
         from exercise.dao import updateEXDao
         dao = updateEXDao()
         dao.update_exercise_complaint( method ,ex=self.ex)
         dao.update_ex_save()
     elif self.au:
         cm = Complaint.objects.get(authorid=self.au, userid=self.us,state="NORMAL")
         dao = userDao({'us':self.au})
         dao.update_complaint(method)
         dao.save_update()
     elif self.tp:
         cm = Complaint.objects.get(topicid=self.tp, userid=self.us,state="NORMAL")
         from bbs.dao import BBSDao
         dao = BBSDao({'bbs':self.tp})
         dao.update_Tcomplaint(method)
         dao.update_Tsave()
     elif self.op:
         cm = Complaint.objects.get(opinionid=self.op, userid=self.us,state="NORMAL")
         from bbs.dao import OpinDao
         dao = OpinDao({'op':self.op})
         dao.update_Ocomplaint(method)
         dao.update_save()
     elif self.rs:
         cm = Complaint.objects.get(resourceid=self.rs, userid=self.us,state="NORMAL")
         dao = rsUpdateDao(self.rs)
         dao.update_complaint(method)
         dao.update_save()
     if key=='state':
         cm.state = 'CANCEL'
     cm.save()
Beispiel #2
0
def contribute(req):
    if req.method == "POST" and req.COOKIES.has_key("userid"):
        jsonReq = simplejson.loads(req.body)
        dao = updateEXDao(ex=jsonReq["titleid"])
        dao.update_exercise_points()
        dao.update_ex_save()
        dao = userDao({"userid": jsonReq["authorid"]})
        dao.update_point_byReq({"method": "+", "points": 1})
        dao.save_update()
        return HttpResponse(json.dumps({"tips": "点赞成功"}), content_type="application/json")
    return HttpResponse(json.dumps({"tips": "点赞失败"}), content_type="application/json")
Beispiel #3
0
 def insert_a_complaint(self,req,method):
     if self.ex:
         n =  Complaint.objects.filter(titleid=self.ex,state='NORMAL').count()
         if n<5:
             Complaint(titleid=self.ex, content=req['content'],userid=self.us, state='NORMAL').save()
             from exercise.dao import updateEXDao
             dao = updateEXDao() 
             if dao.update_exercise_complaint( method='+',ex=self.ex)==5:
                 dao.update_exercise_state('ACTIVE', self.ex)
             dao.update_ex_save()
             return None
     elif self.au:
         n =  Complaint.objects.filter( authorid=self.au,state='NORMAL').count()
         if n<10:
             Complaint(authorid=self.au, content=req['content'],userid=self.us, state='NORMAL').save()
             dao = userDao({'us':self.au})
             if dao.update_complaint('+')==10:
                 dao.update_state('ACTIVE')
             dao.save_update()
             return None
     elif self.tp:
         n =  Complaint.objects.filter( topicid=self.tp,state='NORMAL').count()
         if n<10:
             Complaint(topicid=self.tp, content=req['content'],userid=self.us, state='NORMAL').save()
             from bbs.dao import BBSDao
             dao = BBSDao({'bbs':self.tp})
             if dao.update_Tcomplaint(method)==10:
                 dao.update_Tstate('ACTIVE')
             dao.update_Tsave()
             return None
     elif self.op:
         n =  Complaint.objects.filter(opinionid=self.op,state='NORMAL').count()
         if n<5:
             Complaint(opinionid=self.op, content=req['content'],userid=self.us, state='NORMAL').save()
             from bbs.dao import OpinDao
             dao = OpinDao({'op':self.op})
             if dao.update_Ocomplaint('+')==5:
                 dao.update_state('ACTIVE')
             dao.update_save()
             return None
     elif self.rs:
         n =  Complaint.objects.filter(resourceid=self.rs,state='NORMAL').count()
         if n<10:
             Complaint(resourceid=self.rs, content=req['content'],userid=self.us, state='NORMAL').save()
             dao = rsUpdateDao(self.rs)
             if dao.update_complaint('+')==10:
                 dao.update_state('ACTIVE')
             dao.update_save()
             return None
     return 'wrong request'