Esempio n. 1
0
def audit(user,action,cid):
    clause=Clause.objects.get(id=cid)
    if user==clause.creater:
        return False
    if clause.status==u'审核中':
        if action=='approve':
            clause.status=u'生效中'
            clause.save()
            newrecord(cid,user,'批准')
            newnotice(getcounterpart(user).user,getbeingbyuser(user).nickname+u'在'+datetime.datetime.now().strftime('%Y年%m月%d日').decode('utf-8')+u'批准了条款:'+clause.link())
        elif action=='reject':
            clausedes=clause.description
            clause.delete()
            newnotice(getcounterpart(user).user,getbeingbyuser(user).nickname+u'在'+datetime.datetime.now().strftime('%Y年%m月%d日').decode('utf-8')+u'删除了条款:'+clausedes)
        return True
    elif clause.status==u'请求删除中':
        if action=='approve':
            clausedes=clause.description
            clause.delete()
            newnotice(getcounterpart(user).user,getbeingbyuser(user).nickname+u'在'+datetime.datetime.now().strftime('%Y年%m月%d日').decode('utf-8')+u'同意了删除条款:'+clausedes)
        elif action=='reject':
            clause.status=u'生效中'
            clause.save()
            newrecord(cid,user,'拒删')
            newnotice(getcounterpart(user).user,getbeingbyuser(user).nickname+u'在'+datetime.datetime.now().strftime('%Y年%m月%d日').decode('utf-8')+u'拒绝删除条款:'+clause.link())
Esempio n. 2
0
def fault_confirm(request,fid):
    context=RequestContext(request)
    if request.method=='GET':
        fault=getfault(fid)
        confirmfault(fid)
        if fault.clause:
            newnotice(getcounterpart(request.user).user,getbeingbyuser(request.user).nickname+u'在'+datetime.datetime.now().strftime('%Y年%m月%d日').decode('utf-8')+u'承认了关于条款:'+fault.clause.link()+u' 的违章行为。')
        else:
            newnotice(getcounterpart(request.user).user,getbeingbyuser(request.user).nickname+u'在'+datetime.datetime.now().strftime('%Y年%m月%d日').decode('utf-8')+u'承认了关于:“'+fault.reason+u'”的违章行为。')
        return HttpResponseRedirect('/country/clause_audit/')
Esempio n. 3
0
def newfault(cid,user,currentuser):
    cls=getclause(cid)
    if currentuser==user:
        fr=FaultRecord(clause_id=cid,user=user,status='confirmed')
        mailcall(user=getcounterpart(currentuser).user,title=u'【星际快讯】今日说法',content=u'某不良少年'+getbeingbyuser(currentuser).nickname+u'自愿承认触犯了以下条款:'+cls.description+u', (http://www.yanglala.com/country/fault_list/)。大家赶快一起来嘲笑他吧~~~')
    else:
        fr=FaultRecord(clause_id=cid,user=user,status='confirming')
        mailcall(user=getcounterpart(currentuser).user,title=u'【星际快讯】法院召唤你',content=getbeingbyuser(currentuser).nickname+u'认为你有如下罪行:'+cls.description+u', 将被处以'+cls.card+u', 笨蛋你还不从实招来!(http://www.yanglala.com/country/clause_audit/)~~~')
    fr.save()
    return fr
Esempio n. 4
0
def clause_delete(request,clauseid):
    context=RequestContext(request)
    if request.method=='GET':
        clause=getclause(clauseid)
        user=request.user
        if clause.status==u'生效中':
            requestdeleteclause(user,clauseid)
            newnotice(getcounterpart(user).user,getbeingbyuser(user).nickname+u'在'+datetime.datetime.now().strftime('%Y年%m月%d日').decode('utf-8')+u'申请删除条款'+clause.link())
        else:
            clausedes=clause.description
            deleteclause(cid=clauseid)
            newnotice(getcounterpart(user).user,getbeingbyuser(user).nickname+u'在'+datetime.datetime.now().strftime('%Y年%m月%d日').decode('utf-8')+u'删除了条款:'+clausedes)
        return HttpResponseRedirect("/country/law/")
