## -*- coding: utf-8 -*- <% from ldapcherry.csrf import get_csrf_field from markupsafe import Markup len_attr = len(attributes) switch = len_attr / 2 if not switch * 2 == len_attr: switch = switch + 1 counter = 1 lc1 = [] lc2 = [] for a in sorted(attributes.keys(), key=lambda attr: attributes[attr]['weight']): if counter <= switch: lc1.append(a) else: lc2.append(a) counter = counter + 1 %> <%def name="form_col(l)"> % for a in l: <% attr = attributes[a] %>
<% if modify: required = '' else: required = ' required ' if not values is None and a in values: if type(values[a]) is list: raw_value = values[a][0] else: raw_value = values[a] if raw_value is None: raw_value = '' value = Markup(' value="{}"').format(raw_value) value2 = Markup('').format(raw_value) else: raw_value = '' value = '' value2 = '' if 'default' in attr and value == '': value = Markup(' value="{}"').format(attr['default']) %> ${attr['display_name']} % if modify and a == keyattr: ${raw_value} % elif attr['type'] == 'string': % elif attr['type'] == 'email': % elif attr['type'] == 'int': % elif attr['type'] == 'fix': ${attr['value']} % elif attr['type'] == 'stringlist': % elif attr['type'] == 'password': Retype ${attr['display_name']} % elif attr['type'] == 'textfield': % endif
% endfor
<%include file="csrf_field.tmpl"/> % if autofill: <% attr_set = [] attr_events = {} functions = {} for attrid in attributes: attr = attributes[attrid] field = 'attr.' + attrid if field not in attr_set: attr_set.append(field) if 'autofill' in attr: function = attr['autofill']['function'] tuple = (field, function) if not tuple in functions: functions[tuple] = [] for arg in attr['autofill']['args']: if arg[0] == '$': field_arg = 'attr.' + arg[1:] if field_arg not in attr_set: attr_set.append(field_arg) functions[tuple].append("fields['" + field_arg + "'].value") if not field_arg in attr_events: attr_events[field_arg] = [] attr_events[field_arg].append(tuple) else: value = arg functions[tuple].append("'" + value + "'") %> % endif