Exemple #1
0
##################
# USER FUNCTIONS #
##################

__check_first_character_is_letter = lambda username: username[
    0] in string.letters
__check_no_spaces = lambda username: all([c != " " for c in username])
__check_username = lambda username: get_user(username_lower=username.lower()
                                             ).first() is None
__check_email = lambda email: get_user(email=email.lower()).first() is None

UserSchema = Schema(
    {
        Required("email"):
        check(([str, Length(min=4, max=128)
                ], "Your email should be between 4 and 128 characters long."),
              ([__check_email], "Someone already registered this email."),
              ([utils.__check_email_format], "Please enter a legit email.")),
        Required("name"):
        check(([str, Length(min=4, max=128)
                ], "Your name should be between 4 and 128 characters long.")),
        Required("username"):
        check(
            ([str, Length(min=4, max=32)
              ], "Your username should be between 4 and 32 characters long."),
            ([utils.__check_alphanumeric
              ], "Please only use alphanumeric characters in your username."),
            ([__check_first_character_is_letter
              ], "Your username must begin with a letter."),
            ([__check_no_spaces], "Your username must not contain spaces."),
            ([__check_username
              ], "This username is taken, did you forget your password?")),
Exemple #2
0
	if _team.finalized:
		raise WebException("This team is already finalized.")

	_team.finalize()
	return { "success": 1 }

##################
# TEAM FUNCTIONS #
##################

__check_teamname = lambda teamname: get_team(teamname_lower=teamname.lower()).first() is None

TeamSchema = Schema({
	Required("teamname"): check(
		([str, Length(min=4, max=32)], "Your teamname should be between 4 and 32 characters long."),
		([utils.__check_ascii], "Please only use ASCII characters in your teamname."),
		([__check_teamname], "This teamname is taken. Please choose a different one.")
	),
	Required("school"): check(
		([str, Length(min=4, max=40)], "Your school name should be between 4 and 40 characters long. Use abbreviations if necessary."),
		([utils.__check_ascii], "Please only use ASCII characters in your school name."),
	),
}, extra=True)

def get_team_info(tid=None, teamname=None, teamname_lower=None, owner=None):
	team = get_team(tid=tid, teamname=teamname, teamname_lower=teamname_lower, owner=owner).first()
	if team is None:
		raise WebException("Team not found.")

	result = team.get_info()
	return result
Exemple #3
0

##################
# TEAM FUNCTIONS #
##################

__check_teamname = lambda teamname: get_team(teamname_lower=teamname.lower()
                                             ).first() is None

TeamSchema = Schema(
    {
        Required("teamname"):
        check(
            ([str, Length(min=4, max=32)
              ], "Your teamname should be between 4 and 32 characters long."),
            ([utils.__check_ascii
              ], "Please only use ASCII characters in your teamname."),
            ([__check_teamname
              ], "This teamname is taken. Please choose a different one.")),
        Required("school"):
        check(
            ([str, Length(min=4, max=40)],
             "Your school name should be between 4 and 40 characters long. Use abbreviations if necessary."
             ),
            ([utils.__check_ascii
              ], "Please only use ASCII characters in your school name."),
        ),
    },
    extra=True)

Exemple #4
0
	return { "success": 1, "message": "Deleted." }

##################
# USER FUNCTIONS #
##################

__check_first_character_is_letter = lambda username: username[0] in string.letters
__check_no_spaces = lambda username: all([c!=" " for c in username])
__check_username = lambda username: get_user(username_lower=username.lower()).first() is None
__check_email = lambda email: get_user(email=email.lower()).first() is None

UserSchema = Schema({
	Required("email"): check(
		([str, Length(min=4, max=128)], "Your email should be between 4 and 128 characters long."),
		([__check_email], "Someone already registered this email."),
		([utils.__check_email_format], "Please enter a legit email.")
	),
	Required("name"): check(
		([str, Length(min=4, max=128)], "Your name should be between 4 and 128 characters long.")
	),
	Required("username"): check(
		([str, Length(min=4, max=32)], "Your username should be between 4 and 32 characters long."),
		([utils.__check_alphanumeric], "Please only use alphanumeric characters in your username."),
		([__check_first_character_is_letter], "Your username must begin with a letter."),
		([__check_no_spaces], "Your username must not contain spaces."),
		([__check_username], "This username is taken, did you forget your password?")
	),
	Required("password"): check(
		([str, Length(min=4, max=64)], "Your password should be between 4 and 64 characters long."),
		([utils.__check_ascii], "Please only use ASCII characters in your password."),