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
edx
edx-platform
Commits
9d827b7e
Commit
9d827b7e
authored
Sep 22, 2017
by
tasawernawaz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
make username and courses dropdown dynamic
LEARNER-2679
parent
c8706044
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 @
9d827b7e
...
...
@@ -374,3 +374,46 @@ class SupportViewEnrollmentsTests(SharedModuleStoreTestCase, SupportViewTestCase
)
verified_mode
.
expiration_datetime
=
datetime
(
year
=
1970
,
month
=
1
,
day
=
9
,
tzinfo
=
UTC
)
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 @
9d827b7e
...
...
@@ -5,12 +5,17 @@ from django.views.generic import View
from
edxmako.shortcuts
import
render_to_response
from
student.models
import
CourseEnrollment
#TODO https://openedx.atlassian.net/browse/LEARNER-2296
class
ContactUsView
(
View
):
"""
View for viewing and submitting contact us form.
"""
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 @
9d827b7e
...
...
@@ -228,7 +228,14 @@
.btn-signin
{
width
:
$baseline
*
8
;
color
:
$white
;
margin-bottom
:
(
$baseline
*
2
)
+
10
;
&
:hover
,
&
:focus
{
color
:
$white
;
}
}
@media
only
screen
and
(
min-width
:
768px
)
{
...
...
lms/templates/support/contact_us.html
View file @
9d827b7e
...
...
@@ -2,14 +2,14 @@
<
%!
from
django
.
utils
.
translation
import
ugettext
as
_
from
django
.
utils
.
html
import
escape
%
>
<
%
inherit
file=
"../main.html"
/>
<
%
namespace
file=
'../main.html'
import=
"login_query"
/>
<
%
block
name=
"title"
>
<title>
Contact US
${_("Contact US")}
</title>
</
%
block>
...
...
@@ -35,7 +35,7 @@ from django.utils.html import escape
<div
class=
"row"
>
<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>
<!--logged out users-->
...
...
@@ -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.-->
<div
class=
"row"
>
<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>
...
...
@@ -64,8 +64,6 @@ from django.utils.html import escape
</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=
"col-sm-12"
>
<div
class=
"form-group"
>
...
...
@@ -81,7 +79,7 @@ from django.utils.html import escape
<div
class=
"row"
>
<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>
<br>
...
...
@@ -89,12 +87,17 @@ from django.utils.html import escape
<div
class=
"row"
>
<div
class=
"col-sm-12"
>
<div
class=
"form-group"
>
<label
class=
"label-course"
for=
"course"
>
${_("Course Name")}
</label>
<select
class=
"form-control select-course"
id=
"course"
>
<option>
The Science of Happiness
</option>
<option>
Video Game Design: Teamwork and Collaboration
</option>
<option>
Not course-specific
</option>
</select>
% if user_enrollments:
<label
class=
"label-course"
for=
"course"
>
${_("Course Name")}
</label>
<select
class=
"form-control select-course"
id=
"course"
>
% for enrollment in user_enrollments:
<option
value=
"${enrollment.course.id}"
>
${enrollment.course.display_name}
</option>
% endfor
</select>
% else:
<label
for=
"course"
>
${_("Course Name")}
<span>
${_("(Optional)")}
</span></label>
<input
type=
"text"
class=
"form-control"
id=
"course"
>
% endif
</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