Skip to content

Commit

Permalink
testing own sessions view
Browse files Browse the repository at this point in the history
  • Loading branch information
robdayz committed Jul 27, 2018
1 parent 8ff454e commit 0524984
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 15 deletions.
79 changes: 65 additions & 14 deletions genweb/organs/search.pt
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,18 @@

<div class="row-fluid" tal:condition="not:view/isAnon">

<table tal:define="organs view/getOwnOrgans"
<table tal:define="organs view/getAllOwnOrgans"
class="table table-bordered table-condensed table-hover logFont">
<thead>
<tr>
<th>
<span i18n:translate="">Title / Code</span>
<span i18n:translate="">TEMP ID / TITLE</span>
</th>
<th>
<tal:head i18n:translate="">Roles</tal:head>
</th>
</tr>
</thead>
<!--
<tal:objects repeat="organ organs">
<tr>
<td >
Expand All @@ -53,25 +52,77 @@
<span tal:content="organ/roles"> Roles </span>
</td>
</tr>
</tal:objects> -->
</tal:objects>
</table>
</div>

<div tal:define="organs view/getOwnOrgans">
<div tal:define="organs view/getOwnOrgans;
secretari python:organs[0];
editor python:organs[1];
membre python:organs[2];
afectat python:organs[3]">
<div class="box box-gradient">
<h3 class="liniaBaix"><span class="fa fa-thumb-tack"></span>&nbsp;Organs relacionats amb mi</h3>
<div tal:condition="organs/secretari">
Secretari
<div tal:condition="secretari">
<h2> Organs com a Secretari </h2>
<tal:objects repeat="organ secretari">
<ul>
<li >
<a href="" tal:attributes="href organ/path">
<span tal:content="organ/id"> Title </span>
</a>
</li>
<li>
<span tal:content="organ/roles"> Roles </span>
</li>
</ul>
</tal:objects>
</div>
<!-- <div tal:condition="organs/editor">
Editor
<div tal:condition="editor">
<h2> Organs com a Editor </h2>
<tal:objects repeat="organ editor">
<ul>
<li >
<a href="" tal:attributes="href organ/path">
<span tal:content="organ/id"> Title </span>
</a>
</li>
<li>
<span tal:content="organ/roles"> Roles </span>
</li>
</ul>
</tal:objects>
</div>
<div tal:condition="organs/membre">
Membre
<div tal:condition="membre">
<h2> Organs com a Membre </h2>
<tal:objects repeat="organ membre">
<ul>
<li >
<a href="" tal:attributes="href organ/path">
<span tal:content="organ/id"> Title </span>
</a>
</li>
<li>
<span tal:content="organ/roles"> Roles </span>
</li>
</ul>
</tal:objects>
</div>
<div tal:condition="afectat">
<h2> Organs com a Afectat </h2>
<tal:objects repeat="organ afectat">
<ul>
<li >
<a href="" tal:attributes="href organ/path">
<span tal:content="organ/id"> Title </span>
</a>
</li>
<li>
<span tal:content="organ/roles"> Roles </span>
</li>
</ul>
</tal:objects>
</div>
<div tal:condition="organs/afectat">
Afectat
</div> -->
</div>
</div>

Expand Down
20 changes: 19 additions & 1 deletion genweb/organs/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,24 @@ def isAnon(self):
return False
return True

def getAllOwnOrgans(self):
results = []
portal_catalog = getToolByName(self, 'portal_catalog')
root_path = '/'.join(api.portal.get().getPhysicalPath()) # /998/govern
lt = getToolByName(self, 'portal_languages')
lang = lt.getPreferredLanguage()
values = portal_catalog.unrestrictedSearchResults(
portal_type=['genweb.organs.sessio'],
sort_on='created',
path=root_path + '/' + lang)
for obj in values:
organ = obj._unrestrictedGetObject()
username = api.user.get_current().id
roles = api.user.get_roles(username=username, obj=organ)
sessionpath = organ.absolute_url()
results.append(dict(path=sessionpath, id=organ.title, roles=roles))
return results

def getOwnOrgans(self):
secretari = []
editor = []
Expand All @@ -64,7 +82,7 @@ def getOwnOrgans(self):
membre.append(dict(path=sessionpath, id=organ.title, roles=roles))
if 'OG4-Afectat' in roles:
afectat.append(dict(path=sessionpath, id=organ.title, roles=roles))
return secretari
return secretari, editor, membre, afectat

valid_keys = ('sort_on', 'sort_order', 'sort_limit', 'fq', 'fl', 'facet')

Expand Down

0 comments on commit 0524984

Please sign in to comment.