summaryrefslogtreecommitdiffstats
path: root/ipa-server/ipa-gui/ipagui/forms/principal.py
blob: a830c8a34894361950e89fc43520e7fe70f6c816 (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
import turbogears
from turbogears import validators, widgets
from tg_expanding_form_widget.tg_expanding_form_widget import ExpandingForm

class PrincipalFields(object):
    hostname = widgets.TextField(name="hostname", label="Host Name")
    service = widgets.SingleSelectField(name="service",
            label="Service Type",
            options = [
                       ("cifs", "cifs"),
                       ("dhcp", "dhcp"),
                       ("dns", "dns"),
                       ("host", "host"),
                       ("HTTP", "HTTP"),
                       ("ldap", "ldap"),
                       ("other", "other"),
                       ("rpc", "rpc"),
                       ("snmp", "snmp")
                      ],
            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) = widgets.meta.load_kid_template("ipagui.templates.principalnewform")
        self.principal_fields = PrincipalFields

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