Exemple #1
0
    def validate_params(params):
        (are_orig_valid, orig_error_msg) = \
                         AbstractModel.validate_orig_params(params)
        league_ok = False
        if are_orig_valid:
            error_msgs = []
        else:
            error_msgs = [orig_error_msg]
        if "league" in params:
            league_valid = AbstractModel.validate_param(
                Team.validate_league(params["league"]),
                error_msgs)
            if league_valid:
                league_ok = True
        else:
            error_msgs.append("League is missing")

        location_ok = False
        if "location" in params:
            location_valid = AbstractModel.validate_param(
                Team.validate_location(params["location"]),
                error_msgs)
            if location_valid:
                location_ok = True
        else:
            error_msgs.append("Location is missing")

        if are_orig_valid and league_ok and location_ok:
            return (True, None)
        else:
            return (False, ",".join(error_msgs))
Exemple #2
0
    def validate_params(params):
        error_msgs = []
        (are_orig_valid, orig_error_msg) = \
                         AbstractModel.validate_orig_params(params)
        start_date_str = end_date_str = None
        start_date = end_date = None

        if "start_date_str" in params:
            start_date_str = params["start_date_str"]
            (start_date, start_date_error_msg) = \
                         Event.validate_date(start_date_str, "start_date")
            if not start_date:
                error_msgs.append(start_date_error_msg)
            else:
                params["start_date"] = start_date
        if "end_date_str" in params:
            end_date_str = params["end_date_str"]
            (end_date, end_date_error_msg) = \
                       Event.validate_date(end_date_str, "end_date")
            if not end_date:
                error_msgs.append(end_date_error_msg)
            else:
                params["end_date"] = end_date

        (are_dates_valid, date_error_msg) = \
                          Event.validate_dates(start_date, end_date)
        if are_orig_valid and are_dates_valid:
            return (True, None)
        else:
            if orig_error_msg:
                error_msgs.append(orig_error_msg)
            if date_error_msg:
                error_msgs.append(date_error_msg)
            return (False, ",".join(error_msgs))
Exemple #3
0
 def validate_params(params):
     (are_orig_valid, orig_error_msg) = \
                      AbstractModel.validate_orig_params(params)
     error_msgs = []
     if "sport" in params:
         sport_valid = AbstractModel.validate_param(
             League.validate_sport(params["sport"]),
             error_msgs)
         if sport_valid:
             return (are_orig_valid, orig_error_msg)
         else:
             return (False, ",".join(orig_error_msg, "Sport is null"))
     else:
         return (False, ",".join(orig_error_msg, "Sport is missing"))
Exemple #4
0
 def validate_params(params):
     (are_orig_valid, orig_error_msg) = \
                      AbstractModel.validate_orig_params(params)
     if are_orig_valid:
         error_msgs = []
     else:
         error_msgs = [orig_error_msg]
     if "league" in params:
         league_valid = AbstractModel.validate_param(
             Season.validate_league(params["league"]), error_msgs)
         if league_valid:
             return (are_orig_valid, orig_error_msg)
         else:
             error_msgs.append("League is invalid")
             return (False, ",".join(error_msgs))
     else:
         error_msgs.append("League is missing")
         return (False, ",".join(error_msgs))
Exemple #5
0
 def validate_params(params):
     return AbstractModel.validate_orig_params(params)