diff options
-rw-r--r-- | demo/urls.py | 8 | ||||
-rw-r--r-- | gstudio/models.py | 132 | ||||
-rw-r--r-- | gstudio/templates/gstudio/base.html | 5 | ||||
-rw-r--r-- | gstudio/templates/gstudio/nodetype_detail.html | 27 | ||||
-rw-r--r-- | gstudio/templates/gstudio/skeleton.html | 2 | ||||
-rw-r--r-- | gstudio/templates/gstudio/tags/breadcrumbs.html | 2 | ||||
-rw-r--r-- | gstudio/templatetags/gstudio_tags.py | 2 | ||||
-rw-r--r-- | gstudio/views/add.py | 22 | ||||
-rw-r--r-- | objectapp/models.py | 86 | ||||
-rw-r--r-- | objectapp/templates/objectapp/_gbobject_detail.html | 21 | ||||
-rw-r--r-- | objectapp/templates/objectapp/base.html | 4 | ||||
-rw-r--r-- | objectapp/templates/objectapp/skeleton.html | 2 | ||||
-rw-r--r-- | objectapp/templates/objectapp/tags/authors.html | 3 |
13 files changed, 243 insertions, 73 deletions
diff --git a/demo/urls.py b/demo/urls.py index 71ab823..ce2e623 100644 --- a/demo/urls.py +++ b/demo/urls.py @@ -84,18 +84,16 @@ handler404 = 'django.views.defaults.page_not_found' urlpatterns = patterns( '', (r'^$', 'django.views.generic.simple.redirect_to', - {'url': '/gstudio/'}), - url(r'^gstudio/', include('gstudio.urls')), + {'url': '/nodetypes/'}), + url(r'^nodetypes/', include('gstudio.urls')), url(r'^objects/', include('objectapp.urls')), - url(r'^gstudio/objects/', include('objectapp.urls')), url(r'^comments/', include('django.contrib.comments.urls')), url(r'^xmlrpc/$', 'django_xmlrpc.views.handle_xmlrpc'), url(r'^i18n/', include('django.conf.urls.i18n')), url(r'^admin/doc/', include('django.contrib.admindocs.urls')), url(r'^admin/', include(admin.site.urls)), url(r'^objects/admin/', include(admin.site.urls)), - url(r'^gstudio/admin/', include(admin.site.urls)), - url(r'^gstudio/objects/admin/', include(admin.site.urls)), + url(r'^nodetypes/admin/', include(admin.site.urls)), url(r'^grappelli/', include('grappelli.urls')), url(r'^accounts/', include('registration.urls')), url(r'^$', 'django.views.generic.simple.redirect_to', diff --git a/gstudio/models.py b/gstudio/models.py index 8e42807..a1ddf94 100644 --- a/gstudio/models.py +++ b/gstudio/models.py @@ -753,6 +753,97 @@ class Nodetype(Node): return relations @property + def get_relations1(self): + """ + Returns all the relations of the nodetype + """ + relations={} + reltype={} + left_relations=Relation.objects.filter(left_subject=self.id) + if left_relations: + for each in left_relations: + relation=each.relationtype.title + predicate=each.right_subject + predicate_values=[] + if reltype: + fl=0 + for key,value in reltype.items(): + if type(value) <> list: + t=[] + t.append(value) + predicate_values=t + else: + predicate_values=value + if each.relationtype.title==key: + fl=1 + predicate_values.append(predicate) + reltype[key]=predicate_values + if fl==0: + predicate_values=predicate + reltype[relation]=predicate_values + else: + predicate_values.append(predicate) + reltype[relation]=predicate_values + relations['lrelations']=reltype + + right_relations=Relation.objects.filter(right_subject=self.id) + reltype={} + if right_relations: + for each in right_relations: + relation=each.relationtype.inverse + predicate=each.left_subject + predicate_values=[] + if reltype: + fl=0 + for key,value in reltype.items(): + if type(value) <> list: + t=[] + t.append(value) + prdicate_values=t + else: + predicate_values=value + if each.relationtype.inverse==key: + fl=1 + predicate_values.append(predicate) + reltype[key]=predicate_values + + if fl==0: + predicate_values=predicate + reltype[relation]=predicate_values + + else: + predicate_values.append(predicate) + reltype[relation]=predicate_values + relations['rrelations']=reltype + return relations + + @property + def get_attributes(self): + attributes_dict = {} + all_attributes=self.subject_of.all() + for attributes in all_attributes: + val=[] + atr_key=attributes.attributetype.title + val.append(attributes.svalue) + + if attributes_dict: + fl=0 + itms=attributes_dict + + for key,value in itms.items(): + if atr_key in key: + fl=1 + if type(value) <> list: + t=[] + t.append(value) + val.extend(t) + + else: + val.extend(value) + attributes_dict[atr_key]=val + return attributes_dict + + @property def get_rendered_nbh(self): """ Returns the neighbourhood of the nodetype @@ -803,15 +894,40 @@ class Nodetype(Node): nbh['siblings']=siblings #get Relations relns={} - relnvalue={} - if self.get_relations: - NTrelns=self.get_relations - for value in NTrelns: - relnvalue[NTrelns[value].title]=NTrelns[value].ref.get_absolute_url() - relns[value]=relnvalue - nbh['relations']=relns + rellft={} + relrgt={} + if self.get_relations1: + NTrelns=self.get_relations1 + for key,value in NTrelns.items(): + if key=="rrelations": + relrgt={} + for rgtkey,rgtvalue in value.items(): + relnvalue={} + if isinstance(rgtvalue,list): + for items in rgtvalue: + relnvalue[items]=items.get_absolute_url() + else: + relnvalue[rgtvalue]=rgtvalue.get_absolute_url() + + relrgt[rgtkey]=relnvalue + + else: + rellft={} + relns['left']=rellft + for lftkey,lftvalue in value.items(): + relnvalue={} + if isinstance(lftvalue,list): + for items in lftvalue: + relnvalue[items]=items.get_absolute_url() + else: + relnvalue[lftvalue]=lftvalue.get_absolute_url() + + rellft[lftkey]=relnvalue + + nbh['relations']=relrgt + nbh['relations'].update(rellft) #get Attributes - attributes = self.subject_of.all() + attributes =self.get_attributes nbh['attributes']=attributes #get ATs attributetypes={} diff --git a/gstudio/templates/gstudio/base.html b/gstudio/templates/gstudio/base.html index 1d8898b..2c612e1 100644 --- a/gstudio/templates/gstudio/base.html +++ b/gstudio/templates/gstudio/base.html @@ -1,4 +1,5 @@ {% extends "gstudio/skeleton.html" %} +{% load gstudio_tags i18n %} {% load objectapp_tags i18n %} {% block meta %} @@ -11,11 +12,11 @@ <link rel="wlwmanifest" type="application/wlwmanifest+xml" href="{% url objectapp_wlwmanifest %}" /> <link rel="search" type="application/opensearchdescription+xml" title="Objectapp's Blog" href="{% url objectapp_opensearch %}" /> <link rel="alternate" type="application/rss+xml" title="{% trans "RSS Feed of latest gbobjects" %}" href="{% url objectapp_gbobject_latest_feed %}" /> - {% get_archives_gbobjects "objectapp/tags/archives_gbobjects_link.html" %} + <!-- {% get_archives_gbobjects "objectapp/tags/archives_gbobjects_link.html" %} --> {% endblock %} {% block breadcrumbs %} - {% objectapp_breadcrumbs %} + {% gstudio_breadcrumbs %} {% endblock %} {% block sidebar %} diff --git a/gstudio/templates/gstudio/nodetype_detail.html b/gstudio/templates/gstudio/nodetype_detail.html index 774b688..f5740ea 100644 --- a/gstudio/templates/gstudio/nodetype_detail.html +++ b/gstudio/templates/gstudio/nodetype_detail.html @@ -33,8 +33,14 @@ {% block content %} - {% block nodetype-content %} +<h2 class="nodetype-title"> + <a href="{{ object.get_absolute_url }}" title="{{ object.title }}" rel="bookmark"> + {{ object.title }} + </a> + <a href="{{ object.ref.get_edit_url }}" target="_blank" >[edit]</a> + + </h2> {% with object.html_content|safe as object_content %} @@ -117,7 +123,7 @@ {% if object.get_rendered_nbh.priornodes %} - <b>Priornodes:<nbsp></b> + <b>Prior nodes:<nbsp></b> {% for mkey,mvalue in object.get_rendered_nbh.priornodes.items %} <a href="{{mvalue}}">{{mkey}}</a>; {% endfor %}<br/> @@ -144,14 +150,15 @@ {% endif %} {% if object.get_rendered_nbh.attributes %} - - - <b>Attributes:<nbsp> </b> - - {% for items in object.get_rendered_nbh.attributes.items %} - {{items}}; - {% endfor %} <br/> + {% for atkey,atvalue in object.get_rendered_nbh.attributes.items %} + {% if atvalue %} + <b>{{atkey}}:<nbsp> </b> + {% for atr in atvalue %} + {{atr}}; + {% endfor %} <br/> + {% endif %} + {% endfor %} {% endif %} {% if object.get_rendered_nbh.leftroles %} @@ -176,7 +183,7 @@ {% if object.get_rendered_nbh.ats %} - <b>Attribute Types:<nbsp> </b> + <b>Subjecttype of:<nbsp> </b> {% for atkey,atvalue in object.get_rendered_nbh.ats.items %} <a href="{{atvalue}}">{{atkey}}</a>; diff --git a/gstudio/templates/gstudio/skeleton.html b/gstudio/templates/gstudio/skeleton.html index a54988b..27518d7 100644 --- a/gstudio/templates/gstudio/skeleton.html +++ b/gstudio/templates/gstudio/skeleton.html @@ -144,7 +144,7 @@ vis.append("svg:g").attr("class", "nodes"); $(function() { $.ajax({ -url: '/gstudio/graphs/graph_json/{{ object.id }}', +url: '/nodetypes/graphs/graph_json/{{ object.id }}', //crossDomain: true, dataType: 'json', success : function(json) { diff --git a/gstudio/templates/gstudio/tags/breadcrumbs.html b/gstudio/templates/gstudio/tags/breadcrumbs.html index c7a5361..57f9ad9 100644 --- a/gstudio/templates/gstudio/tags/breadcrumbs.html +++ b/gstudio/templates/gstudio/tags/breadcrumbs.html @@ -1,6 +1,8 @@ {% for crumb in breadcrumbs %} {% if not forloop.last %} +{% if crumb.name %} <a href="{{ crumb.url }}" title="{{ crumb.name }}">{{ crumb.name }}</a> {{ separator }} +{% endif %} {% else %} {{ crumb.name }} {% endif %} diff --git a/gstudio/templatetags/gstudio_tags.py b/gstudio/templatetags/gstudio_tags.py index 574da8c..a22715e 100644 --- a/gstudio/templatetags/gstudio_tags.py +++ b/gstudio/templatetags/gstudio_tags.py @@ -289,7 +289,7 @@ def gstudio_pagination(context, page, begin_pages=3, end_pages=3, @register.inclusion_tag('gstudio/tags/dummy.html', takes_context=True) -def gstudio_breadcrumbs(context, separator='/', root_name='gstudio', +def gstudio_breadcrumbs(context, separator='/', root_name='Nodetype', template='gstudio/tags/breadcrumbs.html',): """Return a breadcrumb for the application""" path = context['request'].path diff --git a/gstudio/views/add.py b/gstudio/views/add.py index d302d9c..f222752 100644 --- a/gstudio/views/add.py +++ b/gstudio/views/add.py @@ -28,7 +28,7 @@ def addmetatype(request): formset = MetatypeForm(request.POST) if formset.is_valid(): formset.save() - return HttpResponseRedirect("/gstudio/") + return HttpResponseRedirect("/nodetypes/") @@ -48,7 +48,7 @@ def addobjecttype(request): formset = ObjecttypeForm(request.POST) if formset.is_valid(): formset.save() - return HttpResponseRedirect("/gstudio/") + return HttpResponseRedirect("/nodetypes/") @@ -65,7 +65,7 @@ def addrelationtype(request): formset = RelationtypeForm(request.POST) if formset.is_valid(): formset.save() - return HttpResponseRedirect("/gstudio/") + return HttpResponseRedirect("/nodetypes/") else: @@ -82,7 +82,7 @@ def addattributetype(request): formset = AttributetypeForm(request.POST) if formset.is_valid(): formset.save() - return HttpResponseRedirect("/gstudio/") + return HttpResponseRedirect("/nodetypes/") else: @@ -99,7 +99,7 @@ def addsystemtype(request): formset = SystemtypeForm(request.POST) if formset.is_valid(): formset.save() - return HttpResponseRedirect("/gstudio/") + return HttpResponseRedirect("/nodetypes/") else: @@ -115,7 +115,7 @@ def addprocesstype(request): formset = ProcesstypeForm(request.POST) if formset.is_valid(): formset.save() - return HttpResponseRedirect("/gstudio/") + return HttpResponseRedirect("/nodetypes/") else: @@ -131,7 +131,7 @@ def addattribute(request): formset = AttributeForm(request.POST) if formset.is_valid(): formset.save() - return HttpResponseRedirect("/gstudio/") + return HttpResponseRedirect("/nodetypes/") else: @@ -147,7 +147,7 @@ def addrelation(request): formset = RelationForm(request.POST) if formset.is_valid(): formset.save() - return HttpResponseRedirect("/gstudio/") + return HttpResponseRedirect("/nodetypes/") else: @@ -163,7 +163,7 @@ def addcomplement(request): formset = ComplementForm(request.POST) if formset.is_valid(): formset.save() - return HttpResponseRedirect("/gstudio/") + return HttpResponseRedirect("/nodetypes/") else: @@ -179,7 +179,7 @@ def addunion(request): formset = UnionForm(request.POST) if formset.is_valid(): formset.save() - return HttpResponseRedirect("/gstudio/") + return HttpResponseRedirect("/nodetypes/") else: @@ -195,7 +195,7 @@ def addintersection(request): formset = IntersectionForm(request.POST) if formset.is_valid(): formset.save() - return HttpResponseRedirect("/gstudio/") + return HttpResponseRedirect("/nodetypes/") else: diff --git a/objectapp/models.py b/objectapp/models.py index 94fa7e1..fb846f5 100644 --- a/objectapp/models.py +++ b/objectapp/models.py @@ -252,12 +252,32 @@ class Gbobject(Node): def get_attributes(self): - attributes = {} - for attribute in Attribute.objects.filter(subject=self.id): - for key,value in attribute.edge_node_dict.iteritems(): - attributes[key]= value + attributes_dict = {} + all_attributes=self.subject_of.all() + for attributes in all_attributes: + val=[] + atr_key=attributes.attributetype.title + val.append(attributes.svalue) + + if attributes_dict: + fl=0 + itms=attributes_dict + + for key,value in itms.items(): + if atr_key in key: + fl=1 + if type(value) <> list: + t=[] + t.append(value) + val.extend(t) + + else: + + val.extend(value) + + attributes_dict[atr_key]=val - return attributes + return attributes_dict @@ -392,16 +412,21 @@ class Gbobject(Node): predicate=each.right_subject predicate_values=[] if reltype: + fl=0 for key,value in reltype.items(): - predicate_values=value + if type(value) <> list: + t=[] + t.append(value) + predicate_values=t + else: + predicate_values=value if each.relationtype.title==key: + fl=1 predicate_values.append(predicate) - reltype[key]=predicate_values - break - else: - predicate_values=predicate - reltype[relation]=predicate_values - break + reltype[key]=predicate_values + if fl==0: + predicate_values=predicate + reltype[relation]=predicate_values else: predicate_values.append(predicate) reltype[relation]=predicate_values @@ -415,16 +440,23 @@ class Gbobject(Node): predicate=each.left_subject predicate_values=[] if reltype: + fl=0 for key,value in reltype.items(): - predicate_values=value + if type(value) <> list: + t=[] + t.append(value) + prdicate_values=t + else: + predicate_values=value if each.relationtype.inverse==key: + fl=1 predicate_values.append(predicate) reltype[key]=predicate_values - break - else: - predicate_values=predicate - reltype[relation]=predicate_values - break + + if fl==0: + predicate_values=predicate + reltype[relation]=predicate_values + else: predicate_values.append(predicate) reltype[relation]=predicate_values @@ -446,6 +478,17 @@ class Gbobject(Node): for each in self.objecttypes.all(): member_of_dict[each.title]= each.get_absolute_url() nbh['member_of']=member_of_dict + + pnode_dict = {} + for each in self.prior_nodes.all(): + pnode_dict[each.title]= each.get_absolute_url() + nbh['priornodes']=pnode_dict + + pnode_dict = {} + for each in self.posterior_nodes.all(): + pnode_dict[each.title]= each.get_absolute_url() + nbh['posteriornodes']=pnode_dict + #get Relations relns={} rellft={} @@ -481,11 +524,10 @@ class Gbobject(Node): nbh['relations']=relrgt nbh['relations'].update(rellft) + #get Attributes - attributes ={} - for each in self.subject_of.all(): - attributes[each.attributetype]=each.svalue - nbh['attributes']=attributes + attributes =self.get_attributes() + nbh['attributes']=attributes return nbh diff --git a/objectapp/templates/objectapp/_gbobject_detail.html b/objectapp/templates/objectapp/_gbobject_detail.html index b9d1b91..10e1563 100644 --- a/objectapp/templates/objectapp/_gbobject_detail.html +++ b/objectapp/templates/objectapp/_gbobject_detail.html @@ -44,7 +44,7 @@ {% if object.get_rendered_nbh.member_of %} - <b> Member of Metatypes :<nbsp></b> + <b> Member of :<nbsp></b> {% for mkey,mvalue in object.get_rendered_nbh.member_of.items %} <a href="{{mvalue}}">{{mkey}}</a>; @@ -63,15 +63,16 @@ {% endif %} {% if object.get_rendered_nbh.attributes %} - - - -<b>Attributes: <nbsp> </b> - -{% for items in object.get_rendered_nbh.attributes %} - {{items}}; -{% endfor %} <br/> -{% endif %} + {% for atkey,atvalue in object.get_rendered_nbh.attributes.items %} + {% if atvalue %} + <b> {{atkey}}:<nbsp></b> + + {% for items in atvalue %} + {{items}};<nbsp> + {% endfor %} + {% endif %}<br/> + {% endfor %} + {% endif %} </p> diff --git a/objectapp/templates/objectapp/base.html b/objectapp/templates/objectapp/base.html index 40e6324..16aaaf9 100644 --- a/objectapp/templates/objectapp/base.html +++ b/objectapp/templates/objectapp/base.html @@ -34,10 +34,12 @@ </p> </form> </div> +<!-- <div class="objecttypes"> <h3>{% trans "Objecttypes" %}</h3> {% get_objecttypes %} </div> +--> <div class="authors"> <h3>{% trans "Authors" %}</h3> {% get_authors %} @@ -88,7 +90,7 @@ {% if perms.objectapp.add_gbobject %} <li> <a href="{% url admin:objectapp_gbobject_add %}" title="{% trans "Post an gbobject" %}"> - {% trans "Post an gbobject" %} + {% trans "Post a gbobject" %} </a> </li> {% endif %} diff --git a/objectapp/templates/objectapp/skeleton.html b/objectapp/templates/objectapp/skeleton.html index 5f89159..36069e0 100644 --- a/objectapp/templates/objectapp/skeleton.html +++ b/objectapp/templates/objectapp/skeleton.html @@ -151,7 +151,7 @@ Javascript for Object type force graph $(function() { $.ajax({ - url: '/gstudio/graphs/graph_json/{{ object.id }}', + url: '/nodetypes/graphs/graph_json/{{ object.id }}', //crossDomain: true, dataType: 'json', success : function(json) { diff --git a/objectapp/templates/objectapp/tags/authors.html b/objectapp/templates/objectapp/tags/authors.html index c518ece..562a83f 100644 --- a/objectapp/templates/objectapp/tags/authors.html +++ b/objectapp/templates/objectapp/tags/authors.html @@ -5,7 +5,8 @@ <li class="vcard"> <a href="{% url objectapp_author_detail author.username %}" title="{{ author.username }}" class="fn nickname url">{{ author.username }}</a> - {% blocktrans count author.gbobjects_published.count as gbobject_count %}{{ gbobject_count }} gbobject{% plural %}{{ gbobject_count }} gbobjects{% endblocktrans %} + <!-- + {% blocktrans count author.gbobjects_published.count as gbobject_count %}{{ gbobject_count }} gbobject{% plural %}{{ gbobject_count }} gbobjects{% endblocktrans %} --> </li> {% empty %} <li> |