diff --git a/pagure/api/project.py b/pagure/api/project.py index 7c622a5..3ff92dc 100644 --- a/pagure/api/project.py +++ b/pagure/api/project.py @@ -241,9 +241,9 @@ def api_new_project(): if form.validate_on_submit(): name = form.name.data description = form.description.data - namespace = form.namespace.data.strip() or None - if namespace == 'None': - namespace = None + namespace = form.namespace.data + if namespace: + namespace = namespace.strip() url = form.url.data avatar_email = form.avatar_email.data create_readme = form.create_readme.data diff --git a/pagure/forms.py b/pagure/forms.py index 4b57f3b..9b12c28 100644 --- a/pagure/forms.py +++ b/pagure/forms.py @@ -95,6 +95,7 @@ class ProjectForm(ProjectFormSimplified): 'Project Namespace', [wtforms.validators.optional()], choices=[], + coerce=lambda val: unicode(val) if val else None ) def __init__(self, *args, **kwargs): diff --git a/pagure/ui/app.py b/pagure/ui/app.py index dafa0ac..6f2f8f7 100644 --- a/pagure/ui/app.py +++ b/pagure/ui/app.py @@ -386,9 +386,9 @@ def new_project(): url = form.url.data avatar_email = form.avatar_email.data create_readme = form.create_readme.data - namespace = form.namespace.data.strip() or None - if namespace == 'None': - namespace = None + namespace = form.namespace.data + if namespace: + namespace = namespace.strip() try: pagure.lib.new_project(