#!/usr/bin/env python




##################################################
## DEPENDENCIES
import sys
import os
import os.path
try:
    import builtins as builtin
except ImportError:
    import __builtin__ as builtin
from os.path import getmtime, exists
import time
import types
from Cheetah.Version import MinCompatibleVersion as RequiredCheetahVersion
from Cheetah.Version import MinCompatibleVersionTuple as RequiredCheetahVersionTuple
from Cheetah.Template import Template
from Cheetah.DummyTransaction import *
from Cheetah.NameMapper import NotFound, valueForName, valueFromSearchList, valueFromFrameOrSearchList
from Cheetah.CacheRegion import CacheRegion
import Cheetah.Filters as Filters
import Cheetah.ErrorCatchers as ErrorCatchers
from prewikka.templates.ClassicLayout import ClassicLayout

##################################################
## MODULE CONSTANTS
VFFSL=valueFromFrameOrSearchList
VFSL=valueFromSearchList
VFN=valueForName
currentTime=time.time
__CHEETAH_version__ = '2.4.4'
__CHEETAH_versionTuple__ = (2, 4, 4, 'development', 0)
__CHEETAH_genTime__ = 1313541192.076537
__CHEETAH_genTimestamp__ = 'Tue Aug 16 18:33:12 2011'
__CHEETAH_src__ = 'prewikka/templates/UserListing.tmpl'
__CHEETAH_srcLastModified__ = 'Tue May  5 08:55:59 2009'
__CHEETAH_docstring__ = 'Autogenerated by Cheetah: The Python-Powered Template Engine'

if __CHEETAH_versionTuple__ < RequiredCheetahVersionTuple:
    raise AssertionError(
      'This template was compiled with Cheetah version'
      ' %s. Templates compiled before version %s must be recompiled.'%(
         __CHEETAH_version__, RequiredCheetahVersion))

##################################################
## CLASSES

