Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
course-discovery
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
course-discovery
Commits
fa67db19
Commit
fa67db19
authored
Oct 25, 2017
by
Asad Azam
Committed by
AsadAzam
Oct 26, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Form validation on course number
parent
3a178f57
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
40 additions
and
4 deletions
+40
-4
course_discovery/apps/publisher/forms.py
+10
-0
course_discovery/apps/publisher/tests/test_forms.py
+16
-0
course_discovery/conf/locale/en/LC_MESSAGES/django.mo
+0
-0
course_discovery/conf/locale/en/LC_MESSAGES/django.po
+5
-1
course_discovery/conf/locale/en/LC_MESSAGES/djangojs.mo
+0
-0
course_discovery/conf/locale/en/LC_MESSAGES/djangojs.po
+1
-1
course_discovery/conf/locale/eo/LC_MESSAGES/django.mo
+0
-0
course_discovery/conf/locale/eo/LC_MESSAGES/django.po
+7
-1
course_discovery/conf/locale/eo/LC_MESSAGES/djangojs.mo
+0
-0
course_discovery/conf/locale/eo/LC_MESSAGES/djangojs.po
+1
-1
No files found.
course_discovery/apps/publisher/forms.py
View file @
fa67db19
import
html
import
logging
import
re
import
waffle
from
dal
import
autocomplete
...
...
@@ -191,6 +192,15 @@ class CourseForm(BaseForm):
"""
return
html
.
unescape
(
self
.
cleaned_data
.
get
(
"title"
))
def
clean_number
(
self
):
"""
Validate that number doesn't consist of any special characters
"""
number
=
self
.
cleaned_data
.
get
(
"number"
)
if
not
re
.
match
(
"^[a-zA-Z0-9_.]*$"
,
number
):
raise
ValidationError
(
_
(
'Please do not use any spaces or special characters.'
))
return
number
def
clean
(
self
):
cleaned_data
=
self
.
cleaned_data
organization
=
cleaned_data
.
get
(
"organization"
)
...
...
course_discovery/apps/publisher/tests/test_forms.py
View file @
fa67db19
...
...
@@ -246,6 +246,22 @@ class PublisherCustomCourseFormTests(TestCase):
course_form
.
cleaned_data
[
'number'
]
=
"123a"
self
.
assertEqual
(
course_form
.
clean
(),
course_form
.
cleaned_data
)
def
test_invalid_number
(
self
):
"""
Verify that clean_number raises 'ValidationError' if the course number consists of special characters
or spaces
"""
course_form
=
CourseForm
()
course_form
.
cleaned_data
=
{
'number'
:
'123 a'
}
with
self
.
assertRaises
(
ValidationError
):
course_form
.
clean_number
()
course_form
.
cleaned_data
[
'number'
]
=
"123.a"
self
.
assertEqual
(
course_form
.
clean_number
(),
"123.a"
)
course_form
.
cleaned_data
[
'number'
]
=
"123a"
self
.
assertEqual
(
course_form
.
clean_number
(),
"123a"
)
def
test_course_title_formatting
(
self
):
"""
Verify that course_title is properly escaped and saved in database while
...
...
course_discovery/conf/locale/en/LC_MESSAGES/django.mo
View file @
fa67db19
No preview for this file type
course_discovery/conf/locale/en/LC_MESSAGES/django.po
View file @
fa67db19
...
...
@@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-10-
16 17:29
+0000\n"
"POT-Creation-Date: 2017-10-
25 06:07
+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
...
...
@@ -684,6 +684,10 @@ msgid "Syllabus"
msgstr ""
#: apps/publisher/forms.py
msgid "Please do not use any spaces or special characters."
msgstr ""
#: apps/publisher/forms.py
msgid "This course title already exists"
msgstr ""
...
...
course_discovery/conf/locale/en/LC_MESSAGES/djangojs.mo
View file @
fa67db19
No preview for this file type
course_discovery/conf/locale/en/LC_MESSAGES/djangojs.po
View file @
fa67db19
...
...
@@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-10-
16 17:29
+0000\n"
"POT-Creation-Date: 2017-10-
25 06:08
+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
...
...
course_discovery/conf/locale/eo/LC_MESSAGES/django.mo
View file @
fa67db19
No preview for this file type
course_discovery/conf/locale/eo/LC_MESSAGES/django.po
View file @
fa67db19
...
...
@@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-10-
16 17:29
+0000\n"
"POT-Creation-Date: 2017-10-
25 06:07
+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
...
...
@@ -815,6 +815,12 @@ msgid "Syllabus"
msgstr "Sýlläßüs Ⱡ'σяєм ιρѕυм ∂#"
#: apps/publisher/forms.py
msgid "Please do not use any spaces or special characters."
msgstr ""
"Pléäsé dö nöt üsé äný späçés ör spéçïäl çhäräçtérs. Ⱡ'σяєм ιρѕυм ∂σłσя ѕιт "
"αмєт, ¢σηѕє¢тєтυя α#"
#: apps/publisher/forms.py
msgid "This course title already exists"
msgstr ""
"Thïs çöürsé tïtlé älréädý éxïsts Ⱡ'σяєм ιρѕυм ∂σłσя ѕιт αмєт, ¢σηѕє¢тє#"
...
...
course_discovery/conf/locale/eo/LC_MESSAGES/djangojs.mo
View file @
fa67db19
No preview for this file type
course_discovery/conf/locale/eo/LC_MESSAGES/djangojs.po
View file @
fa67db19
...
...
@@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-10-
16 17:29
+0000\n"
"POT-Creation-Date: 2017-10-
25 06:08
+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment