Missed a few validator things.
This commit is contained in:
parent
6520579448
commit
765c08cdea
3 changed files with 32 additions and 28 deletions
|
@ -35,47 +35,53 @@ class UnknownGroup(validators.FancyValidator):
|
||||||
raise validators.Invalid(_("The group '%s' already exists.") % value, value, state)
|
raise validators.Invalid(_("The group '%s' already exists.") % value, value, state)
|
||||||
|
|
||||||
class GroupCreate(validators.Schema):
|
class GroupCreate(validators.Schema):
|
||||||
name = validators.All(UnknownGroup(not_empty=True, max=10), validators.String(max=32, min=3))
|
name = validators.All(UnknownGroup, validators.String(max=32, min=3))
|
||||||
display_name = validators.NotEmpty
|
display_name = validators.NotEmpty
|
||||||
owner = validators.All(knownUser(not_empty=True, max=10), validators.String(max=32, min=3))
|
owner = KnownUser
|
||||||
prerequisite = KnownGroup
|
prerequisite = KnownGroup
|
||||||
#group_type = something
|
#group_type = something
|
||||||
|
|
||||||
class GroupSave(validators.Schema):
|
class GroupSave(validators.Schema):
|
||||||
groupname = validators.All(KnownGroup(not_empty=True, max=10), validators.String(max=32, min=3))
|
groupname = validators.All(KnownGroup, validators.String(max=32, min=3))
|
||||||
display_name = validators.NotEmpty
|
display_name = validators.NotEmpty
|
||||||
owner = validators.All(knownUser(not_empty=True, max=10), validators.String(max=32, min=3))
|
owner = KnownUser
|
||||||
prerequisite = KnownGroup
|
prerequisite = KnownGroup
|
||||||
#group_type = something
|
#group_type = something
|
||||||
|
|
||||||
class GroupApply(validators.Schema):
|
class GroupApply(validators.Schema):
|
||||||
groupname = KnownGroup()
|
groupname = KnownGroup
|
||||||
targetname = KnownUser()
|
targetname = KnownUser
|
||||||
|
|
||||||
class GroupSponsor(validators.Schema):
|
class GroupSponsor(validators.Schema):
|
||||||
groupname = KnownGroup()
|
groupname = KnownGroup
|
||||||
targetname = KnownUser()
|
targetname = KnownUser
|
||||||
|
|
||||||
class GroupRemove(validators.Schema):
|
class GroupRemove(validators.Schema):
|
||||||
groupname = KnownGroup()
|
groupname = KnownGroup
|
||||||
targetname = KnownUser()
|
targetname = KnownUser
|
||||||
|
|
||||||
class GroupUpgrade(validators.Schema):
|
class GroupUpgrade(validators.Schema):
|
||||||
groupname = KnownGroup()
|
groupname = KnownGroup
|
||||||
targetname = KnownUser()
|
targetname = KnownUser
|
||||||
|
|
||||||
class GroupDowngrade(validators.Schema):
|
class GroupDowngrade(validators.Schema):
|
||||||
groupname = KnownGroup()
|
groupname = KnownGroup
|
||||||
targetname = KnownUser()
|
targetname = KnownUser
|
||||||
|
|
||||||
class GroupView(validators.Schema):
|
class GroupView(validators.Schema):
|
||||||
groupname = KnownGroup()
|
groupname = KnownGroup
|
||||||
|
|
||||||
class GroupEdit(validators.Schema):
|
class GroupEdit(validators.Schema):
|
||||||
groupname = KnownGroup()
|
groupname = KnownGroup
|
||||||
|
|
||||||
|
class GroupDump(validators.Schema):
|
||||||
|
groupname = KnownGroup
|
||||||
|
|
||||||
class GroupInvite(validators.Schema):
|
class GroupInvite(validators.Schema):
|
||||||
groupname = KnownGroup()
|
groupname = KnownGroup
|
||||||
|
|
||||||
|
class GroupSendInvite(validators.Schema):
|
||||||
|
groupname = KnownGroup
|
||||||
target = validators.Email(not_empty=True, strip=True),
|
target = validators.Email(not_empty=True, strip=True),
|
||||||
|
|
||||||
#class findUser(widgets.WidgetsList):
|
#class findUser(widgets.WidgetsList):
|
||||||
|
@ -460,7 +466,7 @@ class Group(controllers.Controller):
|
||||||
return dict()
|
return dict()
|
||||||
|
|
||||||
@identity.require(turbogears.identity.not_anonymous())
|
@identity.require(turbogears.identity.not_anonymous())
|
||||||
@validate(validators=groupnameExists())
|
@validate(validators=GroupDump())
|
||||||
@error_handler(error)
|
@error_handler(error)
|
||||||
@expose(template="genshi-text:fas.templates.group.dump", format="text", content_type='text/plain; charset=utf-8')
|
@expose(template="genshi-text:fas.templates.group.dump", format="text", content_type='text/plain; charset=utf-8')
|
||||||
def dump(self, groupname):
|
def dump(self, groupname):
|
||||||
|
@ -476,7 +482,7 @@ class Group(controllers.Controller):
|
||||||
return dict(groups=groups)
|
return dict(groups=groups)
|
||||||
|
|
||||||
@identity.require(identity.not_anonymous())
|
@identity.require(identity.not_anonymous())
|
||||||
@validate(validators=groupnameExists())
|
@validate(validators=GroupInvite())
|
||||||
@error_handler(error)
|
@error_handler(error)
|
||||||
@expose(template='fas.templates.group.invite')
|
@expose(template='fas.templates.group.invite')
|
||||||
def invite(self, groupname):
|
def invite(self, groupname):
|
||||||
|
@ -487,7 +493,7 @@ class Group(controllers.Controller):
|
||||||
return dict(person=person, group=group)
|
return dict(person=person, group=group)
|
||||||
|
|
||||||
@identity.require(identity.not_anonymous())
|
@identity.require(identity.not_anonymous())
|
||||||
@validate(validators=groupnameExists())
|
@validate(validators=GroupSendInvite())
|
||||||
@error_handler(error)
|
@error_handler(error)
|
||||||
@expose(template='fas.templates.group.invite')
|
@expose(template='fas.templates.group.invite')
|
||||||
def sendinvite(self, groupname, target):
|
def sendinvite(self, groupname, target):
|
||||||
|
|
|
@ -6,8 +6,6 @@ import cherrypy
|
||||||
|
|
||||||
from fas.auth import *
|
from fas.auth import *
|
||||||
|
|
||||||
from fas.user import knownUser, usernameExists
|
|
||||||
|
|
||||||
from textwrap import dedent
|
from textwrap import dedent
|
||||||
|
|
||||||
import re
|
import re
|
||||||
|
|
|
@ -62,7 +62,7 @@ class ValidUsername(validators.FancyValidator):
|
||||||
raise validators.Invalid(_("'%s' is an illegal username.") % value, value, state)
|
raise validators.Invalid(_("'%s' is an illegal username.") % value, value, state)
|
||||||
|
|
||||||
class UserSave(validators.Schema):
|
class UserSave(validators.Schema):
|
||||||
targetname = KnownUser()
|
targetname = KnownUser
|
||||||
human_name = validators.String(not_empty=True, max=42)
|
human_name = validators.String(not_empty=True, max=42)
|
||||||
#mail = validators.All(
|
#mail = validators.All(
|
||||||
# validators.Email(not_empty=True, strip=True, max=128),
|
# validators.Email(not_empty=True, strip=True, max=128),
|
||||||
|
@ -74,7 +74,7 @@ class UserSave(validators.Schema):
|
||||||
|
|
||||||
class UserCreate(validators.Schema):
|
class UserCreate(validators.Schema):
|
||||||
username = validators.All(
|
username = validators.All(
|
||||||
UnknownUser(),
|
UnknownUser,
|
||||||
ValidUsername(not_empty=True),
|
ValidUsername(not_empty=True),
|
||||||
validators.String(max=32, min=3),
|
validators.String(max=32, min=3),
|
||||||
)
|
)
|
||||||
|
@ -87,17 +87,17 @@ class UserCreate(validators.Schema):
|
||||||
postal_address = validators.String(max=512)
|
postal_address = validators.String(max=512)
|
||||||
|
|
||||||
class UserSetPassword(validators.Schema):
|
class UserSetPassword(validators.Schema):
|
||||||
currentpassword = validators.String()
|
currentpassword = validators.String
|
||||||
# TODO (after we're done with most testing): Add complexity requirements?
|
# TODO (after we're done with most testing): Add complexity requirements?
|
||||||
password = validators.String(min=8)
|
password = validators.String(min=8)
|
||||||
passwordcheck = validators.String()
|
passwordcheck = validators.String
|
||||||
chained_validators = [validators.FieldsMatch('password', 'passwordcheck')]
|
chained_validators = [validators.FieldsMatch('password', 'passwordcheck')]
|
||||||
|
|
||||||
class UserView(validators.Schema):
|
class UserView(validators.Schema):
|
||||||
username = KnownUser()
|
username = KnownUser
|
||||||
|
|
||||||
class UserEdit(validators.Schema):
|
class UserEdit(validators.Schema):
|
||||||
username = KnownUser()
|
username = KnownUser
|
||||||
|
|
||||||
def generatePassword(password=None,length=14,salt=''):
|
def generatePassword(password=None,length=14,salt=''):
|
||||||
''' Generate Password '''
|
''' Generate Password '''
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue