diff options
author | Arun yadav <arunkumar5587@gmail.com> | 2012-05-18 16:37:44 +0530 |
---|---|---|
committer | Arun yadav <arunkumar5587@gmail.com> | 2012-05-18 16:37:44 +0530 |
commit | 431f589903ea3f03678a3c20acfd478ae4c15805 (patch) | |
tree | edcfe264a8afaf6b2e8b1d21e7d0c9f08a050d79 /gstudio/views | |
parent | 4d4df37a9f858d5fc2dc342d06d30b87031000d8 (diff) | |
download | gnowsys-431f589903ea3f03678a3c20acfd478ae4c15805.tar.gz |
templates and views for history, with colour diff v1
Diffstat (limited to 'gstudio/views')
-rw-r--r-- | gstudio/views/graphs.py | 2 | ||||
-rw-r--r-- | gstudio/views/history.py | 87 |
2 files changed, 70 insertions, 19 deletions
diff --git a/gstudio/views/graphs.py b/gstudio/views/graphs.py index 757a838..ff2fa40 100644 --- a/gstudio/views/graphs.py +++ b/gstudio/views/graphs.py @@ -114,7 +114,7 @@ def version_graph_json(request,ssid): try: node = Version.objects.get(id=ssid) - node = node.object + node = node.object.ref except: return HttpResponse("Node not found.", "text/html") diff --git a/gstudio/views/history.py b/gstudio/views/history.py index 7e0c707..1c05b84 100644 --- a/gstudio/views/history.py +++ b/gstudio/views/history.py @@ -10,11 +10,12 @@ from gstudio.models import * from reversion.models import * from gstudio.views.decorators import protect_nodetype from gstudio.views.decorators import update_queryset +import ast def history(request,ssid): # iden=request.GET["id"] nt1=Version.objects.get(id=ssid) - nt=nt1.object + nt=nt1.object.ref ver_dict=nt.version_info(ssid) variables = RequestContext(request,{'ver_dict':ver_dict ,'nt':nt,'ssid':ssid }) template="gstudio/display.html" @@ -26,26 +27,76 @@ def showHistory(request): nt=Version.objects.get(id=vid1) nt1=nt.object pp=pprint.PrettyPrinter(indent=4) - # ver_new=Version.objects.get(id=vid1) - # ver_old=Version.objects.get(id=vid2) + ver_new1=Version.objects.get(id=vid1) + ver_old1=Version.objects.get(id=vid2) + ver_new_dict=nt1.version_info(request.GET["group1"]) + content=str(ver_new_dict['content']) + content=content[3:-4] + ver_new_dict['content']=content ver_old_dict=nt1.version_info(request.GET["group2"]) + content=str(ver_old_dict['content']) + content=content[3:-4] + ver_old_dict['content']=content + ver_new_nbh=ver_new_dict['nbhood'] + ver_new_dict1=ast.literal_eval(ver_new_nbh) + ver_old_nbh=ver_old_dict['nbhood'] + ver_old_dict1=ast.literal_eval(ver_old_nbh) + ver_new_nbh=ver_new_nbh.replace(",","\n") - ver_new_nbh=ver_old_nbh.replace(",","\n") - # ver_new="" - # ver_old="" - # for each in ver_new_nbh: - # ver_new+=each + ":" + str(ver_new_nbh[each])+'\n' - # for each in ver_old_nbh: - # ver_old+=each + ":" + str(ver_old_nbh[each])+'\n' - diffs = dmp.diff_main(ver_new_nbh, ver_old_nbh) - d=dmp.diff_prettyHtml(diffs) - return HttpResponse(d) - # ver_new=nt1.version_info(request.GET["group1"]) - # ver_old=nt1.version_info(request.GET["group2"]) + ver_old_nbh=ver_old_nbh.replace(",","\n") + d=[] + d1=[] + field=['Name','Plural Name','Alternate Name','Authors','Content'] + for each in ver_new_dict: + ver_new="" + ver_old="" + if each =='altnames': + ver_new+=field[2] + ":" + ver_new_dict['altnames'] + ver_old+=field[2] + ":" + ver_old_dict['altnames'] + + diffs = dmp.diff_main(ver_new, ver_old) + d.append(dmp.diff_prettyHtml(diffs)) + diffs = dmp.diff_main(ver_old, ver_new) + d1.append(dmp.diff_prettyHtml(diffs)) + + if each =='title': + ver_new+=field[0] + ":" + ver_new_dict['title'] + ver_old+=field[0] + ":" + ver_old_dict['title'] + diffs = dmp.diff_main(ver_new, ver_old) + d.append(dmp.diff_prettyHtml(diffs)) + diffs = dmp.diff_main(ver_old, ver_new) + d1.append(dmp.diff_prettyHtml(diffs)) + if each =='plural': + ver_new+=field[1] + ":" + ver_new_dict['plural'] + ver_old+=field[1] + ":" + ver_old_dict['plural'] + diffs = dmp.diff_main(ver_new, ver_old) + d.append(dmp.diff_prettyHtml(diffs)) + diffs = dmp.diff_main(ver_old, ver_new) + d1.append(dmp.diff_prettyHtml(diffs)) + if each =='content': + ver_new+=field[4] + ":" + ver_new_dict['content'] + ver_old+=field[4] + ":" + ver_old_dict['content'] + diffs = dmp.diff_main(ver_new, ver_old) + d.append(dmp.diff_prettyHtml(diffs)) + diffs = dmp.diff_main(ver_old, ver_new) + d1.append(dmp.diff_prettyHtml(diffs)) + + # for each in ver_new_dict1: +# ver_new="" + # ver_old="" + # ver_new+=each + ":" + str(ver_new_dict1[each]) +# ver_old+=each + ":" + str(ver_old_dict1[each]) + # diffs = dmp.diff_main(ver_new, ver_old) + # d.append(dmp.diff_prettyHtml(diffs)) + + # return HttpResponse(d) + ver_new=nt1.version_info(request.GET["group1"]) + ver_old=nt1.version_info(request.GET["group2"]) - # variables=RequestContext(request,{'nt':nt1,'ver_old':ver_old,'ver_new':ver_new,'diffs':diffs }) - # template="gstudio/version_diff.html" - # return render_to_response(template,variables) + variables=RequestContext(request,{'nt':nt1,'ver_old':ver_old_dict,'ver_new':ver_new_dict,'diffs':d ,'vid1':vid1,'vid2':vid2,'diffs1':d1}) + template="gstudio/version_diff.html" + return render_to_response(template,variables) + |