summaryrefslogtreecommitdiffstats
path: root/ipa-server/ipa-gui/ipagui/helpers
diff options
context:
space:
mode:
Diffstat (limited to 'ipa-server/ipa-gui/ipagui/helpers')
-rw-r--r--ipa-server/ipa-gui/ipagui/helpers/Makefile.am17
-rw-r--r--ipa-server/ipa-gui/ipagui/helpers/__init__.py1
-rw-r--r--ipa-server/ipa-gui/ipagui/helpers/ipahelper.py88
-rw-r--r--ipa-server/ipa-gui/ipagui/helpers/userhelper.py46
-rw-r--r--ipa-server/ipa-gui/ipagui/helpers/validators.py92
5 files changed, 0 insertions, 244 deletions
diff --git a/ipa-server/ipa-gui/ipagui/helpers/Makefile.am b/ipa-server/ipa-gui/ipagui/helpers/Makefile.am
deleted file mode 100644
index 46185b09..00000000
--- a/ipa-server/ipa-gui/ipagui/helpers/Makefile.am
+++ /dev/null
@@ -1,17 +0,0 @@
-NULL =
-
-appdir = $(IPA_DATA_DIR)/ipagui/helpers
-app_PYTHON = \
- __init__.py \
- ipahelper.py \
- userhelper.py \
- validators.py \
- $(NULL)
-
-EXTRA_DIST = \
- $(NULL)
-
-MAINTAINERCLEANFILES = \
- *~ \
- *.pyc \
- Makefile.in
diff --git a/ipa-server/ipa-gui/ipagui/helpers/__init__.py b/ipa-server/ipa-gui/ipagui/helpers/__init__.py
deleted file mode 100644
index 143f486c..00000000
--- a/ipa-server/ipa-gui/ipagui/helpers/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-# __init__.py
diff --git a/ipa-server/ipa-gui/ipagui/helpers/ipahelper.py b/ipa-server/ipa-gui/ipagui/helpers/ipahelper.py
deleted file mode 100644
index 9b340483..00000000
--- a/ipa-server/ipa-gui/ipagui/helpers/ipahelper.py
+++ /dev/null
@@ -1,88 +0,0 @@
-# Copyright (C) 2007 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
-#
-
-import re
-import logging
-import turbogears
-import kid
-from turbokid import kidsupport
-from pkg_resources import resource_filename
-
-def javascript_string_escape(input):
- """Escapes the ' " and \ characters in a string so
- it can be embedded inside a dynamically generated string."""
-
- return re.sub(r'[\'\"\\]',
- lambda match: "\\%s" % match.group(),
- input)
-
-def setup_mv_fields(field, fieldname):
- """Given a field (must be a list) and field name, convert that
- field into a list of dictionaries of the form:
- [ { fieldname : v1}, { fieldname : v2 }, .. ]
-
- This is how we pre-fill values for multi-valued fields.
- """
- mvlist = []
- if field:
- for v in field:
- if v:
- mvlist.append({ fieldname : v } )
- if len(mvlist) == 0:
- # We need to return an empty value so something can be
- # displayed on the edit page. Otherwise only an Add link
- # will show, not an empty field.
- mvlist.append({ fieldname : '' } )
- return mvlist
-
-def fix_incoming_fields(fields, fieldname, multifieldname):
- """This is called by the update() function. It takes the incoming
- list of dictionaries and converts it into back into the original
- field, then removes the multiple field.
- """
- fields[fieldname] = []
- try:
- for i in range(len(fields[multifieldname])):
- if fields[multifieldname][i][fieldname] is not None and len(fields[multifieldname][i][fieldname]) > 0:
- fields[fieldname].append(fields[multifieldname][i][fieldname])
- del(fields[multifieldname])
- except Exception, e:
- logging.warn("fix_incoming_fields error: " + str(e))
-
- return fields
-
-def load_template(classname, encoding=None):
- """
- Loads the given template. This only handles .kid files.
- Returns a tuple (compiled_tmpl, None) to emulate
- turbogears.meta.load_kid_template() which ends up not properly handling
- encoding.
- """
- if not encoding:
- encoding = turbogears.config.get('kid.encoding', kidsupport.KidSupport.assume_encoding)
- divider = classname.rfind(".")
- package, basename = classname[:divider], classname[divider+1:]
- file_path = resource_filename(package, basename + ".kid")
-
- tclass = kid.load_template(
- file_path,
- name = classname,
- ).Template
- tclass.serializer = kid.HTMLSerializer(encoding=encoding)
- tclass.assume_encoding=encoding
-
- return (tclass, None)
diff --git a/ipa-server/ipa-gui/ipagui/helpers/userhelper.py b/ipa-server/ipa-gui/ipagui/helpers/userhelper.py
deleted file mode 100644
index d80c4d3a..00000000
--- a/ipa-server/ipa-gui/ipagui/helpers/userhelper.py
+++ /dev/null
@@ -1,46 +0,0 @@
-# Copyright (C) 2007 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
-#
-
-import sys
-import datetime
-
-from ipa import ipautil
-
-def password_expires_in(datestr):
- """Returns the number of days that password expires in. Returns a negative number
- if the password is already expired."""
- if (datestr == None) or (datestr == ""):
- return sys.maxint
-
- expdate = ipautil.parse_generalized_time(datestr)
- if not expdate:
- return sys.maxint
-
- delta = expdate - datetime.datetime.now(ipautil.GeneralizedTimeZone())
- return delta.days
-
-def password_is_expired(days):
- return days < 0
-
-def password_expires_soon(days):
- return (not password_is_expired(days)) and (days < 7)
-
-def account_status_display(status):
- if status == "true":
- return "inactive"
- else:
- return "active"
diff --git a/ipa-server/ipa-gui/ipagui/helpers/validators.py b/ipa-server/ipa-gui/ipagui/helpers/validators.py
deleted file mode 100644
index 8ed73b87..00000000
--- a/ipa-server/ipa-gui/ipagui/helpers/validators.py
+++ /dev/null
@@ -1,92 +0,0 @@
-# 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:
- for v in value:
- if v is None or len(v) == 0:
- 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)
-
-class GoodName(Regex):
- """
- Test that the field contains only letters, numbers, underscore,
- dash, hyphen and $.
-
- Examples::
-
- >>> GoodName.to_python('_this9_')
- '_this9_'
- >>> GoodName.from_python(' this ')
- ' this '
- >>> GoodName(accept_python=False).from_python(' this ')
- Traceback (most recent call last):
- ...
- Invalid: Enter only letters, numbers, _ (underscore), - (dash) or $')
- >>> GoodName(strip=True).to_python(' this ')
- 'this'
- >>> GoodName(strip=True).from_python(' this ')
- 'this'
- """
-
- regex = r"^[a-zA-Z0-9_.][a-zA-Z0-9_.-]{0,30}[a-zA-Z0-9_.$-]?$"
-
- messages = {
- 'invalid': _('Enter only letters, numbers, _ (underscore), - (dash) or $'),
- }