#!/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__ = 1313541191.904031
__CHEETAH_genTimestamp__ = 'Tue Aug 16 18:33:11 2011'
__CHEETAH_src__ = 'prewikka/templates/UserSettings.tmpl'
__CHEETAH_srcLastModified__ = 'Wed Jun 10 03:40:28 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 UserSettings(ClassicLayout):

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


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

        super(UserSettings, 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 layout_start_hook(self, **KWS):



        ## CHEETAH: generated from #def layout_start_hook 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
        
        write(u'''
<script type="text/javascript">

<!--

$(document).ready(function() {
  $("#allbox").click(function(){
    $(\'input[name="permissions"]\').check($(this).attr(\'checked\'));
  });
});

//--></script>
''')
        
        ########################################
        ## END - generated method body
        
        return _dummyTrans and trans.response().getvalue() or ""
        

    def main_content(self, **KWS):



        ## CHEETAH: generated from #block main_content at line 18, 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_34418723 = _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'''
<div id="fieldset_page" style="width: 430px;">

<form id="usersettings" action="?" method="post">
''')
        if VFFSL(SL,"user.login",True): # generated from line 24, col 1
            write(u'''<input type="hidden" name="login" value="''')
            _v = VFFSL(SL,"user.login",True) # u'$user.login' on line 25, col 42
            if _v is not None: write(_filter(_v, rawExpr=u'$user.login')) # from line 25, col 42.
            write(u'''"/>
<input type="hidden" name="view" value="user_settings_modify"/>
''')
        else: # generated from line 27, col 1
            write(u'''<input type="hidden" name="view" value="user_settings_add"/>
''')
        write(u'''
''')
        if VFFSL(SL,"user.origin",True): # generated from line 31, col 1
            write(u'''<input type="hidden" name="origin" value="''')
            _v = VFFSL(SL,"user.origin",True) # u'$user.origin' on line 32, col 43
            if _v is not None: write(_filter(_v, rawExpr=u'$user.origin')) # from line 32, col 43.
            write(u'''" />
''')
        write(u'''
<fieldset class="fieldset_heading">
 <legend>''')
        if False:
            _("Account information")
        _v = VFFSL(SL,"_",False)("Account information") # u'$_("Account information")' on line 36, col 10
        if _v is not None: write(_filter(_v, rawExpr=u'$_("Account information")')) # from line 36, col 10.
        write(u'''</legend>

  <table>
''')
        if VFFSL(SL,"user.login",True): # generated from line 39, col 1
            write(u'''   <tr>
    <th style="vertical-align: middle;">''')
            if False:
                _("Login:")
            _v = VFFSL(SL,"_",False)("Login:") # u'$_("Login:")' on line 41, col 41
            if _v is not None: write(_filter(_v, rawExpr=u'$_("Login:")')) # from line 41, col 41.
            write(u'''</th>
    <td style="text-align:right; vertical-align: middle;">
     <h2 style="vertical-align: middle; padding:0px; margin:0px;"><b>''')
            _v = VFFSL(SL,"user.login",True) # u'$user.login' on line 43, col 70
            if _v is not None: write(_filter(_v, rawExpr=u'$user.login')) # from line 43, col 70.
            write(u'''</b></h2>
    </td>
   </tr>
''')
        else: # generated from line 46, col 1
            write(u'''
''')
            if VFFSL(SL,"errmsg",True): # generated from line 48, col 4
                write(u'''   <tr>
\t<td colspan=2><font style="color: red;">''')
                _v = VFFSL(SL,"errmsg",True) # u'$errmsg' on line 50, col 42
                if _v is not None: write(_filter(_v, rawExpr=u'$errmsg')) # from line 50, col 42.
                write(u'''</font></td>
   </tr>
''')
            write(u'''
   <tr>
    <th>Login:</th>
    <td style="text-align: right;"><input type="text" name="login"/></td>
   </tr>
''')
        write(u'''
   <tr>
    <th style="vertical-align: middle;">''')
        if False:
            _("Language:")
        _v = VFFSL(SL,"_",False)("Language:") # u'$_("Language:")' on line 61, col 41
        if _v is not None: write(_filter(_v, rawExpr=u'$_("Language:")')) # from line 61, col 41.
        write(u'''</th>
    <td style="text-align:right; vertical-align: middle;">
     <select name="language">
''')
        for lang, identifier in VFFSL(SL,"available_languages",True): # generated from line 64, col 1
            if VFFSL(SL,"user.language",True) == VFFSL(SL,"identifier",True): # generated from line 65, col 1
                selected = " selected=true"
            else: # generated from line 67, col 1
                selected = ""
            write(u'''     <option value="''')
            _v = VFFSL(SL,"identifier",True) # u'$identifier' on line 70, col 21
            if _v is not None: write(_filter(_v, rawExpr=u'$identifier')) # from line 70, col 21.
            write(u'''"''')
            _v = VFFSL(SL,"selected",True) # u'$selected' on line 70, col 33
            if _v is not None: write(_filter(_v, rawExpr=u'$selected')) # from line 70, col 33.
            write(u'''>''')
            _v = VFFSL(SL,"lang",True) # u'$lang' on line 70, col 43
            if _v is not None: write(_filter(_v, rawExpr=u'$lang')) # from line 70, col 43.
            write(u'''</option>
''')
        write(u'''     </select>
    </td>
   </tr>
   

''')
        row_classes = ("table_row_even", "table_row_odd")
        write(u'''
<tr class="nodash" style="padding:0; margin:0;">
 <th class="nodash">''')
        if False:
            _("Permissions:")
        _v = VFFSL(SL,"_",False)("Permissions:") # u'$_("Permissions:")' on line 80, col 21
        if _v is not None: write(_filter(_v, rawExpr=u'$_("Permissions:")')) # from line 80, col 21.
        write(u'''</th>
 <td class="nodash"></td>
</tr>

<tr style="padding:0; margin:0;">
 <td colspan=2>
 <table>

''')
        cnt = 0
        checked_cnt = 0
        write(u'''
''')
        if VFFSL(SL,"can_manage_user",True): # generated from line 91, col 1
            disabled = ""
        else: # generated from line 93, col 1
            disabled = "disabled=\"disabled\""
        write(u'''
''')
        for perm, value in VFFSL(SL,"user.permissions",True): # generated from line 97, col 7
            write(u'''      <tr class="''')
            _v = VFFSL(SL,"row_classes",True)[VFFSL(SL,"cnt",True)%2] # u'$row_classes[$cnt%2]' on line 98, col 18
            if _v is not None: write(_filter(_v, rawExpr=u'$row_classes[$cnt%2]')) # from line 98, col 18.
            write(u'''">
       <td style="text-align: left;">''')
            _v = VFFSL(SL,"perm",True) # u'$perm' on line 99, col 38
            if _v is not None: write(_filter(_v, rawExpr=u'$perm')) # from line 99, col 38.
            write(u'''</td>
       <td style="text-align: right;">
''')
            if VFFSL(SL,"value",True): # generated from line 101, col 9
                checked_cnt += 1
                checked = "checked=\"checked\""
            else: # generated from line 104, col 9
                checked = ""
            write(u'''        <input class="checkbox" type="checkbox" name="permissions" value="''')
            _v = VFFSL(SL,"perm",True) # u'$perm' on line 107, col 75
            if _v is not None: write(_filter(_v, rawExpr=u'$perm')) # from line 107, col 75.
            write(u'''" ''')
            _v = VFFSL(SL,"checked",True) # u'$checked' on line 107, col 82
            if _v is not None: write(_filter(_v, rawExpr=u'$checked')) # from line 107, col 82.
            write(u''' ''')
            _v = VFFSL(SL,"disabled",True) # u'$disabled' on line 107, col 91
            if _v is not None: write(_filter(_v, rawExpr=u'$disabled')) # from line 107, col 91.
            write(u''' />
       </td>
      </tr>
''')
            cnt += 1
        write(u'''<tr class="nodash">
 <td class="nodash">&nbsp;</td>

''')
        if VFFSL(SL,"cnt",True) == VFFSL(SL,"checked_cnt",True): # generated from line 115, col 1
            checked = "checked=\"checked\""
        else: # generated from line 117, col 1
            checked = ""
        write(u'''
 <td class="nodash"style="text-align: right;"><b>''')
        if False:
            _("Check All")
        _v = VFFSL(SL,"_",False)("Check All") # u'$_("Check All")' on line 121, col 50
        if _v is not None: write(_filter(_v, rawExpr=u'$_("Check All")')) # from line 121, col 50.
        write(u'''</b>
  <input ''')
        _v = VFFSL(SL,"checked",True) # u'$checked' on line 122, col 10
        if _v is not None: write(_filter(_v, rawExpr=u'$checked')) # from line 122, col 10.
        write(u''' ''')
        _v = VFFSL(SL,"disabled",True) # u'$disabled' on line 122, col 19
        if _v is not None: write(_filter(_v, rawExpr=u'$disabled')) # from line 122, col 19.
        write(u''' class="checkbox" type="checkbox" id="allbox"/>
 </td>
</tr>

     </table>
</td></tr>

</table>
</fieldset>
<br/>

''')
        if VFFSL(SL,"can_change_password",True): # generated from line 133, col 1
            write(u'''<fieldset>
  <legend>''')
            if False:
                _("Change password")
            _v = VFFSL(SL,"_",False)("Change password") # u'$_("Change password")' on line 135, col 11
            if _v is not None: write(_filter(_v, rawExpr=u'$_("Change password")')) # from line 135, col 11.
            write(u'''</legend>
  <table>
''')
            if VFFSL(SL,"ask_current_password",True): # generated from line 137, col 5
                write(u'''    <tr>
      <th>''')
                if False:
                    _("Current password:")
                _v = VFFSL(SL,"_",False)("Current password:") # u'$_("Current password:")' on line 139, col 11
                if _v is not None: write(_filter(_v, rawExpr=u'$_("Current password:")')) # from line 139, col 11.
                write(u'''</th>
      <td><input type="password" name="password_current"/></td>
    </tr>
''')
            write(u'''    <tr>
      <th>''')
            if False:
                _("New password:")
            _v = VFFSL(SL,"_",False)("New password:") # u'$_("New password:")' on line 144, col 11
            if _v is not None: write(_filter(_v, rawExpr=u'$_("New password:")')) # from line 144, col 11.
            write(u'''</th>
      <td><input type="password" name="password_new"/></td>
    </tr>
    <tr>
      <th>''')
            if False:
                _("Confirm new password:")
            _v = VFFSL(SL,"_",False)("Confirm new password:") # u'$_("Confirm new password:")' on line 148, col 11
            if _v is not None: write(_filter(_v, rawExpr=u'$_("Confirm new password:")')) # from line 148, col 11.
            write(u'''</th>
      <td><input type="password" name="password_new_confirmation"/></td>
    </tr>
  </table>
</fieldset>
<br/>
''')
        write(u'''
<input type="submit" value="''')
        if False:
            _("Submit Changes")
        _v = VFFSL(SL,"_",False)("Submit Changes") # u'$_("Submit Changes")' on line 156, col 29
        if _v is not None: write(_filter(_v, rawExpr=u'$_("Submit Changes")')) # from line 156, col 29.
        write(u'''"/>

</form>
</div>

''')
        _filter = self._CHEETAH__currentFilter = _orig_filter_34418723
        
        ########################################
        ## 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_UserSettings= 'writeBody'

## END CLASS DEFINITION

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


# 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=UserSettings()).run()


