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
9b35844b
Commit
9b35844b
authored
Jan 16, 2016
by
Matt Drayer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mattdrayer/index-page-bokchoy: Refactor+cover Open edX LMS index page
parent
22e01a8c
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
129 additions
and
16 deletions
+129
-16
common/djangoapps/student/views.py
+20
-0
common/test/acceptance/pages/lms/index.py
+53
-0
common/test/acceptance/tests/lms/test_lms_index.py
+56
-0
lms/templates/index.html
+0
-16
No files found.
common/djangoapps/student/views.py
View file @
9b35844b
...
...
@@ -169,7 +169,27 @@ def index(request, extra_context=None, user=AnonymousUser()):
context
=
{
'courses'
:
courses
}
context
[
'homepage_overlay_html'
]
=
microsite
.
get_value
(
'homepage_overlay_html'
)
# This appears to be an unused context parameter, at least for the master templates...
context
[
'show_partners'
]
=
microsite
.
get_value
(
'show_partners'
,
True
)
# TO DISPLAY A YOUTUBE WELCOME VIDEO
# 1) Change False to True
context
[
'show_homepage_promo_video'
]
=
microsite
.
get_value
(
'show_homepage_promo_video'
,
False
)
# 2) Add your video's YouTube ID (11 chars, eg "123456789xX"), or specify via microsite config
# Note: This value should be moved into a configuration setting and plumbed-through to the
# context via the microsite configuration workflow, versus living here
youtube_video_id
=
microsite
.
get_value
(
'homepage_promo_video_youtube_id'
,
"your-youtube-id"
)
context
[
'homepage_promo_video_youtube_id'
]
=
youtube_video_id
# allow for microsite override of the courses list
context
[
'courses_list'
]
=
microsite
.
get_template_path
(
'courses_list.html'
)
# Insert additional context for use in the template
context
.
update
(
extra_context
)
return
render_to_response
(
'index.html'
,
context
)
...
...
common/test/acceptance/pages/lms/index.py
0 → 100644
View file @
9b35844b
# -*- coding: utf-8 -*-
"""
LMS index (home) page.
"""
from
bok_choy.page_object
import
PageObject
from
.
import
BASE_URL
BANNER_SELECTOR
=
'section.home header div.outer-wrapper div.title hgroup h1'
INTRO_VIDEO_SELECTOR
=
'div.play-intro'
VIDEO_MODAL_SELECTOR
=
'section#video-modal.modal.home-page-video-modal.video-modal'
class
IndexPage
(
PageObject
):
"""
LMS index (home) page, the default landing page for Open edX users when they are not logged in
"""
def
__init__
(
self
,
browser
):
"""Initialize the page.
Arguments:
browser (Browser): The browser instance.
"""
super
(
IndexPage
,
self
)
.
__init__
(
browser
)
url
=
"{base}/"
.
format
(
base
=
BASE_URL
)
def
is_browser_on_page
(
self
):
"""
Returns a browser query object representing the video modal element
"""
element
=
self
.
q
(
css
=
BANNER_SELECTOR
)
return
element
.
visible
and
element
.
text
[
0
]
==
"Welcome to Open edX!"
@property
def
banner_element
(
self
):
"""
Returns a browser query object representing the video modal element
"""
return
self
.
q
(
css
=
BANNER_SELECTOR
)
@property
def
intro_video_element
(
self
):
"""
Returns a browser query object representing the video modal element
"""
return
self
.
q
(
css
=
INTRO_VIDEO_SELECTOR
)
@property
def
video_modal_element
(
self
):
"""
Returns a browser query object representing the video modal element
"""
return
self
.
q
(
css
=
VIDEO_MODAL_SELECTOR
)
common/test/acceptance/tests/lms/test_lms_index.py
0 → 100644
View file @
9b35844b
# -*- coding: utf-8 -*-
"""
End-to-end tests for the LMS Index page (aka, Home page). Note that this is different than
what students see @ edx.org because we redirect requests to a separate web application.
"""
import
datetime
from
bok_choy.web_app_test
import
WebAppTest
from
...pages.lms.index
import
IndexPage
class
BaseLmsIndexTest
(
WebAppTest
):
""" Base test suite for the LMS Index (Home) page """
def
setUp
(
self
):
"""
Initializes the components (page objects, courses, users) for this test suite
"""
# Some state is constructed by the parent setUp() routine
super
(
BaseLmsIndexTest
,
self
)
.
setUp
()
# Load page objects for use by the tests
self
.
page
=
IndexPage
(
self
.
browser
)
# Navigate to the index page and get testing!
self
.
page
.
visit
()
class
LmsIndexPageTest
(
BaseLmsIndexTest
):
""" Test suite for the LMS Index (Home) page """
def
setUp
(
self
):
super
(
LmsIndexPageTest
,
self
)
.
setUp
()
# Useful to capture the current datetime for our tests
self
.
now
=
datetime
.
datetime
.
now
()
def
test_index_basic_request
(
self
):
"""
Perform a general validation of the index page, renders normally, no exceptions raised, etc.
"""
self
.
assertTrue
(
self
.
page
.
banner_element
.
visible
)
def
test_intro_video_hidden_by_default
(
self
):
"""
Confirm that the intro video is not displayed when using the default configuration
"""
# Ensure the introduction video element is not shown
self
.
assertFalse
(
self
.
page
.
intro_video_element
.
visible
)
# @fghaas: The below presence check can now be modified along with your changeset
# Still need to figure out how to swap platform settings in the context of a bok choy test
# but we can at least prevent accidental exposure with these validations going forward
# Note: 'present' is a DOM check, whereas 'visible' is an actual browser/screen check
self
.
assertTrue
(
self
.
page
.
video_modal_element
.
present
)
self
.
assertFalse
(
self
.
page
.
video_modal_element
.
visible
)
lms/templates/index.html
View file @
9b35844b
...
...
@@ -3,18 +3,6 @@
<
%!
from
django
.
utils
.
translation
import
ugettext
as
_
from
django
.
core
.
urlresolvers
import
reverse
from
microsite_configuration
import
microsite
%
>
<
%
homepage_overlay_html =
microsite.get_value('homepage_overlay_html')
##
To
display
a
welcome
video
,
change
False
to
True
,
and
add
a
YouTube
ID
(
11
chars
,
eg
"
123456789xX
")
in
the
following
line
show_homepage_promo_video =
microsite.get_value('show_homepage_promo_video',
False
)
homepage_promo_video_youtube_id =
microsite.get_value('homepage_promo_video_youtube_id',
"
your-youtube-id
")
show_partners =
microsite.get_value('show_partners',
True
)
%
>
<section
class=
"home"
>
...
...
@@ -61,10 +49,6 @@ from microsite_configuration import microsite
</div>
</header>
<
%
#
allow
for
microsite
override
of
the
courses
list
courses_list =
microsite.get_template_path('courses_list.html')
%
>
<
%
include
file=
"${courses_list}"
/>
</section>
...
...
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