Skip to content

Commit

Permalink
Add persons to show back references of related issues.
Browse files Browse the repository at this point in the history
Improve Issues to also include start and end dates of corruption occurence.
  • Loading branch information
kaerumy committed Mar 26, 2012
1 parent b11447e commit b00e2d9
Show file tree
Hide file tree
Showing 4 changed files with 274 additions and 0 deletions.
7 changes: 7 additions & 0 deletions deployment.cfg
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,7 @@
[buildout]

extends = buildout.cfg

[instance]
http-address = 8085
effective-user = www
128 changes: 128 additions & 0 deletions src/sinar/corruptiontracker/person.py
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,128 @@
from five import grok
from zope import schema

from plone.directives import form, dexterity
from plone.app.textfield import RichText
from plone.z3cform.textlines import TextLinesFieldWidget
from plone.autoform.interfaces import IFormFieldProvider
from zope.schema.vocabulary import SimpleVocabulary, SimpleTerm
from z3c.relationfield.schema import RelationList
from z3c.relationfield.schema import RelationChoice
from plone.formwidget.contenttree import ObjPathSourceBinder
from plone.indexer import indexer

from sinar.corruptiontracker import _

from zc.relation.interfaces import ICatalog
from Acquisition import aq_inner
from zope.component import getUtility
from zope import component
from zope.intid.interfaces import IIntIds
from zope.security import checkPermission

from Products.CMFCore.utils import getToolByName


class IPerson(form.Schema):
"""Person of Interest
"""

details = RichText(
title=_(u"Details"),
required=True,
)


class View(dexterity.DisplayForm):
grok.context(IPerson),
grok.require('zope2.View')

def directly_implicated(self):

#from ipdb import set_trace; set_trace()

catalog = component.getUtility(ICatalog)
intids = component.getUtility(IIntIds)
rels=catalog.findRelations({'to_id': intids.getId(self.context),
'from_attribute' : "persons_directly_implicated"},
)
result = []
for i in rels:
result.append(i.from_object)
return result

def indirectly_implicated(self):

#from ipdb import set_trace; set_trace()

catalog = component.getUtility(ICatalog)
intids = component.getUtility(IIntIds)
rels=catalog.findRelations({'to_id': intids.getId(self.context),
'from_attribute' : "persons_indirectly_implicated"},
)
result = []
for i in rels:
result.append(i.from_object)
return result

def indirectly_implicated(self):

#from ipdb import set_trace; set_trace()

catalog = component.getUtility(ICatalog)
intids = component.getUtility(IIntIds)
rels=catalog.findRelations({'to_id': intids.getId(self.context),
'from_attribute' : "persons_indirectly_implicated"},
)
result = []
for i in rels:
result.append(i.from_object)
return result

def supporting(self):

#from ipdb import set_trace; set_trace()

catalog = component.getUtility(ICatalog)
intids = component.getUtility(IIntIds)
rels=catalog.findRelations({'to_id': intids.getId(self.context),
'from_attribute' : "persons_supporting"},
)
result = []
for i in rels:
result.append(i.from_object)
return result

def against(self):

#from ipdb import set_trace; set_trace()

catalog = component.getUtility(ICatalog)
intids = component.getUtility(IIntIds)
rels=catalog.findRelations({'to_id': intids.getId(self.context),
'from_attribute' : "persons_against"},
)
result = []
for i in rels:
result.append(i.from_object)
return result

def disclosing(self):

#from ipdb import set_trace; set_trace()

catalog = component.getUtility(ICatalog)
intids = component.getUtility(IIntIds)
rels=catalog.findRelations({'to_id': intids.getId(self.context),
'from_attribute' : "persons_disclosing"},
)
result = []
for i in rels:
result.append(i.from_object)
return result


@indexer(IPerson)
def searchablePersonIndexer(obj):
return obj.details.output
grok.global_adapter(searchablePersonIndexer, name='SearchablePersonText')
85 changes: 85 additions & 0 deletions src/sinar/corruptiontracker/person_templates/view.pt
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,85 @@
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"
xmlns:tal="http://xml.zope.org/namespaces/tal"
xmlns:metal="http://xml.zope.org/namespaces/metal"
xmlns:i18n="http://xml.zope.org/namespaces/i18n"
lang="en"
metal:use-macro="context/main_template/macros/master"
i18n:domain="sinar.corruptiontracker">
<body>

