summaryrefslogtreecommitdiffstats
path: root/ipa-server/ipa-gui/ipagui/forms/principal.py
blob: 8ff5eed0304d5b64bcb6ab7cc1500583b5bd2ce0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# 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 turbogears
from turbogears import validators, widgets
from tg_expanding_form_widget.tg_expanding_form_widget import ExpandingForm
from ipagui.helpers import ipahelper

class PrincipalFields(object):
    hostname = widgets.TextField(name="hostname", label="Host Name")
    service = widgets.SingleSelectField(name="service",
            label="Service Type",
            options = [
                       ("cifs", "cifs"),
                       ("dns", "dns"),
                       ("host", "host"),
                       ("HTTP", "HTTP"),
                       ("ldap", "ldap"),
                       ("nfs", "nfs"),
                       ("other", "other")
                      ],
            attrs=dict(onchange="toggleOther(this.id)"))
    other = widgets.TextField(name="other", label="Other Service", attrs=dict(size=10))

class PrincipalNewValidator(validators.Schema):
    hostname = validators.String(not_empty=True)
    service = validators.String(not_empty=True)
    other = validators.String(not_empty=False)

class PrincipalNewForm(widgets.Form):
    params = ['principal_fields']

    validator = PrincipalNewValidator()

    def __init__(self, *args, **kw):
        super(PrincipalNewForm,self).__init__(*args, **kw)
        (self.template_c, self.template) = ipahelper.load_template("ipagui.templates.principalnewform")
        self.principal_fields = PrincipalFields

    def update_params(self, params):
        super(PrincipalNewForm,self).update_params(params)