comparison pylons_app/model/forms.py @ 320:05b212954275

Implemented owner settings, as separete posibility to edit repositry by non administrative owner of repository
author Marcin Kuzminski <marcin@python-works.com>
date Wed, 30 Jun 2010 15:35:10 +0200
parents fc4027fe46bc
children cec5cbc956c0
comparison
equal deleted inserted replaced
319:c12f4d19c950 320:05b212954275
180 except Exception: 180 except Exception:
181 msg = self.message('perm_new_user_name', 181 msg = self.message('perm_new_user_name',
182 state=State_obj) 182 state=State_obj)
183 raise formencode.Invalid(msg, value, state, error_dict={'perm_new_user_name':msg}) 183 raise formencode.Invalid(msg, value, state, error_dict={'perm_new_user_name':msg})
184 return value 184 return value
185 185
186 class ValidSettings(formencode.validators.FancyValidator):
187
188 def to_python(self, value, state):
189 #settings form can't edit user
190 if value.has_key('user'):
191 del['value']['user']
192
193 return value
186 #=============================================================================== 194 #===============================================================================
187 # FORMS 195 # FORMS
188 #=============================================================================== 196 #===============================================================================
189 class LoginForm(formencode.Schema): 197 class LoginForm(formencode.Schema):
190 allow_extra_fields = True 198 allow_extra_fields = True
238 if edit: 246 if edit:
239 user = All(Int(not_empty=True), ValidRepoUser) 247 user = All(Int(not_empty=True), ValidRepoUser)
240 248
241 chained_validators = [ValidPerms] 249 chained_validators = [ValidPerms]
242 return _RepoForm 250 return _RepoForm
251
252 def RepoSettingsForm(edit=False):
253 class _RepoForm(formencode.Schema):
254 allow_extra_fields = True
255 filter_extra_fields = False
256 repo_name = All(UnicodeString(strip=True, min=1, not_empty=True), ValidRepoName(edit))
257 description = UnicodeString(strip=True, min=3, not_empty=True)
258 private = StringBoolean(if_missing=False)
259
260 chained_validators = [ValidPerms, ValidSettings]
261 return _RepoForm
262
263
264
265