View | Details | Raw Unified | Return to bug 25095 | Differences between
and this patch

Collapse All | Expand All

(-)management/univention-management-console-module-ucr/umc/js/ucr.js (-3 / +9 lines)
Lines 77-83 Link Here
77
				type: TextBox,
77
				type: TextBox,
78
				name: 'key',
78
				name: 'key',
79
				description: _( 'Name of UCR variable' ),
79
				description: _( 'Name of UCR variable' ),
80
				label: _( 'UCR variable' )
80
				label: _( 'UCR variable' ),
81
				invalidMessage: _( 'A valid key must contain at least one character and can only contain letters, numerals, and "/", ".", "_", "-".' ),
82
				validator: function (value, constraints) {
83
					return !!value && !/[^a-zA-Z0-9/._-]/.test(value);
84
				}
81
			}, {
85
			}, {
82
				type: TextBox,
86
				type: TextBox,
83
				name: 'value',
87
				name: 'value',
Lines 105-112 Link Here
105
				label: _( 'Save' ),
109
				label: _( 'Save' ),
106
				style: 'float: right',
110
				style: 'float: right',
107
				callback: lang.hitch(this, function() {
111
				callback: lang.hitch(this, function() {
108
					this._form.save();
112
					if (this._form.getWidget('key').isValid()) {
109
					this.hide();
113
						this._form.save();
114
						this.hide();
115
					}
110
				})
116
				})
111
			}, {
117
			}, {
112
				//FIXME: Should be much simpler. The key name should be enough
118
				//FIXME: Should be much simpler. The key name should be enough
(-)management/univention-management-console-module-ucr/umc/python/ucr/__init__.py (-1 / +25 lines)
Lines 31-36 Link Here
31
# /usr/share/common-licenses/AGPL-3; if not, see
31
# /usr/share/common-licenses/AGPL-3; if not, see
32
# <http://www.gnu.org/licenses/>.
32
# <http://www.gnu.org/licenses/>.
33
33
34
import re
35
34
from univention.lib.i18n import Translation
36
from univention.lib.i18n import Translation
35
from univention.management.console.modules import Base
37
from univention.management.console.modules import Base
36
from univention.management.console.protocol.definitions import *
38
from univention.management.console.protocol.definitions import *
Lines 86-92 Link Here
86
		return False
88
		return False
87
89
88
	def add( self, request ):
90
	def add( self, request ):
89
		# does the same as put
91
		if isinstance( request.options, ( list, tuple ) ):
92
			for _var in request.options:
93
				try:
94
					var = _var['object']
95
					key = var['key']
96
					ucrinfo = ConfigRegistryInfo(registered_only=False)
97
					if ucrinfo.get_variable(key) is not None:
98
						request.status = BAD_REQUEST_INVALID_ARGS
99
						self.finished(request.id, False, message = _('The key %s is already in use for an existing UCR variable.') % key)
100
				except KeyError:
101
					# handle the case that no key is given for an UCR variable entry
102
					request.status = BAD_REQUEST_INVALID_OPTS
103
					self.finished(request.id, False, message = _('Invalid UCR variable entry, the properties "key" and "value" need to be specified.'))
104
					return
105
		else:
106
			request.status = BAD_REQUEST_INVALID_OPTS
107
			self.finished(request.id, False)
108
90
		self.put( request )
109
		self.put( request )
91
110
92
	def put( self, request ):
111
	def put( self, request ):
Lines 99-104 Link Here
99
					var = _var['object']
118
					var = _var['object']
100
					value = var['value'] or ''
119
					value = var['value'] or ''
101
					key = var['key']
120
					key = var['key']
121
					if not re.match('^[a-zA-Z0-9/._-]+$', key):
122
						success = False
123
						request.status = BAD_REQUEST_INVALID_ARGS
124
						message = _( 'A valid key must contain at least one character and can only contain letters, numerals, and "/", ".", "_", "-".' )
125
						break
102
					if self.is_readonly( key ):
126
					if self.is_readonly( key ):
103
						success = False
127
						success = False
104
						message = _( 'The UCR variable %s is read-only and can not be changed!' ) % key
128
						message = _( 'The UCR variable %s is read-only and can not be changed!' ) % key

Return to bug 25095