def form_changepassword(self, ctx): form = formal.Form() g = formalutils.CollapsibleGroup('changepassword', label='Change Password') g.setCollapsed(False) g.add( formal.Field('pw1', formal.String(required=True), formal.widgetFactory(formalutils.HiddenPassword), label='Old password')) g.add( formal.Field('pw2', formal.String(required=True), formal.widgetFactory(formalutils.HiddenPassword), label='New password')) g.add( formal.Field('pw3', formal.String(required=True), formal.widgetFactory(formalutils.HiddenPassword), label='New password (again)')) sg = formalutils.SubmitFieldGroup('buttons') sg.add( formalutils.SubmitField('changepassword', formal.String(), label='Change password')) g.add(sg) form.add(g) form.addAction(self.submitted, name='changepassword', validate=False) return form
def form_start_install(self, ctx): lbl = 'I have read and accept the License Agreement and the Privacy Policy' form = formal.Form() g = formalutils.CollapsibleGroup( 'startinstall', label='License Agreement and Privacy Policy') g.setCollapsed(False) g.add( formal.Field('acceptlicense', formal.Boolean(required=True), label=lbl)) sg = formalutils.SubmitFieldGroup('buttons') sg.add( formalutils.SubmitField('startinstallation', formal.String(), label='Next')) g.add(sg) form.add(g) form.addAction(self.submitted_start_install, name='startinstallation', label='Next', validate=False) form.data['startinstall.acceptlicense'] = False return form
def form_addTime(self, data): acls = [] for ip, i in self.sysconf.ProxyConfig.get('srcacls', []): acls.append((i,i)) for n, i in self.sysconf.ProxyConfig.get('aclusers', []): acls.append((i,i)) for n, i in self.sysconf.ProxyConfig.get('domacls', []): acls.append((i,i)) form = formal.Form(self.submitTime)[ formal.Field('allow', formal.Boolean(), label = "Allow", description = "Allow traffic at these times"), formal.Field('from', formal.Time(required=True), label = "From time", description = "Starting time (24 hour format)"), formal.Field('to', formal.Time(required=True), label = "To time", description = "Ending time (24 hour format), must be later than the starting time and must not overlap midnight"), formal.Field('domain', formal.String(), label = "Domain", description = "Apply this rule to a specific domain"), formal.Field('exacl', formal.String(), formal.widgetFactory(formal.SelectChoice, options = acls), label = "Extra ACL", description = "Apply this rule to a specific other ACL"), formal.Group('Days')[ [ formal.Field(i, formal.Boolean(), label = i) for i in PageHelpers.days ] ] ] form.data['from'] = datetime.time(0,0) form.data['to'] = datetime.time(23,59) form.addAction(self.submitTime) return form
def form_example(self, ctx): def makeAddressGroup(name): address = formal.Group(name) address.add(formal.Field('address', formal.String())) address.add(formal.Field('city', formal.String())) address.add(formal.Field('postalCode', formal.String())) return address def makePersonGroup(name): person = formal.Group(name, cssClass=name) person.add(formal.Field('name', formal.String(required=True))) person.add(formal.Field('dateOfBirth', formal.Date(required=True))) person.add(makeAddressGroup('address')) return person form = formal.Form() form.add(formal.Field('before', formal.String())) form.add(makePersonGroup('me')) form.add(makePersonGroup('you')) form.add(formal.Field('after', formal.String())) form.addAction(self.submitted) return form
def create_debug_group(self, form, ctx): debug_group = formalutils.CollapsibleGroup('debug_group', label='Debug') debug_group.setCollapsed(False) debug_group.add( formal.Field('debug', formal.Integer( required=True, validators=[formal.RangeValidator(min=0, max=2)]), label='Debug mode (0=normal, 1=light, 2=heavy)')) ui_root = db.get_db().getRoot().getS(ns_ui.uiConfig, rdf.Type(ns_ui.UiConfig)) # Default false if no entry found from the database. debug_fda = formalutils.FormDataAccessor(form, ['debug_group'], ctx) if ui_root.hasS(ns_ui.debug): debug_fda['debug'] = ui_root.getS(ns_ui.debug, rdf.Integer) else: debug_fda['debug'] = 0 return debug_group
def form_config(self, ctx): form = formal.Form( self.submitForm)[formal.Group('topology')[ tags.div[tags.h3["Topology configuration"]], formal.Field('name', formal.String(), label="Name"), formal.Field('topology', formal.String(), formal.widgetFactory(formal.SelectChoice, options=[('master', 'Master'), ('slave', 'Slave')]), label="Topology"), formal.Field( 'ipoverride', formal.Boolean(), label="Take over LAN", description= "Take over the LAN settings of this server on failure."), formal.Field( 'wanoverride', formal.Boolean(), label="Take over WAN", description= "Take over the WAN settings of this server on failure."), #formal.Field('key', formal.String(), label = "Access Key", # description = "On the slave system, configure it to accept HA connections and generate a key which is pasted here") ], formal.Group('failover') [tags.div[tags.h3["Failover services"]], formal. Field('dhcp', formal.Boolean( ), label="DHCP", description= "This server will act as a backup DHCP server" ), formal.Field( 'smtp', formal.Boolean(), label="SMTP", description= "This server will provide backup SMTP routing - NOT POP3/IMAP DELIVERY." ), formal.Field( 'routing', formal.Boolean(), label="Internet Gateway", description= "This server may act as a backup internet gateway in the event that the master goes offline" ), formal.Field( 'dns', formal.Boolean(), label="DNS Server", description= "This server may act as a backup DNS server for all zones" ), formal.Field( 'pdc', formal.Boolean(), label="Domain controller", description= "This server may act as the primary domain controller" )], formal.Group('loadbalance') [tags.div[tags.h3["Load sharing services"]], formal. Field('dhcp', formal.Boolean(), label="DHCP"), formal. Field('smtp', formal.Boolean(), label="SMTP")], ] form.data = self.populateForm() form.addAction(self.submitForm) return form
def makePersonGroup(name): person = formal.Group(name, cssClass=name) person.add(formal.Field('name', formal.String(required=True))) person.add(formal.Field('dateOfBirth', formal.Date(required=True))) person.add(makeAddressGroup('address')) return person
def makeAddressGroup(name): address = formal.Group(name) address.add(formal.Field('address', formal.String())) address.add(formal.Field('city', formal.String())) address.add(formal.Field('postalCode', formal.String())) return address
def form_editForm(self, data): domains = [] if self.avatarId.isAdmin: for i in self.flatFil: thisdom = i.split('dm=')[-1].split(',')[0] if not thisdom in domains: domains.append(thisdom) # Form population userData = self.lc.getUser(self.cid) devList = [] #extList = [] rouList = [] UserExtForm = [] fkeyForm = [] if Settings.sambaDN and self.domain == Settings.defaultDomain and PBXUtils.enabled( ): includeList = [] includeList = self.sysconf.PBXExtensions.get( userData['uid'][0], {'extensions': []})['extensions'] devIncList = self.sysconf.PBXExtensions.get( userData['uid'][0], {'devices': []})['devices'] extList = PBXUtils.getAvaExtenNumSelect(True, includeList) #for ext in PBXUtils.getAvailibleExtensions(): # extList.append((str(ext), str(ext))) for dev in PBXUtils.getAllAvaExtDeviceEndPoints(devIncList): devList.append((str(dev), str(dev))) queueList = [ (queue, queue) for queue in self.sysconf.PBX.get('queues', {}).keys() ] rouList = self.sysconf.PBXRouters.keys() extensionWidget = formal.widgetFactory(formal.SelectChoice, options=extList) deviceWidget = formal.widgetFactory(formal.SelectChoice, options=devList) #queueWidget = formal.widgetFactory(formal.SelectChoice, options = queueList) userExtensions = PBXUtils.getExtensionSelect() queueOptions = formal.widgetFactory(formal.SelectChoice, options=[(1, "Level 1 Member"), (2, "Level 2 Member"), (3, "Level 3 Member") ]) queues = [] for queue in self.sysconf.PBX.get('queues', {}).keys()[0:-1]: queues.append( formal.Field('queue%s' % queue, formal.Integer(), queueOptions, label="Queue %s" % queue)) try: queue = self.sysconf.PBX.get('queues', {}).keys()[-1] except: queue = None if queue: queues.append( formal.Field( 'queue%s' % queue, formal.Integer(), queueOptions, label="Queue %s" % queue, description= "Each extension may be part of many queues, each queue membersip has a specific weighting. The weighting determines the order in which calls may be seeded. Level 2 members only get calls seeded to them once Level 1 has been saturated etc." )) fKeyOptions = formal.widgetFactory(formal.SelectChoice, options=userExtensions) fKeys = [] maxKeys = 54 for i in range(maxKeys): fKeys.append( formal.Field('fkeys%s' % i, formal.String(), fKeyOptions, label="Key %s" % i)) fKeys.append( formal.Field( 'fkeys%s' % maxKeys, formal.String(), fKeyOptions, label="Key %s" % maxKeys, description= "Select the extensions for the function keys above")) userExtFormContent = [ formal.Field('userExtEnabled', formal.Boolean(), label=self.text.userFormLabelExtEnabled), formal.Field('userExtOutbound', formal.Sequence(formal.String()), formal.widgetFactory(formal.CheckboxMultiChoice, options=[(i, i) for i in rouList]), label=self.text.userFormLabelOutbound, description=self.text.userFormDescOutbound), #formal.Field('userExtQueues', formal.Sequence(formal.String()), # formal.widgetFactory(formal.CheckboxMultiChoice, # options = queueList), # label = self.text.userFormLabelQueues, # description = self.text.userFormDescQueues), ] userExtFormContent.extend(queues) userExtFormContent.extend([ formal.Field( 'userLowBW', formal.Boolean(), label="Low Bandwidth", description= 'Indicates that the devices(if applicable) should use a low bandwidth codec' ), formal.Field( 'userExtTimeout', formal.Integer(), label="Timeout", description= "How many seconds should we wait before giving up on this extension, note that setting this to 0 will force the extension to use the default timeout" ), formal.Field( 'userExtqTimeout', formal.Integer(), label="Queue Timeout", description= "How many seconds should we wait before giving up on this queue member, 0 will indicate to use the default" ), formal.Field('userExtCallerID', formal.String(), label=self.text.userFormLabelCallID), formal.Field('userExtNumber0', formal.String(), extensionWidget, label=self.text.userFormLabelExtNumber), formal.Field('userExtNumber1', formal.String(), extensionWidget, label=""), formal.Field('userExtNumber2', formal.String(), extensionWidget, label=""), formal.Field('userExtNumber3', formal.String(), extensionWidget, label=""), formal.Field('userExtNumber4', formal.String(), extensionWidget, label=""), formal.Field('userExtNumber5', formal.String(), extensionWidget, label=""), formal.Field('userExtNumber6', formal.String(), extensionWidget, label=""), formal.Field('userExtNumber7', formal.String(), extensionWidget, label=""), formal.Field('userExtNumber8', formal.String(), extensionWidget, label=""), formal.Field('userExtNumber9', formal.String(), extensionWidget, label=""), tags.div(_class="userLine")[tags.a( href="#", onclick="addExten();")[self.text.userFormLabelAddExt]], #formal.Field('userExtFwdUA', formal.String(), label = self.text.userFormLabelRedNoAnswer, # description = self.text.userFormDescRedNoAnswer), formal.Field('userExtDev0', formal.String(), deviceWidget, label=self.text.userFormLabelDev), formal.Field('userExtDev1', formal.String(), deviceWidget, label=""), formal.Field('userExtDev2', formal.String(), deviceWidget, label=""), formal.Field('userExtDev3', formal.String(), deviceWidget, label=""), formal.Field('userExtDev4', formal.String(), deviceWidget, label=""), formal.Field('userExtDev5', formal.String(), deviceWidget, label=""), formal.Field('userExtDev6', formal.String(), deviceWidget, label=""), formal.Field('userExtDev7', formal.String(), deviceWidget, label=""), formal.Field('userExtDev8', formal.String(), deviceWidget, label=""), formal.Field('userExtDev9', formal.String(), deviceWidget, label=""), tags.div(_class="userLine")[tags.a( href="#", onclick="addExtDev();")[self.text.userFormLabelAddDev]], formal.Field('userExtVoiceMail', formal.Boolean(), label=self.text.userFormLabelVoiceMail), formal.Field('userExtVoiceMailPin', formal.String(), label=self.text.userFormLabelVoiceMailPin), ]) UserExtForm = formal.Group('userExtension')[userExtFormContent] fkeyForm = formal.Group('userFKeys')[fKeys] form = formal.Form( self.submitForm )[formal.Group('userSettings')[tags.div(_class="field")[ tags.label[self.text.userFormLabelEmailAddress], tags.div(id="emailAd", _class="inputs")["%s@%s" % (self.cid, self.domain)]], formal.Field('uid', formal .String(required=True, validators=Base .UserNameValidators), label=self.text. userFormLabelUsername), formal.Field('givenName', formal.String( required=True), label=self.text. userFormLabelName), formal.Field('sn', formal.String(), label=self.text. userFormLabelSurname), formal.Field('userPassword', formal.String(), formal.CheckedPassword, label=self.text. userFormLabelPass), ], formal.Group('mailSettings') [formal.Field('mailForwardingAddress0', formal.String(), label=self. text.userFormLabelForward), formal.Field('mailForwardingAddress1', formal.String(), label=""), formal.Field('mailForwardingAddress2', formal.String(), label=""), formal.Field('mailForwardingAddress3', formal.String(), label=""), formal.Field('mailForwardingAddress4', formal.String(), label=""), formal.Field('mailForwardingAddress5', formal.String(), label=""), formal.Field('mailForwardingAddress6', formal.String(), label=""), formal.Field('mailForwardingAddress7', formal.String(), label=""), formal.Field('mailForwardingAddress8', formal.String(), label=""), formal.Field('mailForwardingAddress9', formal.String(), label=""), tags.div( _class="userLine")[tags.a(href="#", onclick="addForward();" )[self.text.userFormLabelAddline]], formal.Field('mailAlternateAddress0', formal.String(), label=self.text.userFormLabelAlias), formal.Field('mailAlternateAddress1', formal.String(), label=""), formal.Field('mailAlternateAddress2', formal.String(), label=""), formal.Field('mailAlternateAddress3', formal.String(), label=""), formal.Field('mailAlternateAddress4', formal.String(), label=""), formal.Field('mailAlternateAddress5', formal.String(), label=""), formal.Field('mailAlternateAddress6', formal.String(), label=""), formal.Field('mailAlternateAddress7', formal.String(), label=""), formal.Field('mailAlternateAddress8', formal.String(), label=""), formal.Field('mailAlternateAddress9', formal.String(), label=""), tags.div( _class="userLine")[tags.a(href="#", onclick="addAlias();" )[self.text.userFormLabelAddline]], formal.Field('vacen', formal.Boolean(), label=self.text.userFormLabelVacationActive, description=self.text.userFormTextVacationNote), formal.Field('vacation', formal.String(), formal.TextArea, label=self.text.userFormLabelVacation), formal.Field('vacvalidity', formal.Date(), label="Valid until", description= "Disable the vacation note automatically on this date" )], formal.Group('userPermissions')[ formal.Field('employeeType', formal.Boolean(), label=self.text.userFormLabelWeb), formal.Field('accountStatus', formal.Boolean(), label=self.text.userFormLabelEmail), formal.Field('tumsAdmin', formal.Boolean(), label=self.text.userFormLabelAdmin), formal.Field('tumsUser', formal.Sequence(formal.String()), formal.widgetFactory(formal.CheckboxMultiChoice, [( i, i) for i in domains]), label=self.text.userFormLabelDomainAdmin), formal.Field('tumsReports', formal.Boolean(), label=self.text.userFormLabelReports), formal.Field('copyto', formal.String(), label=self.text.userFormLabelCopy, description=self.text.userFormTextCopy)], formal.Group('userAccess')[ formal.Field('vpnEnabled', formal.Boolean(), label=self.text.userFormLabelVPN, description=self.text.userFormTextVPN), formal.Field('ftpEnabled', formal.Boolean(), label=self.text.userFormLabelFTP, description=self.text.userFormTextFTP), formal.Field('ftpGlobal', formal.Boolean(), label=self.text.userFormLabelGlobalFTP, description=self.text.userFormTextGlobal)], UserExtForm, fkeyForm] form.addAction(self.submitForm) tData = copy.deepcopy(userData) tData['userSettings.uid'] = tData['uid'][0] tData['userSettings.givenName'] = tData.get('givenName', [""])[0] tData['userSettings.sn'] = tData.get('sn', [""])[0] if tData.get('loginShell'): if '/bin/bash' in tData['loginShell']: tData['userAccess.ftpEnabled'] = True if self.sysconf.FTP.get('globals'): if tData['uid'][0] in self.sysconf.FTP['globals']: tData['userAccess.ftpGlobal'] = True tData['userSettings.userPassword'] = '' # Strip password address = "%s@%s" % (tData['uid'][0], self.domain) for i in os.listdir('/etc/openvpn/keys/'): if "%s.%s" % (self.cid, self.domain) in i and "key" in i: tData['userAccess.vpnEnabled'] = True if self.sysconf.Mail.get('copys', []): for addr, dest in self.sysconf.Mail['copys']: if addr == address: tData['userPermissions.copyto'] = dest if userData.get('accountStatus', False): tData['userPermissions.accountStatus'] = True else: tData['userPermissions.accountStatus'] = False if userData.get('mailForwardingAddress', False): for cnt, address in enumerate(userData['mailForwardingAddress']): tData['mailSettings.mailForwardingAddress%s' % cnt] = address if userData.get('mailAlternateAddress', False): for cnt, address in enumerate(userData['mailAlternateAddress']): tData['mailSettings.mailAlternateAddress%s' % cnt] = address emp = userData.get('employeeType', [False]) if 'squid' in emp: tData['userPermissions.employeeType'] = True else: tData['userPermissions.employeeType'] = False if 'tumsAdmin' in emp: tData['userPermissions.tumsAdmin'] = True else: tData['userPermissions.tumsAdmin'] = False if 'tumsReports' in emp: tData['userPermissions.tumsReports'] = True else: tData['userPermissions.tumsReports'] = False if emp[0]: for i in emp: if 'tumsUser[' in i: tData['userPermissions.tumsUser'] = i.split('[')[-1].split( ']')[0].split(',') try: vac = open( "/var/spool/mail/vacation/%s@%s.txt" % (self.cid, self.domain), 'r') tData['mailSettings.vacation'] = vac.read() tData['mailSettings.vacen'] = True except: pass # No vacation note try: vac = open( "/var/spool/mail/vacation/DISABLED%s@%s.txt" % (self.cid, self.domain), 'r') tData['mailSettings.vacation'] = vac.read() tData['mailSettings.vacen'] = False except: pass # No disabled note either. if os.path.exists('/var/spool/mail/vacation/%s@%s.validity' % (self.cid, self.domain)): n = open('/var/spool/mail/vacation/%s@%s.validity' % (self.cid, self.domain)).read().strip('\n') d = datetime.date(*[int(i) for i in n.split('-')]) tData['mailSettings.vacvalidity'] = d #Populate Userextension Data if PBXUtils.enabled(): ext = self.sysconf.PBXExtensions.get( tData['uid'][0], { 'enabled': False, 'lowbw': False, 'outbound': [], 'callerID': "", 'voiceMail': False, 'voiceMailPin': '', 'fkeys': [], 'extensions': [], 'devices': [], 'queues': {} }) tData['userExtension.userExtEnabled'] = ext['enabled'] tData['userExtension.userExtOutbound'] = ext['outbound'] tData['userExtension.userExtTimeout'] = ext.get('timeout', 0) tData['userExtension.userExtqTimeout'] = ext.get('qtimeout', 0) #tData['userExtension.userExtQueues'] = ext.get('queues', []) queueSettings = ext.get('queues', {}) if type(queueSettings) == list: n = {} for queue in queueSettings: n[queue] = 1 queueSettings = n for queue in self.sysconf.PBX.get('queues', {}).keys(): tData['userExtension.queue%s' % queue] = queueSettings.get( queue, None) tData['userExtension.userExtCallerID'] = ext['callerID'] tData['userExtension.userExtVoiceMail'] = ext['voiceMail'] tData['userExtension.userExtVoiceMailPin'] = ext['voiceMailPin'] tData['userExtension.userLowBW'] = ext.get('lowbw', False) for i in range(0, 9): try: tData['userExtension.userExtNumber%s' % i] = ext['extensions'][i] except: pass try: tData['userExtension.userExtDev%s' % i] = ext['devices'][i] except: pass for i in range(54): try: tData['userFKeys.fkeys%s' % i] = ext['fkeys'][i] except: pass form.data = tData return form
def form_editForm(self, data): domains = [] if self.avatarId.isAdmin: for i in self.flatFil: thisdom = i.split('dm=')[-1].split(',')[0] if not thisdom in domains: domains.append(thisdom) # Form population l = LDAP.createLDAPConnection(Settings.LDAPServer, 'o='+Settings.LDAPBase, Settings.LDAPManager, Settings.LDAPPass) dc = "%s,%s,o=%s" % (Settings.LDAPPeople, LDAP.domainToDC(self.domain), Settings.LDAPBase) userData = LDAP.getUsers(l, dc, 'uid='+self.cid) if not userData: l.unbind_s() return "Error" form = formal.Form(self.submitForm)[ formal.Group('userSettings')[ tags.div(_class="field")[ tags.label[self.text.userFormLabelEmailAddress], tags.div(id="emailAd", _class="inputs")[ "%s@%s"% (self.cid, self.domain) ] ], formal.Field('uid', formal.String(required=True), label = self.text.userFormLabelUsername), formal.Field('givenName', formal.String(required=True), label = self.text.userFormLabelName), formal.Field('sn', formal.String(), label = self.text.userFormLabelSurname), formal.Field('userPassword', formal.String(), formal.CheckedPassword, label= self.text.userFormLabelPass), ], formal.Group('mailSettings')[ formal.Field('mailForwardingAddress0', formal.String(), label=self.text.userFormLabelForward), formal.Field('mailForwardingAddress1', formal.String(), label=""), formal.Field('mailForwardingAddress2', formal.String(), label=""), formal.Field('mailForwardingAddress3', formal.String(), label=""), formal.Field('mailForwardingAddress4', formal.String(), label=""), formal.Field('mailForwardingAddress5', formal.String(), label=""), formal.Field('mailForwardingAddress6', formal.String(), label=""), formal.Field('mailForwardingAddress7', formal.String(), label=""), formal.Field('mailForwardingAddress8', formal.String(), label=""), formal.Field('mailForwardingAddress9', formal.String(), label=""), tags.div(_class="userLine")[tags.a(href="#", onclick="addForward();")[self.text.userFormLabelAddline]], formal.Field('mailAlternateAddress0', formal.String(), label=self.text.userFormLabelAlias), formal.Field('mailAlternateAddress1', formal.String(), label=""), formal.Field('mailAlternateAddress2', formal.String(), label=""), formal.Field('mailAlternateAddress3', formal.String(), label=""), formal.Field('mailAlternateAddress4', formal.String(), label=""), formal.Field('mailAlternateAddress5', formal.String(), label=""), formal.Field('mailAlternateAddress6', formal.String(), label=""), formal.Field('mailAlternateAddress7', formal.String(), label=""), formal.Field('mailAlternateAddress8', formal.String(), label=""), formal.Field('mailAlternateAddress9', formal.String(), label=""), tags.div(_class="userLine")[tags.a(href="#", onclick="addAlias();")[self.text.userFormLabelAddline]], formal.Field('vacen', formal.Boolean(), label = self.text.userFormLabelVacationActive, description=self.text.userFormTextVacationNote), formal.Field('vacation', formal.String(), formal.TextArea, label=self.text.userFormLabelVacation), ], formal.Group('userPermissions')[ formal.Field('employeeType', formal.Boolean(), label = self.text.userFormLabelWeb), formal.Field('accountStatus', formal.Boolean(), label = self.text.userFormLabelEmail), formal.Field('tumsAdmin', formal.Boolean(), label = self.text.userFormLabelAdmin), formal.Field('tumsUser', formal.Sequence(formal.String()), formal.widgetFactory(formal.CheckboxMultiChoice, [(i,i) for i in domains]), label = self.text.userFormLabelDomainAdmin), formal.Field('tumsReports', formal.Boolean(), label = self.text.userFormLabelReports), formal.Field('copyto', formal.String(), label = self.text.userFormLabelCopy, description = self.text.userFormTextCopy) ], formal.Group('userAccess')[ formal.Field('vpnEnabled', formal.Boolean(), label = self.text.userFormLabelVPN, description = self.text.userFormTextVPN), formal.Field('ftpEnabled', formal.Boolean(), label = self.text.userFormLabelFTP, description = self.text.userFormTextFTP), formal.Field('ftpGlobal', formal.Boolean(), label = self.text.userFormLabelGlobalFTP, description = self.text.userFormTextGlobal) ] ] form.addAction(self.submitForm) tData = copy.deepcopy(userData[0]) tData['userSettings.uid'] = tData['uid'][0] tData['userSettings.givenName'] = tData.get('givenName', [""])[0] tData['userSettings.sn'] = tData.get('sn', [""])[0] if tData.get('loginShell'): if '/bin/bash' in tData['loginShell']: tData['userAccess.ftpEnabled'] = True if self.sysconf.FTP.get('globals'): if tData['uid'][0] in self.sysconf.FTP['globals']: tData['userAccess.ftpGlobal'] = True tData['userSettings.userPassword'] = '' # Strip password address = "%s@%s" % (tData['uid'][0], self.domain) for i in os.listdir('/etc/openvpn/keys/'): if "%s.%s" % (self.cid, self.domain) in i and "key" in i: tData['userAccess.vpnEnabled'] = True if self.sysconf.Mail.get('copys', []): for addr, dest in self.sysconf.Mail['copys']: if addr == address: tData['userPermissions.copyto'] = dest if userData[0].get('accountStatus', False): tData['userPermissions.accountStatus'] = True else: tData['userPermissions.accountStatus'] = False if userData[0].get('mailForwardingAddress', False): for cnt,address in enumerate(userData[0]['mailForwardingAddress']): tData['mailSettings.mailForwardingAddress%s' % cnt] = address if userData[0].get('mailAlternateAddress', False): for cnt,address in enumerate(userData[0]['mailAlternateAddress']): tData['mailSettings.mailAlternateAddress%s' % cnt] = address emp = userData[0].get('employeeType', [False]) if 'squid' in emp: tData['userPermissions.employeeType'] = True else: tData['userPermissions.employeeType'] = False if 'tumsAdmin' in emp: tData['userPermissions.tumsAdmin'] = True else: tData['userPermissions.tumsAdmin'] = False if 'tumsReports' in emp: tData['userPermissions.tumsReports'] = True else: tData['userPermissions.tumsReports'] = False if emp[0]: for i in emp: if 'tumsUser[' in i: tData['userPermissions.tumsUser'] = i.split('[')[-1].split(']')[0].split(',') try: vac = open("/var/spool/mail/vacation/%s@%s.txt" % (self.cid, self.domain), 'r') tData['mailSettings.vacation'] = vac.read() tData['mailSettings.vacen'] = True except: pass # No vacation note try: vac = open("/var/spool/mail/vacation/DISABLED%s@%s.txt" % (self.cid, self.domain), 'r') tData['mailSettings.vacation'] = vac.read() tData['mailSettings.vacen'] = False except: pass # No disabled note either. form.data = tData l.unbind_s() return form
def form_addForm(self, data): domains = [] if self.avatarId.isAdmin: # Resolve domain list for i in self.flatFil: thisdom = i.split('dm=')[-1].split(',')[0] if not thisdom in domains: domains.append(thisdom) form = formal.Form( self.submitForm )[formal.Group('userSettings')[tags.div(_class="field")[ tags.label[self.text.userFormLabelEmailAddress], tags.div(id="emailAd", _class="inputs")["%s@%s" % (self.cid, self.domain)]], formal.Field('uid', formal.String( required=True), label=self.text. userFormLabelUsername), formal.Field('givenName', formal.String( required=True), label=self.text. userFormLabelName), formal.Field('sn', formal.String(), label=self.text. userFormLabelSurname), formal.Field('userPassword', formal.String(), formal.CheckedPassword, label=self.text. userFormLabelPass), ], formal.Group('mailSettings') [formal.Field('mailForwardingAddress0', formal.String(), label=self.text.userFormLabelForward), formal.Field('mailForwardingAddress1', formal.String(), label=""), formal.Field('mailForwardingAddress2', formal.String(), label=""), formal.Field('mailForwardingAddress3', formal.String(), label=""), formal.Field('mailForwardingAddress4', formal.String(), label=""), formal.Field('mailForwardingAddress5', formal.String(), label=""), formal.Field('mailForwardingAddress6', formal.String(), label=""), formal.Field('mailForwardingAddress7', formal.String(), label=""), formal.Field('mailForwardingAddress8', formal.String(), label=""), formal.Field('mailForwardingAddress9', formal.String(), label=""), tags.div( _class="userLine")[tags.a(href="#", onclick="addForward();" )[self.text.userFormLabelAddline]], formal.Field('mailAlternateAddress0', formal.String(), label=self.text.userFormLabelAlias), formal.Field('mailAlternateAddress1', formal.String(), label=""), formal.Field('mailAlternateAddress2', formal.String(), label=""), formal.Field('mailAlternateAddress3', formal.String(), label=""), formal.Field('mailAlternateAddress4', formal.String(), label=""), formal.Field('mailAlternateAddress5', formal.String(), label=""), formal.Field('mailAlternateAddress6', formal.String(), label=""), formal.Field('mailAlternateAddress7', formal.String(), label=""), formal.Field('mailAlternateAddress8', formal.String(), label=""), formal.Field('mailAlternateAddress9', formal.String(), label=""), tags.div( _class="userLine")[tags.a(href="#", onclick="addAlias();" )[self.text.userFormLabelAddline]], formal.Field('vacen', formal.Boolean(), label=self.text.userFormLabelVacationActive, description=self.text.userFormTextVacationNote), formal.Field('vacation', formal.String(), formal.TextArea, label=self.text.userFormLabelVacation), ], formal.Group('userPermissions')[ formal.Field('employeeType', formal.Boolean(), label=self.text.userFormLabelWeb), formal.Field('accountStatus', formal.Boolean(), label=self.text.userFormLabelEmail), formal.Field('tumsAdmin', formal.Boolean(), label=self.text.userFormLabelAdmin), formal.Field('tumsUser', formal.Sequence(formal.String()), formal.widgetFactory(formal.CheckboxMultiChoice, [( i, i) for i in domains]), label=self.text.userFormLabelDomainAdmin), formal.Field('tumsReports', formal.Boolean(), label=self.text.userFormLabelReports), formal.Field('copyto', formal.String(), label=self.text.userFormLabelCopy, description=self.text.userFormTextCopy)], formal.Group('userAccess')[ formal.Field('vpnEnabled', formal.Boolean(), label=self.text.userFormLabelVPN, description=self.text.userFormTextVPN), formal.Field('ftpEnabled', formal.Boolean(), label=self.text.userFormLabelFTP, description=self.text.userFormTextFTP), formal.Field('ftpGlobal', formal.Boolean(), label=self.text.userFormLabelGlobalFTP, description=self.text.userFormTextGlobal)]] form.data['userPermissions.accountStatus'] = True form.addAction(self.submitForm) return form
def form_select_target(self, ctx): form = formal.Form() g = formalutils.CollapsibleGroup('selecttarget', label='Installation Targets') g.setCollapsed(False) targets = [] for m in self._get_disks(): errors = [] if m.get_size() < constants.DISK_SIZE_MINIMUM: errors.append('device too small') if m.is_write_protected(): errors.append('write-protected') if errors: errorstr = ' [' + (', '.join(errors)) + ']' else: errorstr = '' devname = m.get_device() devstring = '%s %s (%s) %s' % (m.get_size_pretty(), m.get_human_readable_description(), m.get_device(), errorstr) targets.append((devname, devstring)) def _target_cmp(x, y): x_dev, x_info = x y_dev, y_info = y return unicode.__cmp__(unicode(x_dev), unicode(y_dev)) targets.sort(cmp=_target_cmp) # XXX: we can't currently disable individual radiobuttons in Formal. # We thus leave them enabled, and check for device size below. This # is unfortunate, but better than not showing small devices at all lbl = 'Target device' g.add( formal.Field('target', formal.String(required=True), formal.widgetFactory(formal.RadioChoice, options=targets), label=lbl)) g.add( formal.Field('recovery', formal.Boolean(required=False), label='Attempt recovery')) sg = formalutils.SubmitFieldGroup('buttons') sg.add( formalutils.SubmitField('selecttarget', formal.String(), label='Next')) sg.add( formalutils.SubmitField('rescan', formal.String(), label='Rescan')) sg.add( formalutils.SubmitField('cancel', formal.String(), label='Cancel')) g.add(sg) form.add(g) form.addAction(self.submitted_select_target, name='selecttarget', label='Next', validate=False) form.addAction(self.submitted_rescan, name='rescan', label='Rescan', validate=False) form.addAction(self.submitted_cancel_installation, name='cancel', label='Cancel', validate=False) # set previous selection if exists as default value cfg = livecddb.get_livecd_database_root() if cfg.hasS(ns_ui.targetDevice): form.data['selecttarget.target'] = cfg.getS( ns_ui.targetDevice, rdf.String) if cfg.hasS(ns_ui.attemptRecovery): form.data['selecttarget.recovery'] = cfg.getS( ns_ui.attemptRecovery, rdf.Boolean) return form
def form_editForm(self, data): domains = [] if self.avatarId.isAdmin: for i in self.flatFil: thisdom = i.split('dm=')[-1].split(',')[0] if not thisdom in domains: domains.append(thisdom) # Form population userData = self.lc.getUser(self.cid) devList = [] #extList = [] rouList = [] UserExtForm = [] fkeyForm = [] if Settings.sambaDN and self.domain==Settings.defaultDomain and PBXUtils.enabled(): includeList = [] includeList = self.sysconf.PBXExtensions.get(userData['uid'][0], {'extensions':[]})['extensions'] extList = PBXUtils.getAvaExtenNumSelect(True, includeList) #for ext in PBXUtils.getAvailibleExtensions(): # extList.append((str(ext), str(ext))) for dev in PBXUtils.getAllAvaExtDeviceEndPoints(): devList.append((str(dev), str(dev))) queueList = [(queue, queue) for queue in self.sysconf.PBX.get('queues', {}).keys()] rouList = self.sysconf.PBXRouters.keys() extensionWidget = formal.widgetFactory(formal.SelectChoice, options = extList) deviceWidget = formal.widgetFactory(formal.SelectChoice, options = devList) #queueWidget = formal.widgetFactory(formal.SelectChoice, options = queueList) userExtensions = PBXUtils.getExtensionSelect() fKeyOptions = formal.widgetFactory(formal.SelectChoice, options = userExtensions) fKeys = [] maxKeys = 11 for i in range(maxKeys): fKeys.append(formal.Field('fkeys%s' % i, formal.String(), fKeyOptions, label = "Key %s" % i)) fKeys.append(formal.Field('fkeys%s'%maxKeys, formal.String(), fKeyOptions, label = "Key %s"%maxKeys, description = "Select the extensions for the function keys above")) UserExtForm = formal.Group('userExtension')[ formal.Field('userExtEnabled', formal.Boolean(), label = self.text.userFormLabelExtEnabled), formal.Field('userExtOutbound', formal.Sequence(formal.String()), formal.widgetFactory(formal.CheckboxMultiChoice, options=[(i,i) for i in rouList]), label = self.text.userFormLabelOutbound, description = self.text.userFormDescOutbound), formal.Field('userExtQueues', formal.Sequence(formal.String()), formal.widgetFactory(formal.CheckboxMultiChoice, options = queueList), label = self.text.userFormLabelQueues, description = self.text.userFormDescQueues), formal.Field('userExtCallerID', formal.String(), label = self.text.userFormLabelCallID), formal.Field('userExtNumber0', formal.String(), extensionWidget, label = self.text.userFormLabelExtNumber), formal.Field('userExtNumber1', formal.String(), extensionWidget,label = ""), formal.Field('userExtNumber2', formal.String(), extensionWidget,label = ""), formal.Field('userExtNumber3', formal.String(), extensionWidget,label = ""), formal.Field('userExtNumber4', formal.String(), extensionWidget,label = ""), formal.Field('userExtNumber5', formal.String(), extensionWidget,label = ""), formal.Field('userExtNumber6', formal.String(), extensionWidget,label = ""), formal.Field('userExtNumber7', formal.String(), extensionWidget,label = ""), formal.Field('userExtNumber8', formal.String(), extensionWidget,label = ""), formal.Field('userExtNumber9', formal.String(), extensionWidget,label = ""), tags.div(_class="userLine")[tags.a(href="#", onclick="addExten();")[self.text.userFormLabelAddExt]], formal.Field('userExtFwdUA', formal.String(), label = self.text.userFormLabelRedNoAnswer, description = self.text.userFormDescRedNoAnswer), formal.Field('userExtDev0', formal.String(), deviceWidget,label = self.text.userFormLabelDev), formal.Field('userExtDev1', formal.String(), deviceWidget,label = ""), formal.Field('userExtDev2', formal.String(), deviceWidget,label = ""), formal.Field('userExtDev3', formal.String(), deviceWidget,label = ""), formal.Field('userExtDev4', formal.String(), deviceWidget,label = ""), formal.Field('userExtDev5', formal.String(), deviceWidget,label = ""), formal.Field('userExtDev6', formal.String(), deviceWidget,label = ""), formal.Field('userExtDev7', formal.String(), deviceWidget,label = ""), formal.Field('userExtDev8', formal.String(), deviceWidget,label = ""), formal.Field('userExtDev9', formal.String(), deviceWidget,label = ""), tags.div(_class="userLine")[tags.a(href="#", onclick="addExtDev();")[self.text.userFormLabelAddDev]], formal.Field('userExtVoiceMail', formal.Boolean(), label = self.text.userFormLabelVoiceMail), formal.Field('userExtVoiceMailPin', formal.String(), label = self.text.userFormLabelVoiceMailPin), ] fkeyForm = formal.Group('userFKeys')[fKeys] form = formal.Form(self.submitForm)[ formal.Group('userSettings')[ tags.div(_class="field")[ tags.label[self.text.userFormLabelEmailAddress], tags.div(id="emailAd", _class="inputs")[ "%s@%s"% (self.cid, self.domain) ] ], formal.Field('uid', formal.String(required=True), label = self.text.userFormLabelUsername), formal.Field('givenName', formal.String(required=True), label = self.text.userFormLabelName), formal.Field('sn', formal.String(), label = self.text.userFormLabelSurname), formal.Field('userPassword', formal.String(), formal.CheckedPassword, label= self.text.userFormLabelPass), ], formal.Group('mailSettings')[ formal.Field('mailForwardingAddress0', formal.String(), label=self.text.userFormLabelForward), formal.Field('mailForwardingAddress1', formal.String(), label=""), formal.Field('mailForwardingAddress2', formal.String(), label=""), formal.Field('mailForwardingAddress3', formal.String(), label=""), formal.Field('mailForwardingAddress4', formal.String(), label=""), formal.Field('mailForwardingAddress5', formal.String(), label=""), formal.Field('mailForwardingAddress6', formal.String(), label=""), formal.Field('mailForwardingAddress7', formal.String(), label=""), formal.Field('mailForwardingAddress8', formal.String(), label=""), formal.Field('mailForwardingAddress9', formal.String(), label=""), tags.div(_class="userLine")[tags.a(href="#", onclick="addForward();")[self.text.userFormLabelAddline]], formal.Field('mailAlternateAddress0', formal.String(), label=self.text.userFormLabelAlias), formal.Field('mailAlternateAddress1', formal.String(), label=""), formal.Field('mailAlternateAddress2', formal.String(), label=""), formal.Field('mailAlternateAddress3', formal.String(), label=""), formal.Field('mailAlternateAddress4', formal.String(), label=""), formal.Field('mailAlternateAddress5', formal.String(), label=""), formal.Field('mailAlternateAddress6', formal.String(), label=""), formal.Field('mailAlternateAddress7', formal.String(), label=""), formal.Field('mailAlternateAddress8', formal.String(), label=""), formal.Field('mailAlternateAddress9', formal.String(), label=""), tags.div(_class="userLine")[tags.a(href="#", onclick="addAlias();")[self.text.userFormLabelAddline]], formal.Field('vacen', formal.Boolean(), label = self.text.userFormLabelVacationActive, description=self.text.userFormTextVacationNote), formal.Field('vacation', formal.String(), formal.TextArea, label=self.text.userFormLabelVacation), formal.Field('vacvalidity', formal.Date(), label = "Valid until", description="Disable the vacation note automatically on this date") ], formal.Group('userPermissions')[ formal.Field('employeeType', formal.Boolean(), label = self.text.userFormLabelWeb), formal.Field('accountStatus', formal.Boolean(), label = self.text.userFormLabelEmail), formal.Field('tumsAdmin', formal.Boolean(), label = self.text.userFormLabelAdmin), formal.Field('tumsUser', formal.Sequence(formal.String()), formal.widgetFactory(formal.CheckboxMultiChoice, [(i,i) for i in domains]), label = self.text.userFormLabelDomainAdmin), formal.Field('tumsReports', formal.Boolean(), label = self.text.userFormLabelReports), formal.Field('copyto', formal.String(), label = self.text.userFormLabelCopy, description = self.text.userFormTextCopy) ], formal.Group('userAccess')[ formal.Field('vpnEnabled', formal.Boolean(), label = self.text.userFormLabelVPN, description = self.text.userFormTextVPN), formal.Field('ftpEnabled', formal.Boolean(), label = self.text.userFormLabelFTP, description = self.text.userFormTextFTP), formal.Field('ftpGlobal', formal.Boolean(), label = self.text.userFormLabelGlobalFTP, description = self.text.userFormTextGlobal) ], UserExtForm, fkeyForm ] form.addAction(self.submitForm) tData = copy.deepcopy(userData) tData['userSettings.uid'] = tData['uid'][0] tData['userSettings.givenName'] = tData.get('givenName', [""])[0] tData['userSettings.sn'] = tData.get('sn', [""])[0] if tData.get('loginShell'): if '/bin/bash' in tData['loginShell']: tData['userAccess.ftpEnabled'] = True if self.sysconf.FTP.get('globals'): if tData['uid'][0] in self.sysconf.FTP['globals']: tData['userAccess.ftpGlobal'] = True tData['userSettings.userPassword'] = '' # Strip password address = "%s@%s" % (tData['uid'][0], self.domain) for i in os.listdir('/etc/openvpn/keys/'): if "%s.%s" % (self.cid, self.domain) in i and "key" in i: tData['userAccess.vpnEnabled'] = True if self.sysconf.Mail.get('copys', []): for addr, dest in self.sysconf.Mail['copys']: if addr == address: tData['userPermissions.copyto'] = dest if userData.get('accountStatus', False): tData['userPermissions.accountStatus'] = True else: tData['userPermissions.accountStatus'] = False if userData.get('mailForwardingAddress', False): for cnt,address in enumerate(userData['mailForwardingAddress']): tData['mailSettings.mailForwardingAddress%s' % cnt] = address if userData.get('mailAlternateAddress', False): for cnt,address in enumerate(userData['mailAlternateAddress']): tData['mailSettings.mailAlternateAddress%s' % cnt] = address emp = userData.get('employeeType', [False]) if 'squid' in emp: tData['userPermissions.employeeType'] = True else: tData['userPermissions.employeeType'] = False if 'tumsAdmin' in emp: tData['userPermissions.tumsAdmin'] = True else: tData['userPermissions.tumsAdmin'] = False if 'tumsReports' in emp: tData['userPermissions.tumsReports'] = True else: tData['userPermissions.tumsReports'] = False if emp[0]: for i in emp: if 'tumsUser[' in i: tData['userPermissions.tumsUser'] = i.split('[')[-1].split(']')[0].split(',') try: vac = open("/var/spool/mail/vacation/%s@%s.txt" % (self.cid, self.domain), 'r') tData['mailSettings.vacation'] = vac.read() tData['mailSettings.vacen'] = True except: pass # No vacation note try: vac = open("/var/spool/mail/vacation/DISABLED%s@%s.txt" % (self.cid, self.domain), 'r') tData['mailSettings.vacation'] = vac.read() tData['mailSettings.vacen'] = False except: pass # No disabled note either. if os.path.exists('/var/spool/mail/vacation/%s@%s.validity' % (self.cid, self.domain)): n = open('/var/spool/mail/vacation/%s@%s.validity'% (self.cid, self.domain)).read().strip('\n') d = datetime.date(*[int(i) for i in n.split('-')]) tData['mailSettings.vacvalidity'] = d #Populate Userextension Data if PBXUtils.enabled(): ext = self.sysconf.PBXExtensions.get(tData['uid'][0], { 'enabled': False, 'outbound': [], 'callerID': "", 'voiceMail': False, 'voiceMailPin': '', 'fkeys': [], 'extensions': [], 'devices': [], 'queues': [] }) tData['userExtension.userExtEnabled'] = ext['enabled'] tData['userExtension.userExtOutbound'] = ext['outbound'] tData['userExtension.userExtQueues'] = ext.get('queues', []) tData['userExtension.userExtCallerID'] = ext['callerID'] tData['userExtension.userExtVoiceMail'] = ext['voiceMail'] tData['userExtension.userExtVoiceMailPin'] = ext['voiceMailPin'] for i in range(0,9): try: tData['userExtension.userExtNumber%s'%i]=ext['extensions'][i] except: pass try: tData['userExtension.userExtDev%s'%i]=ext['devices'][i] except: pass for i in range(12): try: tData['userFKeys.fkeys%s'%i] = ext['fkeys'][i] except: pass form.data = tData return form