diff options
author | Kevin McCarthy <kmccarth@redhat.com> | 2007-10-04 17:10:18 -0700 |
---|---|---|
committer | Kevin McCarthy <kmccarth@redhat.com> | 2007-10-04 17:10:18 -0700 |
commit | d5fedb5f978d7aaa31db9c177286872c6244c12a (patch) | |
tree | f21c78c2ab442d1001f4dcc1e45517bbdb1e64cb /ipa-server/ipa-gui/ipagui/subcontrollers/ipacontroller.py | |
parent | 6f7c918e5922afd3461514ddd58b41c5b86e9691 (diff) | |
download | freeipa.git-d5fedb5f978d7aaa31db9c177286872c6244c12a.tar.gz freeipa.git-d5fedb5f978d7aaa31db9c177286872c6244c12a.tar.xz freeipa.git-d5fedb5f978d7aaa31db9c177286872c6244c12a.zip |
Split the controllers out into separate user and group controllers.
Diffstat (limited to 'ipa-server/ipa-gui/ipagui/subcontrollers/ipacontroller.py')
-rw-r--r-- | ipa-server/ipa-gui/ipagui/subcontrollers/ipacontroller.py | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/ipa-server/ipa-gui/ipagui/subcontrollers/ipacontroller.py b/ipa-server/ipa-gui/ipagui/subcontrollers/ipacontroller.py new file mode 100644 index 00000000..77ebe8dd --- /dev/null +++ b/ipa-server/ipa-gui/ipagui/subcontrollers/ipacontroller.py @@ -0,0 +1,58 @@ +import cherrypy +import turbogears +from turbogears import controllers, expose, flash +from turbogears import validators, validate +from turbogears import widgets, paginate +from turbogears import error_handler +from turbogears import identity + +class IPAController(controllers.Controller): + def restrict_post(self): + if cherrypy.request.method != "POST": + turbogears.flash("This method only accepts posts") + raise turbogears.redirect("/") + + def utf8_encode(self, value): + if value != None: + value = value.encode('utf-8') + return value + + def sort_group_member(self, a, b): + """Comparator function used for sorting group members.""" + if a.getValue('uid') and b.getValue('uid'): + if a.getValue('givenname') == b.getValue('givenname'): + if a.getValue('sn') == b.getValue('sn'): + if a.getValue('uid') == b.getValue('uid'): + return 0 + elif a.getValue('uid') < b.getValue('uid'): + return -1 + else: + return 1 + elif a.getValue('sn') < b.getValue('sn'): + return -1 + else: + return 1 + elif a.getValue('givenname') < b.getValue('givenname'): + return -1 + else: + return 1 + elif a.getValue('uid'): + return -1 + elif b.getValue('uid'): + return 1 + else: + if a.getValue('cn') == b.getValue('cn'): + return 0 + elif a.getValue('cn') < b.getValue('cn'): + return -1 + else: + return 1 + + def sort_by_cn(self, a, b): + """Comparator function used for sorting groups.""" + if a.getValue('cn') == b.getValue('cn'): + return 0 + elif a.getValue('cn') < b.getValue('cn'): + return -1 + else: + return 1 |