class UserListing(ClassicLayout):

    ##################################################
    ## CHEETAH GENERATED METHODS


    def __init__(self, *args, **KWs):

        super(UserListing, self).__init__(*args, **KWs)
        if not self._CHEETAH__instanceInitialized:
            cheetahKWArgs = {}
            allowedKWs = 'searchList namespaces filter filtersLib errorCatcher'.split()
            for k,v in KWs.items():
                if k in allowedKWs: cheetahKWArgs[k] = v
            self._initCheetahInstance(**cheetahKWArgs)
        

    def main_content(self, **KWS):



        ## CHEETAH: generated from #block main_content at line 3, col 1.
        trans = KWS.get("trans")
        if (not trans and not self._CHEETAH__isBuffering and not callable(self.transaction)):
            trans = self.transaction # is None unless self.awake() was called
        if not trans:
            trans = DummyTransaction()
            _dummyTrans = True
        else: _dummyTrans = False
        write = trans.response().write
        SL = self._CHEETAH__searchList
        _filter = self._CHEETAH__currentFilter
        
        ########################################
        ## START - generated method body
        
        _orig_filter_92834004 = _filter
        filterName = u'CleanOutput'
        if self._CHEETAH__filters.has_key("CleanOutput"):
            _filter = self._CHEETAH__currentFilter = self._CHEETAH__filters[filterName]
        else:
            _filter = self._CHEETAH__currentFilter = \
			self._CHEETAH__filters[filterName] = getattr(self._CHEETAH__filtersLib, filterName)(self).filter
        write(u'''
<form action="?" method="post">
<input type="hidden" name="view" value="user_delete"/>

<table class="user_list_table">
  <thead>
    <tr>
      <td>''')
        if False:
            _("Login")
        _v = VFFSL(SL,"_",False)("Login") # u'$_("Login")' on line 12, col 11
        if _v is not None: write(_filter(_v, rawExpr=u'$_("Login")')) # from line 12, col 11.
        write(u'''</td>
''')
        perm_cnt = 2
        for perm in VFFSL(SL,"permissions",True): # generated from line 14, col 9
            perm_cnt += 1
            write(u'''          <td>''')
            _v = VFN(VFFSL(SL,"perm",True),"replace",False)("_", " ")
            if _v is not None: write(_filter(_v))
            write(u'''</td>
''')
        write(u'''      </tr>
  </thead>
  <tbody>
''')
        row_classes = ("table_row_even", "table_row_odd")
        cnt = 0
        for user in VFFSL(SL,"users",True): # generated from line 23, col 3
            write(u'''    <tr class="''')
            _v = VFFSL(SL,"row_classes",True)[VFFSL(SL,"cnt",True)%2] # u'$row_classes[$cnt%2]' on line 24, col 16
            if _v is not None: write(_filter(_v, rawExpr=u'$row_classes[$cnt%2]')) # from line 24, col 16.
            write(u'''">
      <td><a href="''')
            _v = VFFSL(SL,"user.settings_link",True) # u'$user.settings_link' on line 25, col 20
            if _v is not None: write(_filter(_v, rawExpr=u'$user.settings_link')) # from line 25, col 20.
            write(u'''">''')
            _v = VFFSL(SL,"user.login",True) # u'$user.login' on line 25, col 41
            if _v is not None: write(_filter(_v, rawExpr=u'$user.login')) # from line 25, col 41.
            write(u'''</a></td>
''')
            for perm in VFFSL(SL,"user.permissions",True): # generated from line 26, col 7
                perm = ("", "x")[VFFSL(SL,"perm",True)]
                write(u'''        <td>''')
                _v = VFFSL(SL,"perm",True) # u'$perm' on line 28, col 13
                if _v is not None: write(_filter(_v, rawExpr=u'$perm')) # from line 28, col 13.
                write(u'''</td>
''')
            write(u'''      <td><input class="checkbox" type="checkbox" name="users" value="''')
            _v = VFFSL(SL,"user.login",True) # u'$user.login' on line 30, col 71
            if _v is not None: write(_filter(_v, rawExpr=u'$user.login')) # from line 30, col 71.
            write(u'''"/></td>
    </tr>
''')
            cnt += 1
        write(u'''
  <tr>
    <td colspan="''')
        _v = VFFSL(SL,"perm_cnt",True) # u'$perm_cnt' on line 36, col 18
        if _v is not None: write(_filter(_v, rawExpr=u'$perm_cnt')) # from line 36, col 18.
        write(u'''" style="text-align: right;">
''')
        if VFFSL(SL,"backend_can_delete",True): # generated from line 37, col 1
            write(u'''     <input style="float: right;" type="submit" value="''')
            if False:
                _("Delete user")
            _v = VFFSL(SL,"_",False)("Delete user") # u'$_("Delete user")' on line 38, col 56
            if _v is not None: write(_filter(_v, rawExpr=u'$_("Delete user")')) # from line 38, col 56.
            write(u'''"/>
''')
        write(u'''     </form>

''')
        if VFFSL(SL,"backend_can_create",True): # generated from line 42, col 1
            write(u'''     <form action="?" method="get">
      <input type="hidden" name="view" value="user_add_form"/>
      <input style="float: left;" type="submit" value="''')
            if False:
                _("Create user")
            _v = VFFSL(SL,"_",False)("Create user") # u'$_("Create user")' on line 45, col 56
            if _v is not None: write(_filter(_v, rawExpr=u'$_("Create user")')) # from line 45, col 56.
            write(u'''"/>
     </form>
''')
        write(u'''
    </td>
  </tr>

  </tbody>
</table>
</form>

''')
        _filter = self._CHEETAH__currentFilter = _orig_filter_92834004
        
        ########################################
        ## END - generated method body
        
        return _dummyTrans and trans.response().getvalue() or ""
        

    def writeBody(self, **KWS):



        ## CHEETAH: main method generated for this template
        trans = KWS.get("trans")
        if (not trans and not self._CHEETAH__isBuffering and not callable(self.transaction)):
            trans = self.transaction # is None unless self.awake() was called
        if not trans:
            trans = DummyTransaction()
            _dummyTrans = True
        else: _dummyTrans = False
        write = trans.response().write
        SL = self._CHEETAH__searchList
        _filter = self._CHEETAH__currentFilter
        
        ########################################
        ## START - generated method body
        
        write(u'''
''')
        self.main_content(trans=trans)
        
        ########################################
        ## END - generated method body
        
        return _dummyTrans and trans.response().getvalue() or ""
        
    ##################################################
    ## CHEETAH GENERATED ATTRIBUTES


    _CHEETAH__instanceInitialized = False

    _CHEETAH_version = __CHEETAH_version__

    _CHEETAH_versionTuple = __CHEETAH_versionTuple__

    _CHEETAH_genTime = __CHEETAH_genTime__

    _CHEETAH_genTimestamp = __CHEETAH_genTimestamp__

    _CHEETAH_src = __CHEETAH_src__

    _CHEETAH_srcLastModified = __CHEETAH_srcLastModified__

    _mainCheetahMethod_for_UserListing= 'writeBody'

## END CLASS DEFINITION

if not hasattr(UserListing, '_initCheetahAttributes'):
    templateAPIClass = getattr(UserListing, '_CHEETAH_templateClass', Template)
    templateAPIClass._addCheetahPlumbingCodeToClass(UserListing)


# CHEETAH was developed by Tavis Rudd and Mike Orr
# with code, advice and input from many other volunteers.
# For more information visit http://www.CheetahTemplate.org/

##################################################
## if run from command line:
if __name__ == '__main__':
    from Cheetah.TemplateCmdLineIface import CmdLineIface
    CmdLineIface(templateObj=UserListing()).run()


