-
Notifications
You must be signed in to change notification settings - Fork 12
RDISCROWD-7728 ownership id on project create page #1055
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Pull Request Test Coverage Report for Build 14199405470Details
💛 - Coveralls |
pybossa/api/project.py
Outdated
validate_ownership_id(project.info.get('ownership_id')) | ||
if not valid_ownership_id(project.info.get('ownership_id')): | ||
ownership_id_title = current_app.config.get('OWNERSHIP_ID_TITLE', 'Ownership ID') | ||
raise ValueError(f"{ownership_id_title} must be numeric and less than 20 characters.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems inconsistent behavior with the error is getting reported via api above and from fronted here as the error messages are different; line above missing Got :<input-number>
. It would be nice to have a single place from where a consistent error message is reported back both for api or frontend. This can be achieved via existing similar implementations here
pybossa/util.py
Outdated
def valid_ownership_id(o_id): | ||
if o_id == None or len(o_id) == 0: | ||
return | ||
return True | ||
if not (o_id.isnumeric() and len(o_id) <= 20): | ||
raise ValueError(f"{ownership_id_title} must be numeric and less than 20 characters. Got: {o_id}") | ||
return False | ||
return True |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Is it possible to pass numeric value to this function thereby causing
isnumeric
call to raise exception - Can this function be refactored so that it returns True only when condition is satisfied and False otherwise
ex
if not o_id or (isinstance(o_id, str) and o_id.isnumeric() and len(o_id) <= 20):
return True
return False
*Issue number of the reported bug or feature request: RDISCROWD-7728
Describe your changes
Related
bloomberg/pybossa-default-theme#488