summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gstudio/admin/objecttype.py4
-rw-r--r--gstudio/models.py42
-rw-r--r--gstudio/templates/gstudio/base.html13
-rw-r--r--gstudio/templates/gstudio/display.html12
-rw-r--r--gstudio/templates/gstudio/version_diff.html180
-rw-r--r--gstudio/urls/history.py4
-rw-r--r--gstudio/views/graphs.py6
-rw-r--r--gstudio/views/history.py38
8 files changed, 266 insertions, 33 deletions
diff --git a/gstudio/admin/objecttype.py b/gstudio/admin/objecttype.py
index c98a0d78..74401407 100644
--- a/gstudio/admin/objecttype.py
+++ b/gstudio/admin/objecttype.py
@@ -172,8 +172,10 @@ class ObjecttypeAdmin(reversion.VersionAdmin):
if not form.cleaned_data.get('authors'):
form.cleaned_data['authors'].append(request.user)
- nodetype.last_update = datetime.now()
nodetype.save()
+ # nodetype.nbhood = nodetype.get_nbh
+ # nodetype.last_update = datetime.now()
+ # nodetype.save()
def queryset(self, request):
"""Make special filtering by user permissions"""
diff --git a/gstudio/models.py b/gstudio/models.py
index 100e4e2e..353a5b81 100644
--- a/gstudio/models.py
+++ b/gstudio/models.py
@@ -107,6 +107,7 @@ import reversion
from reversion.models import Version
from django.core import serializers
from reversion.models import *
+from reversion.helpers import *
NODETYPE_CHOICES = (
('ND', 'Nodes'),
@@ -192,6 +193,7 @@ class Author(User):
class Meta:
"""Author's Meta"""
proxy = True
+
class NID(models.Model):
"""the set of all nodes. provides node ID (NID) to all nodes in
the network, including edges. Edges are also first class citizens
@@ -205,6 +207,19 @@ class NID(models.Model):
slug = models.SlugField(help_text=_('used for publication'),
unique_for_date='creation_date',
max_length=255)
+
+
+ def convert(self,data):
+ if isinstance(data, unicode):
+ return str(data)
+ elif isinstance(data, collections.Mapping):
+ return dict(map(convert, data.iteritems()))
+ elif isinstance(data, collections.Iterable):
+ return type(data)(map(convert, data))
+ else:
+ return data
+
+
@property
def get_revisioncount(self):
"""
@@ -239,6 +254,22 @@ class NID(models.Model):
def version_info(self,ssid):
version_object=Version.objects.get(id=ssid)
return version_object.field_dict
+
+
+ def get_version_nbh(self,ssid):
+ """
+ Returns Version nbh
+ """
+ ver_dict=self.version_info(ssid)
+ ver_nbh_list=[]
+ ver_nbh_dict={}
+ for item in self.get_nbh.keys():
+ if item in ver_dict.keys():
+ ver_nbh_list.append(item)
+ for each in ver_nbh_list:
+ ver_nbh_dict[each]=ver_dict[each]
+ return ver_nbh_dict
+
def get_serialized_dict(self):
@@ -370,6 +401,10 @@ class Node(NID):
sites = models.ManyToManyField(Site, verbose_name=_('sites publication'),
related_name='nodetypes')
+ nbhood = models.TextField(help_text="The serialized nbh of this version of the Node.")
+
+
+
published = NodePublishedManager()
def __unicode__(self):
return self.title
@@ -379,6 +414,7 @@ class Node(NID):
@reversion.create_revision()
def save(self, *args, **kwargs):
+ # self.nbhood=self.get_nbh
super(Node, self).save(*args, **kwargs) # Call the "real" save() method.
@@ -579,6 +615,7 @@ class Metatype(Node):
# Save for metatype
@reversion.create_revision()
def save(self, *args, **kwargs):
+# self.nbhood=self.get_nbh
super(Metatype, self).save(*args, **kwargs) # Call the "real" save() method.
@@ -678,8 +715,8 @@ class Nodetype(Node):
reltypes['possible_rightroles'] = right_subset
return reltypes
-
-
+
+
@property
def get_possible_attributetypes(self):
"""
@@ -1396,6 +1433,7 @@ class Objecttype(Nodetype):
# Save for Objecttype
@reversion.create_revision()
def save(self, *args, **kwargs):
+ # self.nbhood=self.get_nbh
super(Objecttype, self).save(*args, **kwargs) # Call the "real" save() method.
diff --git a/gstudio/templates/gstudio/base.html b/gstudio/templates/gstudio/base.html
index 8625e139..20b010df 100644
--- a/gstudio/templates/gstudio/base.html
+++ b/gstudio/templates/gstudio/base.html
@@ -52,19 +52,8 @@
<h3>{% trans "Versions" %}</h3>
<table border="1" cellspacing="0">
{% for sid in object.get_ssid reversed %}
- <tr>
- <td width="5%" >
- <input type="radio" name="group1" value="{{ sid }}"><a href="{{ object.get_version_url }}{{ sid }}">{{ object.id }}{{ sid }}</a></input>
- </td>
- <td width="5%">
- <input type="radio" name="group2" value="{{ sid }}">{{ sid }}</input>
- </td>
- </tr>
- <br>
+ <a href="{{ object.get_version_url }}{{ sid }}">{{ object.title }}{{ object.id }}{{ sid }}</a><br>
{% endfor %}
- </table>
- <br>
- <input type="submit" value="Compare" />
</div>
<br>
diff --git a/gstudio/templates/gstudio/display.html b/gstudio/templates/gstudio/display.html
index f4c2dfb4..f2053a6e 100644
--- a/gstudio/templates/gstudio/display.html
+++ b/gstudio/templates/gstudio/display.html
@@ -523,9 +523,9 @@ $(function() {
{% block sidebar %}
<div class="History">
- <!-- <script type="text/javascript"> -->
+ <script type="text/javascript">
<!-- function go_to_loc(sid) -->
- <!-- { -->
+ <!-- { -->
<!-- window.location.href = "{{ nt.get_version_url }}"+sid -->
@@ -533,10 +533,10 @@ $(function() {
<!-- } -->
- <!-- </script> -->
+ <!-- </script> -->
<h3>{% trans "Versions" %}</h3>
- <form action="" method="POST" >
+ <form action="/nodetypes/display/showhistory/" >
<table cellspacing="0" border="2">
{% for sid in nt.get_ssid reversed %}
<tr>
@@ -544,10 +544,10 @@ $(function() {
<input type="radio" name="group1" value="{{ sid }}"><a href="{{ nt.get_version_url }}{{ sid }}">{{ nt.id }}.{{ sid }}</a></input>
</td>
<td>
- <input type="radio" name="group2" value="{{ sid }}">{{ sid }}</input>
+ <input type="radio" name="group2" value="{{ sid }}">{{ nt.id }}.{{ sid }}</input>
</td>
{% endfor %}
-
+
</table>
<input type="submit" value="Compare" />
</form>
diff --git a/gstudio/templates/gstudio/version_diff.html b/gstudio/templates/gstudio/version_diff.html
new file mode 100644
index 00000000..81305749
--- /dev/null
+++ b/gstudio/templates/gstudio/version_diff.html
@@ -0,0 +1,180 @@
+
+{% load i18n comments gstudio_tags %}
+{% load gstudio_tags i18n %}
+{% get_tags as nodetype_tags %}
+{% load adminmedia grp_tags %}
+
+
+{% load gstudio_tags i18n %}
+{% get_tags as nodetype_tags %}
+{% load adminmedia grp_tags %}
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
+<html xml:lang="{{ LANGUAGE_CODE }}" lang="{{ LANGUAGE_CODE }}" version="-//W3C//DTD XHTML 1.1//EN" xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+ <style type="text/css">
+ body {
+ background-color: white;
+ display:block;
+ }
+ .content
+ {
+ }
+ .content1
+ {
+ }
+ </style>
+ {% block blockbots %}
+ <meta name="robots" content="NONE,NOARCHIVE" />
+ {% endblock %} <!-- STYLESHEETS -->
+ {% block stylesheets %}
+ <link href="{% admin_media_prefix %}css/base.css" rel="stylesheet" type="text/css" />
+ {% if LANGUAGE_BIDI %}
+ <link href="{% block stylesheet_rtl %}{% admin_media_prefix %}css/rtl.css{% endblock %}" rel="stylesheet" type="text/css" />
+ {% endif %}
+ <link href="{% admin_media_prefix %}jquery/ui/css/custom-theme/jquery-ui-1.8.custom.css" rel="stylesheet" type="text/css" media="screen" title="no title" charset="utf-8" />
+ <link href="{% admin_media_prefix %}css/jquery-ui-grappelli-extensions.css" rel="stylesheet" type="text/css" />
+ {% endblock %} <!-- EXTRASTYLES -->
+ {% block extrastyle %}{% endblock %} <!-- JAVASCRIPTS -->
+ {% block javascripts %}
+ <script type="text/javascript">
+ // GLOBALS
+ var grappelli = {},
+ // TODO: klemens: drop ADMIN_URL
+ ADMIN_URL = "{% url admin:index %}",
+ MODEL_URL_ARRAY = {% get_content_types %}, DATE_FORMAT = "{% get_date_format %}", TIME_FORMAT = "{% get_time_format %}", DATETIME_FORMAT = "{% get_datetime_format %}";
+ </script>
+ <!-- jQuery, jQuery-UI -->
+ <script src="{% admin_media_prefix %}jquery/jquery-1.6.2.min.js" type="text/javascript"></script>
+ <script src="{% admin_media_prefix %}jquery/ui/js/jquery-ui-1.8.15.custom.min.js" type="text/javascript"></script>
+ <!-- Grappelli Main JS -->
+ <script src="{% admin_media_prefix %}js/grappelli/grappelli.js" type="text/javascript"></script>
+ <!-- Grappelli jQuery Plugins, Widgets -->
+ <script src="{% admin_media_prefix %}js/grappelli/jquery.grp_collapsible.js" type="text/javascript"></script>
+ <script src="{% admin_media_prefix %}js/grappelli/jquery.grp_collapsible_group.js" type="text/javascript"></script>
+ <script src="{% admin_media_prefix %}js/grappelli/jquery.grp_timepicker.js" type="text/javascript"></script>
+ <script src="{% admin_media_prefix %}js/grappelli/jquery.grp_related_fk.js" type="text/javascript"></script>
+ <script src="{% admin_media_prefix %}js/grappelli/jquery.grp_related_m2m.js" type="text/javascript"></script>
+ <script src="{% admin_media_prefix %}js/grappelli/jquery.grp_related_generic.js" type="text/javascript"></script>
+ <script src="{% admin_media_prefix %}js/grappelli/jquery.grp_autocomplete_fk.js" type="text/javascript"></script>
+ <script src="{% admin_media_prefix %}js/grappelli/jquery.grp_autocomplete_m2m.js" type="text/javascript"></script>
+ <script src="{% admin_media_prefix %}js/grappelli/jquery.grp_autocomplete_generic.js" type="text/javascript"></script>
+ <script type="text/javascript" src="{{STATIC_URL}}gstudio/js/jquery-ui-timepicker-0.2.9/include/jquery-1.5.1.min.js"></script>
+ <script type="text/javascript" src="{{STATIC_URL}}gstudio/js/jquery-ui-timepicker-0.2.9/include/jquery.ui.core.min.js"></script>
+ <script type="text/javascript" src="{{STATIC_URL}}gstudio/js/jquery-ui-timepicker-0.2.9/include/jquery.ui.widget.min.js"></script>
+ <script type="text/javascript" src="{{STATIC_URL}}gstudio/js/jquery-ui-timepicker-0.2.9/include/jquery.ui.tabs.min.js"></script>
+ <script type="text/javascript" src="{{STATIC_URL}}gstudio/js/jquery-ui-timepicker-0.2.9/include/jquery.ui.position.min.js"></script>
+
+ <script type="text/javascript" src="{{STATIC_URL}}gstudio/js/jquery.ui.timepicker.js"></script>
+
+ <script type="text/javascript" src="https://apis.google.com/js/plusone.js"></script>
+ <script src="{{STATIC_URL}}gstudio/js/gstudio.js" type="text/javascript"></script>
+ <!-- EXTRAHEAD -->
+ {% block extrahead %}{% endblock %}
+
+ {% endblock %}
+ <meta http-equiv="content-type" content="text/html; charset=utf-8" />
+ <meta http-equiv="cache-control" content="public" />
+ <meta name="robots" content="follow, all" />
+ <meta name="language" content="{{ LANGUAGE_CODE }}" />
+ <meta name="description" content="{% block meta-description %}Demonstration of the Gstudio Blog application.{% endblock %}" />
+ <meta name="keywords" content="{% block meta-keywords %}django, blog, gstudio, {{ nodetype_tags|join:", "}}{% endblock %}" />
+ <meta name="author" content="gnowgi" />
+ {% block meta %}{% endblock %}
+ <link rel="pingback" href="/xmlrpc/" />
+ <link rel="shortcut icon" href="{{ STATIC_URL }}gstudio/img/favicon.ico" />
+ <link rel="home" href="{% url gstudio_nodetype_archive_index %}" />
+ <link rel="stylesheet" type="text/css" media="screen, projection" href="{{ STATIC_URL }}gstudio/css/grappelli_skin_default.css" />
+ <link rel="stylesheet" type="text/css" media="screen, projection" href="{{ STATIC_URL }}gstudio/css/screen.css" />
+ <link rel="stylesheet" type="text/css" media="screen, projection" href="{{ STATIC_URL }}gstudio/css/screen_gstudio.css" />
+ <link rel="stylesheet" type="text/css" media="print" href="{{ STATIC_URL }}gstudio/css/print.css" />
+ {% block link %}{% endblock %}
+ {% block script %}{% endblock %} <title>Gnowledge Studio - {% block title %}{% endblock %}</title>
+ </head>
+ <body id="gstudio">
+
+
+
+
+
+
+ {% include "gstudio/_header.html" %}
+ <div id="breadcrumbs" class="span-24 last">
+ / {% block breadcrumbs %}{% endblock %}
+ </div>
+ <!-- <div id="body" class="span-24 last" > -->
+ <table border="0" >
+ <tr><td>
+
+ <h3>{% block content %}
+ {% block nodetype-content %}
+ <h2 class="nodetype-title">
+ <a href="{{ nt1.get_absolute_url }}" title="{{ nt1.title }}" rel="bookmark">{{ ver_new.title }}
+ </a>
+ </h2>
+ <br>
+ {% with nt1.html_content|safe as object_content %}
+ <b>Name:<nbsp></b>{{ ver_new.title }}<br/>
+ {% if ver_new.altnames %}
+ <b> Alternate names:<nbsp></b> {{ diffs }}
+ <br/>
+ {% endif %}
+ {% if ver_new.plural %}
+ <b> Plural Name:<nbsp></b>{{ ver_new.plural }} <br/>
+ {% endif %}
+ {% if nt1.get_rendered_nbh.authors %}<b>Authors: <nbsp> </b>
+ {% endif %}
+ {% for author in nt1.authors.all %}
+ <span class="vcard author">
+ <a href="{% url gstudio_author_detail author %}" class="fn nickname url" rel="author"
+ title="{% blocktrans with author as author %}Show {{ author }} nodetypes{% endblocktrans %}">{{ author }}</a>
+ </span>{% if not forloop.last %}, {% endif %}
+ {% endfor %} <br/>
+ {% endwith %}
+ {% endblock %}
+ {% endblock %}
+
+ </td>
+ <td>
+
+ <h3>{% block content1 %}
+ {% block nodetype-content1 %}
+ <h2 class="nodetype-title">
+ <a href="{{ nt1.get_absolute_url }}" title="{{ nt1.title }}" rel="bookmark">{{ ver_old.title }}
+ </a>
+ </h2>
+ <br>
+ {% with nt1.html_content|safe as object_content %}
+ <b>Name:<nbsp></b>{{ ver_old.title }}<br/>
+ {% if ver_old.altnames %}
+ <b> Alternate names:<nbsp></b>{{ ver_old.altnames}}
+ <br/>
+ {% endif %}
+ {% if ver_old.plural %}
+ <b> Plural Name:<nbsp></b>{{ ver_old.plural }} <br/>
+ {% endif %}
+ {% if nt1.get_rendered_nbh.authors %}<b>Authors: <nbsp> </b>
+ {% endif %}
+ {% for author in nt1.authors.all %}
+ <span class="vcard author">
+ <a href="{% url gstudio_author_detail author %}" class="fn nickname url" rel="author"
+ title="{% blocktrans with author as author %}Show {{ author }} nodetypes{% endblocktrans %}">{{ author }}</a>
+ </span>{% if not forloop.last %}, {% endif %}
+ {% endfor %} <br/>
+ {% endwith %}
+ {% endblock %}
+ {% endblock %}
+
+ </td>
+ </tr>
+ </table>
+
+
+
+
+
+ </body>
+</html>
+
+
+
+
diff --git a/gstudio/urls/history.py b/gstudio/urls/history.py
index d3d72cac..d8f6245c 100644
--- a/gstudio/urls/history.py
+++ b/gstudio/urls/history.py
@@ -3,6 +3,6 @@ from django.conf.urls.defaults import url
from django.conf.urls.defaults import patterns
urlpatterns = patterns('gstudio.views.history',
- url(r'^viewhistory/(?P<ssid>\d+)$', 'history',
+ url(r'^viewhistory/(?P<ssid>\d+)/$', 'history',
name='gstudio_history'),
- url(r'^showhistory/(?P<obj>\d+)$','showHistory'),)
+ url(r'^showhistory/$','showHistory'),)
diff --git a/gstudio/views/graphs.py b/gstudio/views/graphs.py
index 36a79e77..070ceab3 100644
--- a/gstudio/views/graphs.py
+++ b/gstudio/views/graphs.py
@@ -73,7 +73,7 @@ from gstudio.gnowql import *
#import d3
import json
import os
-
+from gstudio.models import *
from gstudio.views.decorators import protect_nodetype
from gstudio.views.decorators import update_queryset
@@ -86,7 +86,7 @@ def graph_json(request, node_id):
return HttpResponse(str(jsonFile.read()), "application/json")
try:
- node = NID.objects.get(id=node_id)
+ node = Objecttype.objects.get(id=node_id)
node = node.ref
except:
return HttpResponse("Node not found.", "text/html")
@@ -108,7 +108,7 @@ def version_graph_json(request,ssid):
try:
node = Version.objects.get(id=ssid)
- node = node.object.ref
+ node = node.object
except:
return HttpResponse("Node not found.", "text/html")
diff --git a/gstudio/views/history.py b/gstudio/views/history.py
index bcaedd70..7e0c7078 100644
--- a/gstudio/views/history.py
+++ b/gstudio/views/history.py
@@ -4,8 +4,8 @@ from gstudio.models import *
from django.template import RequestContext
from django.shortcuts import render_to_response
from django.views.generic.date_based import object_detail
-
-
+from reversion.helpers import *
+import pprint
from gstudio.models import *
from reversion.models import *
from gstudio.views.decorators import protect_nodetype
@@ -20,8 +20,32 @@ def history(request,ssid):
template="gstudio/display.html"
return render_to_response(template,variables)
-def showHistory(request,obj):
- obj=Objecttype.objects.get(id=obj)
- variables=RequestContext(request,{'ob':ob})
- template="gstudio/history.html"
- return render_to_response(template,variables)
+def showHistory(request):
+ vid1=request.GET["group1"]
+ vid2=request.GET["group2"]
+ 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_new_dict=nt1.version_info(request.GET["group1"])
+ ver_old_dict=nt1.version_info(request.GET["group2"])
+ ver_new_nbh=ver_new_dict['nbhood']
+ ver_old_nbh=ver_old_dict['nbhood']
+ 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"])
+
+ # 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)