forked from shaba/openuds
Bug fix in LDAP & Regldap related to unicode literals
Fixes in new admin interface
This commit is contained in:
parent
b64928f1e6
commit
4565f00174
@ -43,7 +43,7 @@ import ldap
|
||||
import re
|
||||
import logging
|
||||
|
||||
__updated__ = '2014-02-19'
|
||||
__updated__ = '2014-03-19'
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@ -188,7 +188,7 @@ class RegexLdap(auths.Authenticator):
|
||||
self._userNameAttr)
|
||||
|
||||
def marshal(self):
|
||||
return str.join('\t', [
|
||||
return '\t'.join([
|
||||
'v2',
|
||||
self._host, self._port, gui.boolToStr(self._ssl), self._username, self._password, self._timeout,
|
||||
self._ldapBase, self._userClass, self._userIdAttr, self._groupNameAttr, self._userNameAttr
|
||||
|
@ -42,7 +42,7 @@ from uds.core.auths.Exceptions import AuthenticatorException
|
||||
import ldap
|
||||
import logging
|
||||
|
||||
__updated__ = '2014-02-19'
|
||||
__updated__ = '2014-03-19'
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@ -128,7 +128,7 @@ class SimpleLDAPAuthenticator(Authenticator):
|
||||
self._userNameAttr)
|
||||
|
||||
def marshal(self):
|
||||
return str.join('\t', ['v1',
|
||||
return '\t'.join(['v1',
|
||||
self._host, self._port, gui.boolToStr(self._ssl), self._username, self._password, self._timeout,
|
||||
self._ldapBase, self._userClass, self._groupClass, self._userIdAttr, self._groupIdAttr, self._memberAttr, self._userNameAttr])
|
||||
|
||||
|
@ -97,7 +97,9 @@ class gui(object):
|
||||
|
||||
@staticmethod
|
||||
def convertToList(vals):
|
||||
return [unicode(v) for v in vals]
|
||||
if vals is not None:
|
||||
return [unicode(v) for v in vals]
|
||||
return []
|
||||
|
||||
@staticmethod
|
||||
def choiceItem(id_, text):
|
||||
|
@ -36,10 +36,12 @@ from uds.core import services
|
||||
from uds.core.util.AutoAttributes import AutoAttributes
|
||||
from uds.core.ui.UserInterface import gui
|
||||
from IPMachineDeployed import IPMachineDeployed
|
||||
import logging, cPickle
|
||||
import logging
|
||||
import cPickle
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class IPMachinesService(services.Service):
|
||||
|
||||
# Gui
|
||||
@ -52,25 +54,24 @@ class IPMachinesService(services.Service):
|
||||
iconFile = 'machine.png'
|
||||
|
||||
# Characteristics of service
|
||||
maxDeployed = -1 # If the service provides more than 1 "provided service" (-1 = no limit, 0 = ???? (do not use it!!!), N = max number to deploy
|
||||
usesCache = False # Cache are running machine awaiting to be assigned
|
||||
usesCache_L2 = False # L2 Cache are running machines in suspended state
|
||||
needsManager = False # If the service needs a s.o. manager (managers are related to agents provided by services itselfs, i.e. virtual machines with agent)
|
||||
mustAssignManually = False # If true, the system can't do an automatic assignation of a deployed user service from this service
|
||||
maxDeployed = -1 # If the service provides more than 1 "provided service" (-1 = no limit, 0 = ???? (do not use it!!!), N = max number to deploy
|
||||
usesCache = False # Cache are running machine awaiting to be assigned
|
||||
usesCache_L2 = False # L2 Cache are running machines in suspended state
|
||||
needsManager = False # If the service needs a s.o. manager (managers are related to agents provided by services itselfs, i.e. virtual machines with agent)
|
||||
mustAssignManually = False # If true, the system can't do an automatic assignation of a deployed user service from this service
|
||||
|
||||
deployedType = IPMachineDeployed
|
||||
|
||||
def __init__(self, environment, parent, values = None):
|
||||
def __init__(self, environment, parent, values=None):
|
||||
super(IPMachinesService, self).__init__(environment, parent, values)
|
||||
if values is None:
|
||||
if values is None or values.get('ipList', None) is None:
|
||||
self._ips = []
|
||||
else:
|
||||
self._ips = list(set(values['ipList'])) # Avoid duplicates :-)
|
||||
self._ips = list(set(values['ipList'])) # Avoid duplicates :-)
|
||||
self._ips.sort()
|
||||
|
||||
|
||||
def valuesDict(self):
|
||||
return { 'ipList' : gui.convertToList(self._ips) }
|
||||
return {'ipList': gui.convertToList(self._ips)}
|
||||
|
||||
def marshal(self):
|
||||
self.storage().saveData('ips', cPickle.dumps(self._ips))
|
||||
@ -78,8 +79,7 @@ class IPMachinesService(services.Service):
|
||||
|
||||
def unmarshal(self, vals):
|
||||
if vals == 'v1':
|
||||
self._ips = cPickle.loads( self.storage().readData('ips') )
|
||||
|
||||
self._ips = cPickle.loads(self.storage().readData('ips'))
|
||||
|
||||
def getUnassignedMachine(self):
|
||||
# Search first unassigned machine
|
||||
|
@ -87,7 +87,7 @@
|
||||
<script src="{% get_static_prefix %}js/jquery.cookie.js"></script>
|
||||
<script src="{% get_static_prefix %}js/bootstrap.min.js"></script>
|
||||
<script src="{% get_static_prefix %}js/bootstrap-switch.min.js"></script>
|
||||
<script src="{% get_static_prefix %}js/bootstrap-select.min.js"></script>
|
||||
<script src="{% get_static_prefix %}js/bootstrap-select.min.js"></script>
|
||||
|
||||
<script>
|
||||
$(function(){
|
||||
|
@ -1,5 +1,4 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from django.utils.safestring import mark_safe
|
||||
|
||||
#
|
||||
# Copyright (c) 2012 Virtual Cable S.L.
|
||||
@ -31,9 +30,11 @@ from django.utils.safestring import mark_safe
|
||||
'''
|
||||
@author: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
'''
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.utils.translation import ugettext_lazy as _, ugettext
|
||||
from django import forms
|
||||
from django.utils.safestring import mark_safe
|
||||
from django.forms.forms import NON_FIELD_ERRORS
|
||||
from django.forms.util import ErrorDict
|
||||
from uds.models import Authenticator
|
||||
@ -41,18 +42,20 @@ import logging
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class CustomSelect(forms.Select):
|
||||
def render(self, name, value, attrs=None):
|
||||
if len(self.choices) < 2:
|
||||
visible = ' style="display: none;"'
|
||||
else:
|
||||
visible = '';
|
||||
visible = ''
|
||||
res = '<select id="id_{0}" name="{0}" class="selectpicker show-menu-arrow" data-header="{1}" data-size="8" data-width="100%" >'.format(name, ugettext('Select authenticator'))
|
||||
for choice in self.choices:
|
||||
res += '<option value="{0}">{1}</option>'.format(choice[0], choice[1])
|
||||
res += '</select>'
|
||||
return mark_safe('<div class="form-group"{0}><label>'.format(visible) + unicode(_('authenticator')) + '</label>' + res + '</div>')
|
||||
|
||||
|
||||
class BaseForm(forms.Form):
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
@ -65,6 +68,7 @@ class BaseForm(forms.Form):
|
||||
self._errors[NON_FIELD_ERRORS] = self.error_class()
|
||||
self._errors[NON_FIELD_ERRORS].append(message)
|
||||
|
||||
|
||||
class LoginForm(BaseForm):
|
||||
user = forms.CharField(label=_('Username'), max_length=64, widget=forms.TextInput())
|
||||
password = forms.CharField(label=_('Password'), widget=forms.PasswordInput(attrs={'title': _('Password')}), required=False)
|
||||
@ -99,6 +103,8 @@ class LoginForm(BaseForm):
|
||||
for a in auths:
|
||||
if a.getType() is None:
|
||||
continue
|
||||
if a.getType().isCustom() and smallName == 'disabled':
|
||||
continue
|
||||
choices.append((a.id, a.name))
|
||||
if a.getType().isCustom():
|
||||
nonStandard.append(str(a.id))
|
||||
|
Loading…
Reference in New Issue
Block a user