diff options
-rw-r--r-- | gnowsys-ndf/gnowsys_ndf/ndf/templates/ndf/node_ajax_view.html | 17 | ||||
-rw-r--r-- | gnowsys-ndf/gnowsys_ndf/ndf/templates/ndf/version_page.html | 31 | ||||
-rw-r--r-- | gnowsys-ndf/gnowsys_ndf/ndf/urls/version.py | 1 | ||||
-rw-r--r-- | gnowsys-ndf/gnowsys_ndf/ndf/views/methods.py | 28 | ||||
-rw-r--r-- | gnowsys-ndf/gnowsys_ndf/ndf/views/page.py | 2 | ||||
-rw-r--r-- | gnowsys-ndf/gnowsys_ndf/ndf/views/version.py | 51 |
6 files changed, 77 insertions, 53 deletions
diff --git a/gnowsys-ndf/gnowsys_ndf/ndf/templates/ndf/node_ajax_view.html b/gnowsys-ndf/gnowsys_ndf/ndf/templates/ndf/node_ajax_view.html index e5c31dd..0e00b9b 100644 --- a/gnowsys-ndf/gnowsys_ndf/ndf/templates/ndf/node_ajax_view.html +++ b/gnowsys-ndf/gnowsys_ndf/ndf/templates/ndf/node_ajax_view.html @@ -245,9 +245,11 @@ ul#navigation li a.last { color: #10c1cb; } + </style> + {% if user.is_authenticated %} <!--<a id="toggle-shelf" class="right-off-canvas-toggle right" ><i class='fi-book-bookmark'></i></a> --> {% endif %} @@ -297,7 +299,6 @@ ul#navigation li a.last { <h1><span itemprop="{{schema.1.name}}" class='node'>{{node.name}}</span> - {% if node %} {% get_publish_policy request groupid node as group_policy %} {% if group_policy == "allow" %} @@ -306,7 +307,8 @@ ul#navigation li a.last { {% endif %} </h1> - + + <h1 class="subheader"> <dl class="tabs" data-tab> @@ -1121,6 +1123,7 @@ ul#navigation li a.last { {% endif %} {% endif %} </div> + <div class="medium-7 columns"> {% get_create_url node.pk as create_url %} {% if is_group %} @@ -1164,9 +1167,15 @@ ul#navigation li a.last { {% endif %} {% endif %} {% endif %} - </div> - + + <div class ="rows"> + {% if user.is_authenticated %} + <div class= "medium-12 columns" > + <a href = "{% url 'node_version' groupid node.pk %}" class="tiny round button" > <label style = 'width:8%;'> History </label> </a> + </div> + {% endif %} + </div> {% if node %} diff --git a/gnowsys-ndf/gnowsys_ndf/ndf/templates/ndf/version_page.html b/gnowsys-ndf/gnowsys_ndf/ndf/templates/ndf/version_page.html index 91c9d89..9e8dfd4 100644 --- a/gnowsys-ndf/gnowsys_ndf/ndf/templates/ndf/version_page.html +++ b/gnowsys-ndf/gnowsys_ndf/ndf/templates/ndf/version_page.html @@ -37,7 +37,7 @@ background:#b3ffb3; {% trans "Compare" %} {% endifequal %} {% trans "History" %} : - {{content1.3.name|title}} + {{content.3.name|title}} </h2> </div> @@ -79,9 +79,12 @@ background:#b3ffb3; {% if user.is_authenticated %} {% if user.is_superuser or node.created_by == user.id %} {% if selected_versions.1 and selected_versions.2 %} + {% comment %} <a class="button tiny" href="{% url 'merge_doc' group_id node selected_versions.1 selected_versions.2 %}" > Merge </a> + {% endcomment %} <a class="button tiny" href="{% url 'revert_doc' group_id node selected_versions.1 %}" > Revert to {{selected_versions.1}} </a> <a class="button tiny" href="{% url 'revert_doc' group_id node selected_versions.2 %}" > Revert to {{selected_versions.2}} </a> + {% endif %} {% endif %} {% endif %} @@ -112,7 +115,7 @@ background:#b3ffb3; </div> {% elif view == "merge" or view == "revert" %} <script> - document.location.href = '/{{group_id}}/page/{{node}}/version/{{ver}}'</script> + document.location.href = '/{{group_id}}/compare/{{node}}/version/{{ver}}'</script> {% else %} <div class="row" style = "overflow: auto; min-height: auto;max-height: 75vh;"> @@ -128,16 +131,18 @@ background:#b3ffb3; {% block script %} -a={{content|safe}} +left_panel = {{content|safe}} +if ( '{{content1}}' != 'none' ) + { + right_panel = {{content1|safe}} + right_panel.reverse() + } $('#compare-view').append("<table id='new' width='700' </table>") $('#new').append("<thead> <th> Feild </th> <th> Value </th> <th> Compared </th> </thead>") - -a1 = {{content1|safe}} h= 0 -a.reverse() -$.each(a1,function(k,g) +$.each(left_panel,function(k,g) { h = h + 1 $.each(g,function(c,v){ @@ -145,11 +150,13 @@ $.each(a1,function(k,g) }); - t = a.pop(k) - $.each(t,function(c,v){ - $('#rows' + k).append(" <td style='vertical-align: top;'> " + v + "</td> </tr>") - }); - + if ( '{{content1}}' != 'none' ) + { + t = right_panel.pop(k) + $.each(t,function(c,v){ + $('#rows' + k).append(" <td style='vertical-align: top;'> " + v + "</td> </tr>") + }); + } }); $("#compare_versions").click(function() { if ($("#version_1").val() === $("#version_2").val()) { diff --git a/gnowsys-ndf/gnowsys_ndf/ndf/urls/version.py b/gnowsys-ndf/gnowsys_ndf/ndf/urls/version.py index 1ce983f..c5acdf2 100644 --- a/gnowsys-ndf/gnowsys_ndf/ndf/urls/version.py +++ b/gnowsys-ndf/gnowsys_ndf/ndf/urls/version.py @@ -2,6 +2,7 @@ from django.conf.urls import patterns, url urlpatterns = patterns('gnowsys_ndf.ndf.views.version', url(r'^/(?P<node_id>[\w-]+)/version/(?P<version_no>\d+\.\d+)$', 'version_node', name='node_version'), + url(r'^/(?P<node_id>[\w-]+)/version/$', 'version_node', name='node_version'), url(r'^(?P<node_id>[\w-]+)/merge/(?P<version_1>\d+\.\d+)/(?P<version_2>\d+\.\d+)$', 'merge_doc', name='merge_doc'), url(r'^(?P<node_id>[\w-]+)/revert/(?P<version_1>\d+\.\d+)$', 'revert_doc', name='revert_doc'), ) diff --git a/gnowsys-ndf/gnowsys_ndf/ndf/views/methods.py b/gnowsys-ndf/gnowsys_ndf/ndf/views/methods.py index 93b4ec0..2e4dc49 100644 --- a/gnowsys-ndf/gnowsys_ndf/ndf/views/methods.py +++ b/gnowsys-ndf/gnowsys_ndf/ndf/views/methods.py @@ -2914,8 +2914,8 @@ def create_college_group_and_setup_data(college_node): return gfc, gr_gfc -def get_published_version_dict(request,document_object): - """Returns the dictionary containing the list of revision numbers of published nodes. +def get_published_version_list(request,document_object): + """Returns the list of revision numbers of published nodes. """ published_node_version = [] rcs = RCS() @@ -2939,9 +2939,11 @@ def parse_data(doc): date_typelist = ['last_update','created_at'] objecttypelist = ['member_of'] languagelist = ['language'] + content = ['content'] for i in doc: - + if i in content: + doc[i] = str(doc[i]) if i in user_idlist: if type(doc[i]) == list : temp = "" @@ -2949,9 +2951,8 @@ def parse_data(doc): if User.objects.filter(id = userid).exists(): user = User.objects.get(id = userid) if user: - user_name = user.get_username if temp: - temp =temp + "," + (user.get_username() ) + temp =temp + "," + (str(user.get_username()) ) else: temp = str(user.get_username()) doc[i] = temp @@ -2960,7 +2961,7 @@ def parse_data(doc): if User.objects.filter(id = doc[i]).exists(): user = User.objects.get(id = doc[i]) if user: - doc[i] = user.get_username() + doc[i] = str(user.get_username()) elif i in date_typelist: doc[i] = datetime.strftime(doc[i],"%d %B %Y %H:%M") elif i in objecttypelist: @@ -2969,13 +2970,14 @@ def parse_data(doc): doc[i] = node.name elif i == "rating": new_str = "" - for k in doc[i]: - userid = k['user_id'] - score = k['score'] - if User.objects.filter(id = userid).exists(): - user = User.objects.get(id = userid) - if user: - new_str = new_str + "User" +":" + str(user.get_username()) + " " + "Score" + str (score) + "\n" + if doc[i]: + for k in doc[i]: + userid = k['user_id'] + score = k['score'] + if User.objects.filter(id = userid).exists(): + user = User.objects.get(id = userid) + if user: + new_str = new_str + "User" +":" + str(user.get_username()) + " " + "Score" + str (score) + "\n" if not doc[i]: doc[i] = "" else: diff --git a/gnowsys-ndf/gnowsys_ndf/ndf/views/page.py b/gnowsys-ndf/gnowsys_ndf/ndf/views/page.py index b89f5c1..b0dc6dc 100644 --- a/gnowsys-ndf/gnowsys_ndf/ndf/views/page.py +++ b/gnowsys-ndf/gnowsys_ndf/ndf/views/page.py @@ -28,7 +28,7 @@ from gnowsys_ndf.ndf.models import node_collection, triple_collection from gnowsys_ndf.ndf.models import HistoryManager from gnowsys_ndf.ndf.rcslib import RCS from gnowsys_ndf.ndf.org2any import org2html -from gnowsys_ndf.ndf.views.methods import get_node_common_fields, get_translate_common_fields,get_page,get_resource_type,diff_string,get_node_metadata,create_grelation_list,get_execution_time,get_published_version_dict,parse_data +from gnowsys_ndf.ndf.views.methods import get_node_common_fields, get_translate_common_fields,get_page,get_resource_type,diff_string,get_node_metadata,create_grelation_list,get_execution_time,parse_data from gnowsys_ndf.ndf.management.commands.data_entry import create_gattribute from gnowsys_ndf.ndf.views.html_diff import htmldiff from gnowsys_ndf.ndf.views.methods import get_versioned_page, get_page, get_resource_type, diff_string diff --git a/gnowsys-ndf/gnowsys_ndf/ndf/views/version.py b/gnowsys-ndf/gnowsys_ndf/ndf/views/version.py index 8fba053..fb99c85 100644 --- a/gnowsys-ndf/gnowsys_ndf/ndf/views/version.py +++ b/gnowsys-ndf/gnowsys_ndf/ndf/views/version.py @@ -4,7 +4,7 @@ from django.core.urlresolvers import reverse from django.shortcuts import render_to_response, render from django.template import RequestContext from gnowsys_ndf.ndf.views.html_diff import htmldiff -from gnowsys_ndf.ndf.views.methods import get_versioned_page, get_page, get_resource_type, diff_string,get_published_version_dict +from gnowsys_ndf.ndf.views.methods import get_versioned_page, get_page, get_resource_type, diff_string,get_published_version_list from gnowsys_ndf.ndf.views.methods import parse_data try: from bson import ObjectId @@ -16,7 +16,7 @@ from gnowsys_ndf.ndf.models import HistoryManager history_manager = HistoryManager() -def version_node(request, group_id, node_id, version_no): +def version_node(request, group_id, node_id, version_no = None): """Renders either a single or compared version-view based on request. In single version-view, all information of the node for the given version-number @@ -38,8 +38,7 @@ def version_node(request, group_id, node_id, version_no): else : pass - d=diff_match_patch() - + d=diff_match_patch() view = "" # either single or compare selected_versions = {} node = node_collection.one({"_id": ObjectId(node_id)}) @@ -47,7 +46,16 @@ def version_node(request, group_id, node_id, version_no): fp = history_manager.get_file_path(node) listform = ['modified_by','created_by','last_update','name','content','contributors','rating','location','access_policy', 'type_of','status','tags','language','member_of','url','created_at','author_set'] - versions= get_published_version_dict(request,node) + versions= get_published_version_list(request,node) + + if not version_no: + if versions: + version_no = versions.pop() + versions.append(version_no) + else: + version_no = node.current_version + + if request.method == "POST": view = "compare" @@ -59,26 +67,26 @@ def version_node(request, group_id, node_id, version_no): doc1=history_manager.get_version_document(node,version_2) parse_data(doc) parse_data(doc1) - content_difference = htmldiff(doc['content'],doc1['content']) - for i in node1: try: - s=d.diff_compute(str(doc[i]),str(doc1[i]),True) - l=diff_prettyHtml(s) - node1[i]=l + s=htmldiff(str(doc[i]),str(doc1[i]),True) + node1[i]=s except: node1[i]=node1[i] - content = node1 - new_content = content_difference.replace("insert:"," ").replace("delete:","").replace("<tt>","").replace("</tt>","") - new_content = new_content.replace("<","<").replace(">",">").replace(""","\"") - content['content'] = new_content - content_1=doc + content = doc + content_1 = node1 + + content['content'] = doc['content'].replace("<","<").replace(">",">").replace(""","\"") + content_1['content'] = content_1['content'].replace("insert:"," ").replace("delete:","").replace("<tt>","").replace("</tt>","") + content_1['content'] = content_1['content'].replace("<","<").replace(">",">").replace(""","\"") + new_content = [] new_content1= [] + for i in listform: - new_content.append({i:content[i]}) - new_content1.append({i:str(content_1[i])}) + new_content.append({i:str(content[i])}) + new_content1.append({i:content_1[i]}) content = new_content content_1 = new_content1 else: @@ -89,11 +97,11 @@ def version_node(request, group_id, node_id, version_no): new_content = [] selected_versions = {"1": version_no, "2": ""} for i in listform: - new_content.append({i:data[i]}) + new_content.append({i:str(data[i])}) content = new_content #content = data - content_1='none' + content_1="none" return render_to_response("ndf/version_page.html", {'view': view, 'node': node, @@ -211,7 +219,7 @@ def merge_doc(request,group_id,node_id,version_1,version_2): node.content=doc2.content node.modified_by=request.user.id node.save() - update_mobwrite = update_mobwrite_content_org(node) + #update_mobwrite = update_mobwrite_content_org(node) ver=history_manager.get_current_version(node) view='merge' @@ -244,14 +252,11 @@ def revert_doc(request,group_id,node_id,version_1): node[attr] =node[attr] node.modified_by=request.user.id node.save() - update_mobwrite = update_mobwrite_content_org(node) view ='revert' ver=history_manager.get_current_version(node) selected_versions=selected_versions = {"1": version_1, "2": ""} - return render_to_response("ndf/version_page.html", {'view': view, - 'appId':app._id, 'selected_versions': selected_versions, 'node':node, 'groupid':group_id, |