Skip to content

Commit

Permalink
testing private organs
Browse files Browse the repository at this point in the history
  • Loading branch information
robdayz committed Jul 27, 2018
1 parent be6c231 commit 8ff454e
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 6 deletions.
54 changes: 48 additions & 6 deletions genweb/organs/search.pt
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,55 @@

<div tal:content="structure view/getPage"></div>

<!-- <div class="row-fluid" tal:condition="not:view/isAnon">
<div class="span12">
<div class="box box-gradient clearfix">
<h3 class="liniaBaix"><span class="fa fa-thumb-tack"></span>&nbsp;Organs relacionats amb mi</h3>
</div>
<div class="row-fluid" tal:condition="not:view/isAnon">

<table tal:define="organs view/getOwnOrgans"
class="table table-bordered table-condensed table-hover logFont">
<thead>
<tr>
<th>
<span i18n:translate="">Title / Code</span>
</th>
<th>
<tal:head i18n:translate="">Roles</tal:head>
</th>
</tr>
</thead>
<!--
<tal:objects repeat="organ organs">
<tr>
<td >
<a href="" tal:attributes="href organ/path">
<span tal:content="organ/id"> Title </span>
</a>
</td>
<td>
<span tal:content="organ/roles"> Roles </span>
</td>
</tr>
</tal:objects> -->
</table>
</div>

<div tal:define="organs view/getOwnOrgans">
<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>
<!-- <div tal:condition="organs/editor">
Editor
</div>
</div> -->
<div tal:condition="organs/membre">
Membre
</div>
<div tal:condition="organs/afectat">
Afectat
</div> -->
</div>
</div>

<div class="clearfix"></div>
<form name="searchform"
action="@@search"
class="searchPage enableAutoFocus"
Expand Down
28 changes: 28 additions & 0 deletions genweb/organs/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,34 @@ def isAnon(self):
return False
return True

def getOwnOrgans(self):
secretari = []
editor = []
membre = []
afectat = []
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()
if 'OG1-Secretari' in roles:
secretari.append(dict(path=sessionpath, id=organ.title, roles=roles))
if 'OG2-Editor' in roles:
editor.append(dict(path=sessionpath, id=organ.title, roles=roles))
if 'OG3-Membre' in roles:
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

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

def results(self, query=None, batch=True, b_size=50, b_start=0):
Expand Down

0 comments on commit 8ff454e

Please sign in to comment.