Esempio n. 5
0
def requestdeleteclause(user,cid):
    clause=getclause(cid=cid)
    clause.creater=user
    clause.status='请求删除中'
    clause.save()
    mailcall(user=getcounterpart(user).user,title=u'【星际快讯】星际法删除',content=getbeingbyuser(user).nickname+u'申请删除条款.(http://www.yanglala.com/country/clause_audit/)。赶快去审核吧~~~')
    return True
Esempio n. 6
0
def clause_audit(request):
    context=RequestContext(request)
    if request.method=='GET':
        if request.user.is_authenticated():
            user=request.user
            al=getauditing(user)
            return render_to_response('clause_audit.html',{'auditlist':al,'other':getcounterpart(user),'faultlist':getconfirming(user),'deletelist':getdeleting(user),'request':request},context)
        else:
            return render_to_response('index.html',{'error':'Please Login First!','king':getking(),'queen':getqueen()},context)
Esempio n. 7
0
def fault_delete(request,fid):
    context=RequestContext(request)
    if request.method=='GET':
        fault=getfault(fid)
        clause=fault.clause
        if clause:
            page=request.REQUEST.get('redirect','/country/clause_detail/'+str(clause.id))
        else:
            page=request.REQUEST.get('redirect','/country/fault_list/')
        if not deletefault(fid):
            error='删除记录失败,此记录不存在。'
            print error
        if fault.clause:
            newnotice(getcounterpart(request.user).user,getbeingbyuser(request.user).nickname+u'在'+datetime.datetime.now().strftime('%Y年%m月%d日').decode('utf-8')+u'拒绝了关于条款:'+clause.link()+u' 的违章行为。')
            mailcall(getcounterpart(request.user).user,u'【星际快讯】犯罪嫌疑人起诉',getbeingbyuser(request.user).nickname+u'否认了关于条款:'+clause.description+u' 的违章行为。(http://www.yanglala.com/country/fault_list/)')
        else:
            newnotice(getcounterpart(request.user).user,getbeingbyuser(request.user).nickname+u'在'+datetime.datetime.now().strftime('%Y年%m月%d日').decode('utf-8')+u'拒绝了关于:“'+fault.reason+u'”的违章行为。')
            mailcall(getcounterpart(request.user).user,u'【星际快讯】犯罪嫌疑人起诉',getbeingbyuser(request.user).nickname+u'否认了关于:'+fault.reason+u' 的违章行为。(http://www.yanglala.com/country/fault_list/)')
        return HttpResponseRedirect(page)
Esempio n. 8
0
def faultstats_update(request):
    context=RequestContext(request)
    if request.method=='POST':
        form=forms.UpdateFaultStatsForm(request.POST)
        if form.is_valid():
            data=form.cleaned_data
            user=request.user
            objbeing=getcounterpart(user)
            objbeing.faultstats.do(ywqz=data['ywqz'],fwc=data['fwc'],ytxs=data['ytxs'],pb=data['pb'],cancel=data['cancel'])
            return HttpResponseRedirect("/being/user_detail/"+str(objbeing.user.id))
Esempio n. 9
0
def newpost(creater,title,description,happentime,imageurls,imageuploads):
    p=Post(creater=creater,title=title,happentime=happentime,description=description)
    p.save()
    for url in imageurls:
        img=NetImage(post=p,url=url)
        img.save()
    for image in imageuploads:
        img=UploadImage(post=p,image=image)
        img.save()
    mailcall(user=getcounterpart(creater).user,title=u'【星际快讯】大事件',content=getbeingbyuser(creater).nickname+u'添加了历史记录:'+title+u'(http://www.yanglala.com/history/)。一起见证光辉的时刻吧~~~')
    return p
Esempio n. 10
0
def updateclause(user,cid,description,section,card,startdate=datetime.date.today(),enddate=datetime.date(9999,8,15)):
    clause=Clause.objects.get(id=cid)
    clause.section=section
    clause.creater=user
    clause.startdate=startdate
    clause.description=description
    clause.enddate=enddate
    clause.card=card
    clause.status='审核中'
    clause.save()
    mailcall(user=getcounterpart(user).user,title=u'【星际快讯】星际法修订',content=getbeingbyuser(user).nickname+u'修订了法律.(http://www.yanglala.com/country/clause_audit/)。赶快去审核该修订吧~~~')
    return True
