from gstudio.models import * from objectapp.models import * from django.template.defaultfilters import slugify import datetime import os from demo.settings import PYSCRIPT_URL_GSTUDIO from demo.settings import FILE_URL def get_threadbox_of_twist(twistid): thid="" for each in System.objects.all(): sys_set=each.system_set.all() if sys_set: sys_set=each.system_set.all()[0] for eachsys in sys_set.gbobject_set.all(): if eachsys.id==twistid: return sys_set return thid def delete(idnum): del_ob = Gbobject.objects.get(id=idnum) del_ob.delete() return True def make_rep_object(title,auth_id,usr): new_ob = Gbobject() new_ob.title = "Re: " new_ob.slug=slugify(new_ob.title) new_ob.save() titleid = "Re:"+str(new_ob.id) contorg = unicode(title) fname=slugify(titleid)+"-"+usr new_ob.content_org=contorg.encode('utf8') ext='.org' html='.html' myfile = open(os.path.join(FILE_URL,fname+ext),'w') myfile.write(new_ob.content_org) myfile.close() myfile = open(os.path.join(FILE_URL,fname+ext),'r') rfile=myfile.readlines() scontent="".join(rfile) newcontent=scontent.replace("\r","") myfile = open(os.path.join(FILE_URL,fname+ext),'w') myfile.write(newcontent) myfile = open(os.path.join(FILE_URL,fname+ext),'a') myfile.write("\n#+OPTIONS: timestamp:nil author:nil creator:nil H:3 num:nil toc:nil @:t ::t |:t ^:t -:t f:t *:t <:t") myfile.write("\n#+TITLE: ") myfile = open(os.path.join(FILE_URL,fname+ext),'r') stdout = os.popen("%s %s %s"%(PYSCRIPT_URL_GSTUDIO,fname+ext,FILE_URL)) output = stdout.read() data = open(os.path.join(FILE_URL,fname+html)) data1 = data.readlines() data2 = data1[107:] dataa = data2[data2.index('