<metal:main fill-slot="main">
<tal:main-macro metal:define-macro="main">

<div tal:replace="structure provider:plone.abovecontenttitle" />

<h1 class="documentFirstHeading" tal:content="context/title" />

<div tal:replace="structure provider:plone.belowcontenttitle" />

<p class="documentDescription" tal:content="context/description" />

<div tal:replace="structure provider:plone.abovecontentbody" />

<div tal:content="structure view/w/details/render" />

<h2 tal:condition="python: view.directly_implicated()">Issues directl
<dl tal:repeat="obj python: view.directly_implicated()">
<dt><a tal:attributes="href obj/absolute_url">
<span tal:replace="obj/Title" /></a>
</dt>
<dd>
<span tal:replace="obj/description" />
</dd>
<dd>
Financial Cost (MYR): <span tal:replace="obj/financial_cost" />
</dd>
</dl>

<h2 tal:condition="python: view.indirectly_implicated()">Issues indirectly implicated</h2>
<dl tal:repeat="obj python: view.indirectly_implicated()">
<dt><a tal:attributes="href obj/absolute_url">
<span tal:replace="obj/Title" /></a>
</dt>
<dd>
<span tal:replace="obj/description" />
</dd>
<dd>
Financial Cost (MYR): <span tal:replace="obj/financial_cost" />
</dd>
</dl>

<h2 tal:condition="python: view.against()">Issues Against</h2>
<dl tal:repeat="obj python: view.against()">
<dt><a tal:attributes="href obj/absolute_url">
<span tal:replace="obj/Title" /></a>
</dt>
<dd>
<span tal:replace="obj/description" />
</dd>
<dd>
Financial Cost (MYR): <span tal:replace="obj/financial_cost" />
</dd>
</dl>

<h2 tal:condition="python: view.supporting()">Issues Support</h2>
<dl tal:repeat="obj python: view.supporting()">
<dt><a tal:attributes="href obj/absolute_url">
<span tal:replace="obj/Title" /></a>
</dt>
<dd>
<span tal:replace="obj/description" />
</dd>
<dd>
Financial Cost (MYR): <span tal:replace="obj/financial_cost" />
</dd>
</dl>



<div tal:replace="structure provider:plone.belowcontentbody" />

</tal:main-macro>
</metal:main>

</body>
</html>
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,54 @@
<?xml version="1.0"?>
<object name="sinar.corruptiontracker.person" meta_type="Dexterity FTI"
i18n:domain="sinar.corruptiontracker" xmlns:i18n="http://xml.zope.org/namespaces/i18n">

<!-- Basic metadata -->
<property name="title" i18n:translate="">Person</property>
<property name="description" i18n:translate="">A Person related to an
Issue</property>
<property name="content_icon">user.gif</property>
<property name="allow_discussion">True</property>
<property name="global_allow">True</property>
<property name="filter_content_types">No</property>
<property name="allowed_content_types" />

<!-- schema interface -->
<property name="schema">sinar.corruptiontracker.person.IPerson</property>

<!-- class used for content items -->
<property name="klass">plone.dexterity.content.Item</property>

<!-- add permission -->
<property name="add_permission">cmf.AddPortalContent</property>

<!-- enabled behaviors -->
<property name="behaviors">
<element value="plone.app.content.interfaces.INameFromTitle" />
<element value="plone.app.dexterity.behaviors.metadata.IDublinCore"
/>
</property>

<!-- View information -->
<property name="default_view">view</property>
<property name="default_view_fallback">False</property>
<property name="view_methods">
<element value="view"/>
</property>


<!-- Method aliases -->
<alias from="(Default)" to="(dynamic view)"/>
<alias from="edit" to="@@edit"/>
<alias from="sharing" to="@@sharing"/>
<alias from="view" to="(selected layout)"/>

<!-- Actions -->
<action title="View" action_id="view" category="object" condition_expr=""
url_expr="string:${object_url}" visible="True">
<permission value="View"/>
</action>
<action title="Edit" action_id="edit" category="object" condition_expr=""
url_expr="string:${object_url}/edit" visible="True">
<permission value="Modify portal content"/>
</action>
</object>

0 comments on commit b00e2d9

Please sign in to comment.