Esempio n. 11
0
def post(request):
    context=RequestContext(request)
    if request.method=='POST':
        form=forms.PostForm(request.POST,files=request.FILES)
        if form.is_valid():
            user=request.user
            data=form.cleaned_data
            files=request.FILES.getlist('imageupload')
            p=newpost(creater=request.user,title=data['title'],description=data['description'],happentime=request.POST['happentime'],imageurls=form.geturls(),imageuploads=files)
            newrecord(user,p.id,'发布')
            newnotice(getcounterpart(user).user,getbeingbyuser(user).link()+u'发布了新的历史'+p.link()+u',还不快去看看?')
            return HttpResponseRedirect("/history/")
        else:
            print form.errors
            return render_to_response('history.html',{'error':'post failed,check you form.'},context)
Esempio n. 12
0
def update(request,postid):
    context=RequestContext(request)
    p=getpost(postid)
    if request.method=='GET':
        return render_to_response('post_update.html',{'post':p,'update':True},context)

    elif request.method=='POST':
        #process update
        form=forms.UpdatePostForm(request.POST,files=request.FILES)
        if form.is_valid():
            data=form.cleaned_data
            files=request.FILES.getlist('imageupload')
            p.update(title=data['title'],description=data['description'],happentime=request.POST['happentime'],imageurls=form.geturls(),imageuploads=files)
            user=request.user
            newrecord(user,postid,'修改')
            newnotice(getcounterpart(user).user,getbeingbyuser(user).link()+u'更新了历史'+p.link()+u',还不快去看看?')
            return HttpResponseRedirect("/history/")
        else:
            print form.errors
            return render_to_response('post_update.html',{'post':p,'error':'post failed,check you form.'},context)
Esempio n. 13
0
def index(request):
    if request.method=='GET':
        context=RequestContext(request)
        being=getcounterpart(request.user)
        return render_to_response('garden.html',{'objectbeing':being},context)
Esempio n. 14
0
def getdeleting(user):
    being=getcounterpart(user)
    al=Clause.objects.filter(status='请求删除中',creater=being.user)
    return al
Esempio n. 15
0
def getauditing(user):
    being=getcounterpart(user)
    al=Clause.objects.filter(status='审核中',creater=being.user)
    return al
Esempio n. 16
0
def confirmfault(fid):
    fr=FaultRecord.objects.get(id=fid)
    fr.status='confirmed'
    fr.save()
    mailcall(user=getcounterpart(fr.user).user,title=u'【星际快讯】今日说法',content=u'潜逃多日的罪犯'+getbeingbyuser(fr.user).nickname+u'于今日俯首认罪, 按照星球法:'+fr.clause.description+u' 被处以'+fr.clause.card+u'.(http://www.yanglala.com/country/fault_list/)~~~')
    return fr
Esempio n. 17
0
def newclause(creater,startdate,enddate,description,section,card):
    enddate=enddate if enddate!=None else datetime.date(9999,8,15)
    cl=Clause(creater=creater,description=description,startdate=startdate,enddate=enddate,section=section,status="审核中",card=card)
    cl.save()
    mailcall(user=getcounterpart(creater).user,title=u'【星际快讯】新的法律制定',content=getbeingbyuser(creater).nickname+u'添加了新的法律条文.(http://www.yanglala.com/country/clause_audit/)。请尽快审核吧~~~')
    return cl
Esempio n. 18
0
def newmovie(creater,title,source=None,introduction=''):
    mv=Movie(creater=creater,title=title,source=source,introduction=introduction)
    mv.save()
    mailcall(user=getcounterpart(creater).user,title=u'【星际快讯】视频推荐',content=getbeingbyuser(creater).nickname+u'给你的视频推荐:'+title+u'(http://www.yanglala.com/movie/)。观看后要记得给评价哦~~~')
    return mv