summaryrefslogtreecommitdiffstats
path: root/idp/extra/modules/identities_ui.ptl
diff options
context:
space:
mode:
authorFrederic Peters <fpeters@0d.be>2008-05-02 08:53:12 (GMT)
committerFrederic Peters <fpeters@0d.be>2008-05-02 08:53:12 (GMT)
commita8858842c490a9d290220f432f16cfdc948318ef (patch)
treea1055a48668786dfb860d61960db7a8281ef2a57 /idp/extra/modules/identities_ui.ptl
parentb48c0515cfdfc85831e2996807217b310700f1fb (diff)
downloadpratic-a8858842c490a9d290220f432f16cfdc948318ef.zip
pratic-a8858842c490a9d290220f432f16cfdc948318ef.tar.gz
pratic-a8858842c490a9d290220f432f16cfdc948318ef.tar.bz2
search on first and last name and sirh code
Diffstat (limited to 'idp/extra/modules/identities_ui.ptl')
-rw-r--r--idp/extra/modules/identities_ui.ptl85
1 files changed, 67 insertions, 18 deletions
diff --git a/idp/extra/modules/identities_ui.ptl b/idp/extra/modules/identities_ui.ptl
index 53ae7da..5c3e998 100644
--- a/idp/extra/modules/identities_ui.ptl
+++ b/idp/extra/modules/identities_ui.ptl
@@ -187,12 +187,13 @@ class IdentitiesDirectory(Directory):
if user.is_admin() and not self.collectivity:
# list all collectivities
- form = Form(action = 'lookup_sirh')
- form.add(StringWidget, 'sirh', title = _('Search on SIRH Code'),
- size = 10)
- #form.add_submit('submit', _('Search'))
+ form = Form()
+ form.add(StringWidget, 'search', title = _('Search'))
form.render()
+ if form.is_submitted():
+ return self.all_search_results(form.get_widget('search').parse())
+
'<ul>'
for collectivity in directory.get_sorted_collectivities():
'<li><a href="%s/">' % collectivity.ou
@@ -210,22 +211,33 @@ class IdentitiesDirectory(Directory):
'- <a href="authorizations">%s</a>' % _('Manage Authorizations')
'</p>'
- current_letter = get_request().form.get('letter', 'A')
- if str(current_letter) not in string.letters:
- current_letter = 'A'
- '<div class="letters-nav">'
- for letter in string.uppercase:
- if letter == current_letter:
- '<span class="current-letter">%s</span>' % letter
- else:
- '<a href="?letter=%s">%s</a>' % (letter, letter)
- if letter != string.uppercase[-1]:
- '-'
- '</div>'
+
+ form = Form()
+ form.add(StringWidget, 'search', title = _('Search'))
+ form.render()
+
+ if form.is_submitted():
+ agents = directory.search_agents(self.collectivity,
+ form.get_widget('search').parse(), sorted = True)
+ else:
+ current_letter = get_request().form.get('letter', 'A')
+ if str(current_letter) not in string.letters:
+ current_letter = 'A'
+ '<div class="letters-nav">'
+ for letter in string.uppercase:
+ if letter == current_letter:
+ '<span class="current-letter">%s</span>' % letter
+ else:
+ '<a href="?letter=%s">%s</a>' % (letter, letter)
+ if letter != string.uppercase[-1]:
+ '-'
+ '</div>'
+
+ agents = directory.get_agents(self.collectivity,
+ first_letter = current_letter, sorted = True)
'<ul class="biglist">'
- for agent in directory.get_agents(self.collectivity,
- first_letter = current_letter, sorted = True):
+ for agent in agents:
if agent.cdg59isDisabled:
'<li class="biglistitem disabled">'
elif agent.cdg59isAdmin:
@@ -245,6 +257,43 @@ class IdentitiesDirectory(Directory):
'<a href="../">%s</a>' % _('Back')
'</p>'
+ def all_search_results [html] (self, query):
+ agents = directory.search_agents(None, query, sorted = True)
+ user = get_session().get_user_object()
+
+ agents.sort(lambda x,y: cmp(x.get_collectivity(), y.get_collectivity()))
+
+ last_col = None
+
+ for agent in agents:
+ agent_col = agent.get_collectivity()
+ if agent_col != last_col:
+ if last_col is not None:
+ '</ul>'
+ '<h2>%s</h2>' % directory.get_collectivity_name(agent_col)
+ '<ul class="biglist">'
+ last_col = agent_col
+
+ if agent.cdg59isDisabled:
+ '<li class="biglistitem disabled">'
+ elif agent.cdg59isAdmin:
+ '<li class="biglistitem admin">'
+ else:
+ '<li class="biglistitem">'
+ '<strong class="label">%s</strong>' % agent.cn
+ '<p class="commands">'
+ command_icon('%s/%s/' % (agent_col, agent.username), 'view')
+ command_icon('%s/%s/edit' % (agent_col, agent.username), 'edit')
+ if user.is_admin():
+ command_icon('%s/%s/delete' % (agent_col, agent.username),
+ 'remove', popup = True)
+ '</p></li>'
+
+ if last_col is not None:
+ '</ul>'
+
+
+
def authorizations [html] (self):
if not self.collectivity:
raise errors.TraversalError()