Login
[x]
Log in using an account from:
Fedora Account System
Red Hat Associate
Red Hat Customer
Or login using a Red Hat Bugzilla account
Forgot Password
Login:
Hide Forgot
Create an Account
Red Hat Bugzilla – Attachment 305736 Details for
Bug 445286
No checking for duplicate phone numbers in Add/Edit User screen
[?]
New
Simple Search
Advanced Search
My Links
Browse
Requests
Reports
Current State
Search
Tabular reports
Graphical reports
Duplicates
Other Reports
User Changes
Plotly Reports
Bug Status
Bug Severity
Non-Defaults
|
Product Dashboard
Help
Page Help!
Bug Writing Guidelines
What's new
Browser Support Policy
5.0.4.rh83 Release notes
FAQ
Guides index
User guide
Web Services
Contact
Legal
This site requires JavaScript to be enabled to function correctly, please enable it.
[patch]
Do uniqueness check on phone numbers entered via the UI.
freeipa-22-unique.patch (text/plain), 5.48 KB, created by
Rob Crittenden
on 2008-05-16 19:51:33 UTC
(
hide
)
Description:
Do uniqueness check on phone numbers entered via the UI.
Filename:
MIME Type:
Creator:
Rob Crittenden
Created:
2008-05-16 19:51:33 UTC
Size:
5.48 KB
patch
obsolete
>From 20da04efd196f904a16f1e7743da284cc02ffb93 Mon Sep 17 00:00:00 2001 >From: Rob Crittenden <rcritten@redhat.com> >Date: Fri, 16 May 2008 15:49:05 -0400 >Subject: [PATCH] Do uniqueness check on phone numbers entered via the UI. > >445286 >--- > ipa-server/ipa-gui/ipagui/forms/user.py | 11 ++++ > ipa-server/ipa-gui/ipagui/helpers/validators.py | 63 ++++++++++++++++++++++ > ipa-server/ipa-gui/ipagui/subcontrollers/user.py | 4 +- > 3 files changed, 76 insertions(+), 2 deletions(-) > create mode 100644 ipa-server/ipa-gui/ipagui/helpers/validators.py > >diff --git a/ipa-server/ipa-gui/ipagui/forms/user.py b/ipa-server/ipa-gui/ipagui/forms/user.py >index a149dc4..92bdee9 100644 >--- a/ipa-server/ipa-gui/ipagui/forms/user.py >+++ b/ipa-server/ipa-gui/ipagui/forms/user.py >@@ -18,6 +18,7 @@ > import turbogears > from turbogears import validators, widgets > from tg_expanding_form_widget.tg_expanding_form_widget import ExpandingForm >+from ipagui.helpers.validators import * > > class UserFields(object): > givenname = widgets.TextField(name="givenname", label="First Name") >@@ -91,6 +92,11 @@ class UserNewValidator(validators.Schema): > sn = validators.String(not_empty=True) > cn = validators.ForEach(validators.String(not_empty=True)) > mail = validators.Email(not_empty=False) >+ telephonenumber = UniqueList(not_empty=False) >+ facsimiletelephonenumber = UniqueList(not_empty=False) >+ mobile = UniqueList(not_empty=False) >+ pager = UniqueList(not_empty=False) >+ homephone = UniqueList(not_empty=False) > > chained_validators = [ > validators.FieldsMatch('krbprincipalkey', 'krbprincipalkey_confirm') >@@ -129,6 +135,11 @@ class UserEditValidator(validators.Schema): > mail = validators.Email(not_empty=False) > uidnumber = validators.Int(not_empty=False) > gidnumber = validators.Int(not_empty=False) >+ telephonenumber = UniqueList(not_empty=False) >+ facsimiletelephonenumber = UniqueList(not_empty=False) >+ mobile = UniqueList(not_empty=False) >+ pager = UniqueList(not_empty=False) >+ homephone = UniqueList(not_empty=False) > > pre_validators = [ > validators.RequireIfPresent(required='uid', present='editprotected'), >diff --git a/ipa-server/ipa-gui/ipagui/helpers/validators.py b/ipa-server/ipa-gui/ipagui/helpers/validators.py >new file mode 100644 >index 0000000..b5750b8 >--- /dev/null >+++ b/ipa-server/ipa-gui/ipagui/helpers/validators.py >@@ -0,0 +1,63 @@ >+# Copyright (C) 2007-2008 Red Hat >+# see file 'COPYING' for use and warranty information >+# >+# This program is free software; you can redistribute it and/or >+# modify it under the terms of the GNU General Public License as >+# published by the Free Software Foundation; version 2 only >+# >+# This program is distributed in the hope that it will be useful, >+# but WITHOUT ANY WARRANTY; without even the implied warranty of >+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >+# GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License >+# along with this program; if not, write to the Free Software >+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA >+# >+ >+from formencode.validators import * >+from formencode.compound import * >+from formencode.api import Invalid, NoDefault >+from formencode.schema import Schema >+from formencode import ForEach >+ >+def _(s): return s # dummy >+ >+class UniqueList(FancyValidator): >+ """ >+ Given a list, ensure that all of the values in it are unique. >+ >+ >>> x = UniqueList() >+ >>> x.validate_python(['1','1'],'') >+ Traceback (most recent call last): >+ ... >+ formencode.api.Invalid: Duplicate values are not allowed >+ >>> x.validate_python(['1','2'],'') >+ >>> >+ """ >+ >+ not_empty = None >+ >+ messages = { >+ 'notunique': _('Duplicate values are not allowed'), >+ 'empty': _('Empty values not allowed'), >+ } >+ >+ def __initargs__(self, new_attrs): >+ if self.not_empty is None: >+ self.not_empty = True >+ >+ def validate_python(self, value, state): >+ if not isinstance(value, list): >+ return # just punt for now >+ >+ if self.not_empty and len(value): >+ raise Invalid(self.message('empty', state), >+ value, state) >+ >+ orig = len(value) >+ check = len(set(value)) >+ >+ if orig > check: >+ raise Invalid(self.message('notunique', state), >+ value, state) >diff --git a/ipa-server/ipa-gui/ipagui/subcontrollers/user.py b/ipa-server/ipa-gui/ipagui/subcontrollers/user.py >index 9232f30..734d867 100644 >--- a/ipa-server/ipa-gui/ipagui/subcontrollers/user.py >+++ b/ipa-server/ipa-gui/ipagui/subcontrollers/user.py >@@ -165,8 +165,6 @@ class UserController(IPAController): > turbogears.flash("Add user cancelled") > raise turbogears.redirect('/user/list') > >- tg_errors, kw = self.usercreatevalidate(**kw) >- > # Fix incoming multi-valued fields we created for the form > kw = ipahelper.fix_incoming_fields(kw, 'cn', 'cns') > kw = ipahelper.fix_incoming_fields(kw, 'telephonenumber', 'telephonenumbers') >@@ -175,6 +173,8 @@ class UserController(IPAController): > kw = ipahelper.fix_incoming_fields(kw, 'pager', 'pagers') > kw = ipahelper.fix_incoming_fields(kw, 'homephone', 'homephones') > >+ tg_errors, kw = self.usercreatevalidate(**kw) >+ > if tg_errors: > turbogears.flash("There were validation errors.<br/>" + > "Please see the messages below for details.") >-- >1.5.4 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 445286
: 305736