def authz_fieldset_builder(role_class): fs = fa.Grid(role_class) role_options = model.Role.get_all() if role_class == model.PackageRole: fs.append( Field(u'delete', types.String, get_package_linker(u'delete')).readonly()) elif role_class == model.GroupRole: fs.append( Field(u'delete', types.String, get_group_linker(u'delete')).readonly()) elif role_class == model.AuthorizationGroupRole: fs.append( Field(u'delete', types.String, get_authorization_group_linker(u'delete')).readonly()) fs.append( # use getattr because though we should always have a user name, # sometimes (due to error) we don't and want to avoid a 500 ... Field(u'username', types.String, lambda item: ckan_h.linked_user(getattr(item.user, 'name', '')) ).readonly()) fs.append( Field(u'authzgroupname', types.String, lambda item: getattr( item.authorized_group, 'name', '')).readonly()) fs.configure( options=[ fs.role.with_renderer(RolesRenderer), ], include=[fs.username, fs.authzgroupname, fs.role, fs.delete], ) return fs
def POST(self, clspath): from formalchemy import Field model = admin.getModelByTablename(clspath) fs = Field(model, data=web.input()) fs.sync() db.commit() print web.input() print fs.validate() if fs.validate(): fs.sync() db.commit()
def add_operations(self, route_name): self.append(Field(' ', type=types.String, value=lambda item:self._operations_col(item, route_name)))
UserForm.st.with_renderer(CountriesRenderer) ]) AdminUserForm = FieldSet(ldap.User) AdminUserForm.configure(include=[ AdminUserForm.uid.hidden(), AdminUserForm.sn, AdminUserForm.title.with_renderer(RoleRenderer), AdminUserForm.mail.validate(validators.email), AdminUserForm.emailAlias, AdminUserForm.labeledURI, AdminUserForm.telephoneNumber, AdminUserForm. birthDate, AdminUserForm.street, AdminUserForm.postalCode, AdminUserForm.l, AdminUserForm.st.with_renderer(CountriesRenderer) ]) NewUserForm = FieldSet(ldap.User) NewUserForm.configure(include=[ NewUserForm.uid.validate(validate_uid), NewUserForm.sn, NewUserForm.mail.validate( validate_email), NewUserForm.telephoneNumber, NewUserForm.birthDate, NewUserForm.street, NewUserForm.postalCode, NewUserForm.l, NewUserForm.st.with_renderer(CountriesRenderer) ]) RegisterForm = FieldSet(ldap.User) RegisterForm.append(Field('password')) RegisterForm.configure(include=[ RegisterForm.uid.validate(validate_uid), RegisterForm.sn, RegisterForm.mail.validate(validate_email), RegisterForm.password.label('Mot de passe').with_renderer( PasswordFieldRenderer).required() ])
class DummySchema(object): name = Field() value = Field(type=types.Integer)