Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
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
OpenEdx
edx-platform
Commits
0fe36114
Commit
0fe36114
authored
Sep 22, 2017
by
tasawernawaz
Committed by
Dillon Dumesnil
Oct 31, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
make username and courses dropdown dynamic
LEARNER-2679
parent
64ee415a
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
73 additions
and
15 deletions
+73
-15
lms/djangoapps/support/tests/test_views.py
+43
-0
lms/djangoapps/support/views/contact_us.py
+7
-2
lms/static/sass/views/_support.scss
+7
-0
lms/templates/support/contact_us.html
+16
-13
No files found.
lms/djangoapps/support/tests/test_views.py
View file @
0fe36114
...
@@ -374,3 +374,46 @@ class SupportViewEnrollmentsTests(SharedModuleStoreTestCase, SupportViewTestCase
...
@@ -374,3 +374,46 @@ class SupportViewEnrollmentsTests(SharedModuleStoreTestCase, SupportViewTestCase
)
)
verified_mode
.
expiration_datetime
=
datetime
(
year
=
1970
,
month
=
1
,
day
=
9
,
tzinfo
=
UTC
)
verified_mode
.
expiration_datetime
=
datetime
(
year
=
1970
,
month
=
1
,
day
=
9
,
tzinfo
=
UTC
)
verified_mode
.
save
()
verified_mode
.
save
()
class
ContactUsViewTests
(
ModuleStoreTestCase
):
url
=
reverse
(
'support:contact_us'
)
def
setUp
(
self
):
super
(
ContactUsViewTests
,
self
)
.
setUp
()
self
.
user
=
UserFactory
()
self
.
client
.
login
(
username
=
self
.
user
.
username
,
password
=
'test'
)
self
.
user_enrollment
=
CourseEnrollmentFactory
.
create
(
user
=
self
.
user
,
)
def
test_get_with_logged_in_user
(
self
):
""" Verify that logged in users will see courses dropdown."""
response
=
self
.
client
.
get
(
self
.
url
)
expected
=
'<option value="{course_id}">'
.
format
(
course_id
=
self
.
user_enrollment
.
course
.
id
)
self
.
assertContains
(
response
,
expected
)
def
test_get_without_course_enrollment
(
self
):
""" Verify that logged in users will see not courses dropdown,
if they are not enrolled in any course.
"""
self
.
client
.
logout
()
new_user
=
UserFactory
()
self
.
client
.
login
(
username
=
new_user
.
username
,
password
=
'test'
)
response
=
self
.
client
.
get
(
self
.
url
)
self
.
_assert_without_course_enrollment
(
response
)
def
test_get_with_anonymous_user
(
self
):
""" Verify that logged out users will see not courses dropdown.
They will see sign in button.
"""
self
.
client
.
logout
()
response
=
self
.
client
.
get
(
self
.
url
)
self
.
assertContains
(
response
,
'class="btn btn-primary btn-signin">Sign in</a>'
)
self
.
_assert_without_course_enrollment
(
response
)
def
_assert_without_course_enrollment
(
self
,
response
):
""" Assert that users will not see simple course text input."""
expected
=
'<input type="text" class="form-control" id="course">'
self
.
assertContains
(
response
,
expected
)
lms/djangoapps/support/views/contact_us.py
View file @
0fe36114
...
@@ -5,12 +5,17 @@ from django.views.generic import View
...
@@ -5,12 +5,17 @@ from django.views.generic import View
from
edxmako.shortcuts
import
render_to_response
from
edxmako.shortcuts
import
render_to_response
from
student.models
import
CourseEnrollment
#TODO https://openedx.atlassian.net/browse/LEARNER-2296
class
ContactUsView
(
View
):
class
ContactUsView
(
View
):
"""
"""
View for viewing and submitting contact us form.
View for viewing and submitting contact us form.
"""
"""
def
get
(
self
,
request
):
def
get
(
self
,
request
):
return
render_to_response
(
"support/contact_us.html"
)
context
=
{}
if
request
.
user
.
is_authenticated
():
context
[
'user_enrollments'
]
=
CourseEnrollment
.
enrollments_for_user
(
request
.
user
)
return
render_to_response
(
"support/contact_us.html"
,
context
)
lms/static/sass/views/_support.scss
View file @
0fe36114
...
@@ -228,7 +228,14 @@
...
@@ -228,7 +228,14 @@
.btn-signin
{
.btn-signin
{
width
:
$baseline
*
8
;
width
:
$baseline
*
8
;
color
:
$white
;
margin-bottom
:
(
$baseline
*
2
)
+
10
;
margin-bottom
:
(
$baseline
*
2
)
+
10
;
&
:hover
,
&
:focus
{
color
:
$white
;
}
}
}
@media
only
screen
and
(
min-width
:
768px
)
{
@media
only
screen
and
(
min-width
:
768px
)
{
...
...
lms/templates/support/contact_us.html
View file @
0fe36114
...
@@ -2,14 +2,14 @@
...
@@ -2,14 +2,14 @@
<
%!
<
%!
from
django
.
utils
.
translation
import
ugettext
as
_
from
django
.
utils
.
translation
import
ugettext
as
_
from
django
.
utils
.
html
import
escape
%
>
%
>
<
%
inherit
file=
"../main.html"
/>
<
%
inherit
file=
"../main.html"
/>
<
%
namespace
file=
'../main.html'
import=
"login_query"
/>
<
%
block
name=
"title"
>
<
%
block
name=
"title"
>
<title>
<title>
Contact US
${_("Contact US")}
</title>
</title>
</
%
block>
</
%
block>
...
@@ -35,7 +35,7 @@ from django.utils.html import escape
...
@@ -35,7 +35,7 @@ from django.utils.html import escape
<div
class=
"row"
>
<div
class=
"row"
>
<div
class=
"col-sm-12"
>
<div
class=
"col-sm-12"
>
<a
class=
"btn btn-secondary help-button"
>
${_("Visit edX Help")}
</a>
<a
href=
"${marketing_link('FAQ')}"
class=
"btn btn-secondary help-button"
>
${_("Visit edX Help")}
</a>
</div>
</div>
</div>
</div>
<!--logged out users-->
<!--logged out users-->
...
@@ -50,7 +50,7 @@ from django.utils.html import escape
...
@@ -50,7 +50,7 @@ from django.utils.html import escape
<!-- Sign-in button brings user to sign-in page. After signing in, user is brough to logged in state of contact form.-->
<!-- Sign-in button brings user to sign-in page. After signing in, user is brough to logged in state of contact form.-->
<div
class=
"row"
>
<div
class=
"row"
>
<div
class=
"col-sm-12"
>
<div
class=
"col-sm-12"
>
<
button
class=
"btn btn-primary btn-signin"
>
${_("Sign in")}
</button
>
<
a
href=
"/login${login_query()}"
class=
"btn btn-primary btn-signin"
>
${_("Sign in")}
</a
>
</div>
</div>
</div>
</div>
...
@@ -64,8 +64,6 @@ from django.utils.html import escape
...
@@ -64,8 +64,6 @@ from django.utils.html import escape
</div>
</div>
</div>
</div>
<!-- Course is an optional text field in logged out state because we don't know what courses
the user is enrolled in and the question may not be course-specific-->
<div
class=
"row"
>
<div
class=
"row"
>
<div
class=
"col-sm-12"
>
<div
class=
"col-sm-12"
>
<div
class=
"form-group"
>
<div
class=
"form-group"
>
...
@@ -81,7 +79,7 @@ from django.utils.html import escape
...
@@ -81,7 +79,7 @@ from django.utils.html import escape
<div
class=
"row"
>
<div
class=
"row"
>
<div
class=
"col-sm-12"
>
<div
class=
"col-sm-12"
>
<p>
${_("What can we help you with,
iananderson21?"
)}
</p>
<p>
${_("What can we help you with,
{username}?").format(username=user.username
)}
</p>
</div>
</div>
</div>
</div>
<br>
<br>
...
@@ -89,12 +87,17 @@ from django.utils.html import escape
...
@@ -89,12 +87,17 @@ from django.utils.html import escape
<div
class=
"row"
>
<div
class=
"row"
>
<div
class=
"col-sm-12"
>
<div
class=
"col-sm-12"
>
<div
class=
"form-group"
>
<div
class=
"form-group"
>
<label
class=
"label-course"
for=
"course"
>
${_("Course Name")}
</label>
% if user_enrollments:
<select
class=
"form-control select-course"
id=
"course"
>
<label
class=
"label-course"
for=
"course"
>
${_("Course Name")}
</label>
<option>
The Science of Happiness
</option>
<select
class=
"form-control select-course"
id=
"course"
>
<option>
Video Game Design: Teamwork and Collaboration
</option>
% for enrollment in user_enrollments:
<option>
Not course-specific
</option>
<option
value=
"${enrollment.course.id}"
>
${enrollment.course.display_name}
</option>
</select>
% endfor
</select>
% else:
<label
for=
"course"
>
${_("Course Name")}
<span>
${_("(Optional)")}
</span></label>
<input
type=
"text"
class=
"form-control"
id=
"course"
>
% endif
</div>
</div>
</div>
</div>
</div>
</div>
...
...
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