美文网首页
山东大学-VirtualJudge-总结9

山东大学-VirtualJudge-总结9

作者: LJCgeorge | 来源:发表于2017-06-09 19:55 被阅读0次

实现了在contest中的clarification功能以及对于已经存在的问题进行了修改:

部分核心代码:

<script type="text/javascript">
    function post_clar(){
        var clar = $("#clar_content").val()
            if(clar == ""){
                alert("New Clarification is null!")
            }else{
                $.ajax({
                    type : "post",
                    url : "/contest/"+{{contest.id}}+"/clarification/",
                    data : {"clar":clar},
                    success : function(responseData){
                        $('#panel-clar').html(responseData)
                        scrollTo(0,0)
                    }
                })
            }
    }
</script>
def contest_clarification(req,cid):
    #pid=req.GET.get("proid")
    #pro = Problem.objects.get(proid=proid)
    contest = Contest.objects.get(id = cid)
    isAuthor = req.user == contest.uid
    print('OUT POST clar', req.POST.get('clar')) 
    print('OUT GET clar', req.GET.get('clar')) 
    if not req.POST.get('clar') :
        #print('GET count', Contest_clarification.objects.filter(contest=contest).count())
        return render(req,'contest/contest_clar.html',{'contest':contest,'list': Contest_clarification.objects.filter(contest=contest).order_by('-time'), 'isAuthor':isAuthor})
    else :
        #print('POST count', Contest_clarification.objects.filter(contest=contest).count())
        #print('POST clar', req.POST.get('clar')) 
        if isAuthor:
            contest_clarification = Contest_clarification(contest = contest, clarification = req.POST.get('clar'),
                time = time.strftime('%Y-%m-%d %H:%M:%S',time.localtime(time.time())))
            contest_clarification.save()
        return render(req,'contest/contest_clar.html',{'contest':contest, 'list': Contest_clarification.objects.filter(contest=contest).order_by('-time'), 'isAuthor':isAuthor })

def dateToInt(date, field):
     if field == 0:
         return date.days * 24 * 60 + date.seconds // 60
     else:
         return date.days * 24 * 60 *60  + date.seconds

相关文章

网友评论

      本文标题:山东大学-VirtualJudge-总结9

      本文链接:https://www.haomeiwen.com/subject/hjbfqxtx.html