From f14dd9d3c577ce13ee970612e3d9c2b5db6dee79 Mon Sep 17 00:00:00 2001 From: Waheed Ahmed Date: Thu, 17 Jul 2014 15:52:02 +0500 Subject: [PATCH] Disabled student view if course is not yet released for students. LMS-6617 Fixed wiki merge url regex. TNL-413 ECOM-345 changed any lists that could display with only 1 item to divs ECOM-345 Added aria tags for header ECOM-364 Accessibility update for footer added my name to the authors file Addressing feedback from code review - removing unnecessary element references in selectors Updated header aria-label to be main --- AUTHORS | 1 + lms/djangoapps/courseware/views.py | 18 +- lms/envs/common.py | 1 + lms/static/sass/shared/_header.scss | 736 +++++++++--------- .../courseware/course_navigation.html | 7 + lms/templates/footer-edx-new.html | 16 +- lms/templates/navigation.html | 50 +- lms/urls.py | 2 +- 8 files changed, 435 insertions(+), 396 deletions(-) diff --git a/AUTHORS b/AUTHORS index c170b8459f..a27106006a 100644 --- a/AUTHORS +++ b/AUTHORS @@ -173,3 +173,4 @@ Jason Zhu Marceau Cnudde Braden MacDonald Jonathan Piacenti +Alasdair Swan diff --git a/lms/djangoapps/courseware/views.py b/lms/djangoapps/courseware/views.py index 20164db01f..c9b50d18b6 100644 --- a/lms/djangoapps/courseware/views.py +++ b/lms/djangoapps/courseware/views.py @@ -6,6 +6,7 @@ import logging import urllib import json +from datetime import datetime from collections import defaultdict from django.utils import translation from django.utils.translation import ugettext as _ @@ -16,6 +17,7 @@ from django.core.exceptions import PermissionDenied from django.core.urlresolvers import reverse from django.contrib.auth.models import User, AnonymousUser from django.contrib.auth.decorators import login_required +from django.utils.timezone import UTC from django.views.decorators.http import require_GET from django.http import Http404, HttpResponse from django.shortcuts import redirect @@ -27,7 +29,7 @@ from functools import wraps from markupsafe import escape from courseware import grades -from courseware.access import has_access +from courseware.access import has_access, _adjust_start_date_for_beta_testers from courseware.courses import get_courses, get_course, get_studio_url, get_course_with_access, sort_by_announcement from courseware.masquerade import setup_masquerade from courseware.model_data import FieldDataCache @@ -337,6 +339,13 @@ def index(request, course_id, chapter=None, section=None, 'reverifications': fetch_reverify_banner_info(request, course_key), } + now = datetime.now(UTC()) + effective_start = _adjust_start_date_for_beta_testers(user, course, course_key) + if staff_access and now < effective_start: + # Disable student view button if user is staff and + # course is not yet visible to students. + context['disable_student_access'] = True + has_content = course.has_children_at_depth(CONTENT_DEPTH) if not has_content: # Show empty courseware for a course with no units @@ -590,6 +599,13 @@ def course_info(request, course_id): 'url_to_enroll': url_to_enroll, } + now = datetime.now(UTC()) + effective_start = _adjust_start_date_for_beta_testers(request.user, course, course_key) + if staff_access and now < effective_start: + # Disable student view button if user is staff and + # course is not yet visible to students. + context['disable_student_access'] = True + return render_to_response('courseware/info.html', context) diff --git a/lms/envs/common.py b/lms/envs/common.py index b331e39340..52e202eb05 100644 --- a/lms/envs/common.py +++ b/lms/envs/common.py @@ -469,6 +469,7 @@ LMS_MIGRATION_ALLOWED_IPS = [] # too many inadvertent side effects :-( COURSE_KEY_PATTERN = r'(?P[^/+]+(/|\+)[^/+]+(/|\+)[^/]+)' COURSE_ID_PATTERN = COURSE_KEY_PATTERN.replace('course_key_string', 'course_id') +COURSE_KEY_REGEX = COURSE_KEY_PATTERN.replace('P', ':') USAGE_KEY_PATTERN = r'(?P(?:i4x://?[^/]+/[^/]+/[^/]+/[^@]+(?:@[^/]+)?)|(?:[^/]+))' ASSET_KEY_PATTERN = r'(?P(?:/?c4x(:/)?/[^/]+/[^/]+/[^/]+/[^@]+(?:@[^/]+)?)|(?:[^/]+))' diff --git a/lms/static/sass/shared/_header.scss b/lms/static/sass/shared/_header.scss index eb6226e97a..8581d92010 100644 --- a/lms/static/sass/shared/_header.scss +++ b/lms/static/sass/shared/_header.scss @@ -26,208 +26,207 @@ header.global { } } - ol { - &.left { - float: left; + .left { + float: left; + } + + .guest { + float: right; + } + + > li { + display: inline-block; + margin-right: 20px; + position: relative; + vertical-align: middle; + + &:last-child { + margin-right: 0px; } - &.guest { - float: right; + a { + letter-spacing: 1px; + vertical-align: middle; } + } - > li { + li.secondary { + > a { + color: $link-color; + display: block; + font-family: $sans-serif; display: inline-block; - margin-right: 20px; - position: relative; + margin: 0px 30px 0px 0px; + text-decoration: none; + text-transform: uppercase; + text-shadow: 0 1px rgba(255,255,255, 0.6); + + &:last-child { + margin-right: 0px; + } + + &:hover, &:focus { + color: $base-font-color; + } + } + } + + .primary { + margin-right: 5px; + + > a { + @include background-image($button-bg-image); + background-color: $button-bg-color; + border: 1px solid $border-color-2; + border-radius: 3px; + @include box-sizing(border-box); + box-shadow: 0 1px 0 0 rgba(255,255,255, 0.6); + color: $base-font-color; + display: inline-block; + font-family: $sans-serif; + display: inline-block; + line-height: 1em; + margin: 1px 5px; + padding: 10px 12px; + text-decoration: none; + text-transform: uppercase; + text-shadow: 0 1px rgba(255,255,255, 0.6); vertical-align: middle; &:last-child { margin-right: 0px; } - a { - letter-spacing: 1px; - vertical-align: middle; + &:hover, &:focus, &:active { + background: $button-bg-hover-color; } } + } - li.secondary { - > a { - color: $link-color; - display: block; - font-family: $sans-serif; - display: inline-block; - margin: 0px 30px 0px 0px; - text-decoration: none; - text-transform: uppercase; - text-shadow: 0 1px rgba(255,255,255, 0.6); + .user { + float: right; + margin-top: 4px; - &:last-child { - margin-right: 0px; - } - - &:hover, &:focus { - color: $base-font-color; - } - } - } - - li.primary { - margin-right: 5px; + > .primary { + display: block; + float: left; + margin: 0px; + position: relative; > a { - @include background-image($button-bg-image); - background-color: $button-bg-color; - border: 1px solid $border-color-2; - border-radius: 3px; - @include box-sizing(border-box); - box-shadow: 0 1px 0 0 rgba(255,255,255, 0.6); - color: $base-font-color; - display: inline-block; - font-family: $sans-serif; - display: inline-block; - line-height: 1em; - margin: 1px 5px; - padding: 10px 12px; - text-decoration: none; - text-transform: uppercase; - text-shadow: 0 1px rgba(255,255,255, 0.6); - vertical-align: middle; - - &:last-child { - margin-right: 0px; - } - - &:hover, &:focus, &:active { - background: $button-bg-hover-color; - } - } - } - - &.user { - float: right; - margin-top: 4px; - - > li.primary { - display: block; - float: left; margin: 0px; + @include border-right-radius(0px); + } + + &:last-child { + > a { + border-radius: 0 4px 4px 0; + border-left: none; + padding: 5px 8px 7px 8px; + + &.shopping-cart { + border-radius: 4px; + border: 1px solid $border-color-2; + margin-right: 10px; + padding-bottom: 6px; + } + } + } + } + + a.user-link { + padding: 6px 12px 8px 35px; + position: relative; + text-transform: none; + font-size: 14px; + font-weight: bold; + letter-spacing: 0; + + .avatar { + @include background-image(url('../images/small-header-home-icon.png')); + background-repeat: no-repeat; + height: 26px; + display: inline-block; + left: 8px; + opacity: 0.5; + overflow: hidden; + position: absolute; + top: 4px; + @include transition(all 0.15s linear 0s); + width: 26px; + } + + &:hover, &:focus { + .avatar { + opacity: 0.8; + } + } + } + + .dropdown-menu { + background: $border-color-4; + border-radius: 4px; + box-shadow: 0 2px 24px 0 rgba(0,0,0, 0.3); + border: 1px solid $border-color-3; + display: none; + padding: 5px 10px; + position: absolute; + right: 0px; + top: 34px; + width: 170px; + z-index: 3; + + &.expanded { + display: block; + } + + &::before { + background: transparent; + border: { + top: 6px solid $border-color-4; + right: 6px solid $border-color-4; + bottom: 6px solid transparent; + left: 6px solid transparent; + } + box-shadow: 1px 0 0 0 $border-color-3, 0 -1px 0 0 $border-color-3; + content: ""; + display: block; + height: 0px; + position: absolute; + @include transform(rotate(-45deg)); + right: 12px; + top: -6px; + width: 0px; + } + + li { + display: block; + border-top: 1px dotted $border-color-2; + box-shadow: inset 0 1px 0 0 rgba(255,255,255, 0.05); + + &:first-child { + border: none; + box-shadow: none; + } > a { - margin: 0px; - @include border-right-radius(0px); - } - - &:last-child { - > a { - border-radius: 0 4px 4px 0; - border-left: none; - padding: 5px 8px 7px 8px; - - &.shopping-cart { - border-radius: 4px; - border: 1px solid $border-color-2; - margin-right: 10px; - padding-bottom: 6px; - } - } - } - } - - a.user-link { - padding: 6px 12px 8px 35px; - position: relative; - text-transform: none; - font-size: 14px; - font-weight: bold; - letter-spacing: 0; - - .avatar { - @include background-image(url('../images/small-header-home-icon.png')); - background-repeat: no-repeat; - height: 26px; - display: inline-block; - left: 8px; - opacity: 0.5; + border: 1px solid transparent; + border-radius: 3px; + @include box-sizing(border-box); + color: $link-color; + cursor: pointer; + display: block; + margin: 5px 0px; overflow: hidden; - position: absolute; - top: 4px; - @include transition(all 0.15s linear 0s); - width: 26px; - } + padding: 3px 5px 4px; + text-overflow: ellipsis; + @include transition(padding 0.15s linear 0s); + white-space: nowrap; + width: 100%; - &:hover, &:focus { - .avatar { - opacity: 0.8; - } - } - } - - ul.dropdown-menu { - background: $border-color-4; - border-radius: 4px; - box-shadow: 0 2px 24px 0 rgba(0,0,0, 0.3); - border: 1px solid $border-color-3; - display: none; - padding: 5px 10px; - position: absolute; - right: 0px; - top: 34px; - width: 170px; - z-index: 3; - - &.expanded { - display: block; - } - - &::before { - background: transparent; - border: { - top: 6px solid $border-color-4; - right: 6px solid $border-color-4; - bottom: 6px solid transparent; - left: 6px solid transparent; - } - box-shadow: 1px 0 0 0 $border-color-3, 0 -1px 0 0 $border-color-3; - content: ""; - display: block; - height: 0px; - position: absolute; - @include transform(rotate(-45deg)); - right: 12px; - top: -6px; - width: 0px; - } - - li { - display: block; - border-top: 1px dotted $border-color-2; - box-shadow: inset 0 1px 0 0 rgba(255,255,255, 0.05); - - &:first-child { - border: none; - box-shadow: none; - } - - > a { - border: 1px solid transparent; - border-radius: 3px; - @include box-sizing(border-box); - color: $link-color; - cursor: pointer; - display: block; - margin: 5px 0px; - overflow: hidden; - padding: 3px 5px 4px; - text-overflow: ellipsis; - @include transition(padding 0.15s linear 0s); - white-space: nowrap; - width: 100%; - - &:hover, &:focus { - color: $base-font-color; - text-decoration: none; - } + &:hover, &:focus { + color: $base-font-color; + text-decoration: none; } } } @@ -237,8 +236,10 @@ header.global { .nav-global { margin-top: ($baseline/2); list-style: none; + float: left; - li { + li, + div { display: inline-block; margin: 0 $baseline+1 0 0; font-size: em(14); @@ -282,7 +283,7 @@ header.global { margin-top: ($baseline/4); list-style: none; - li { + div { display: inline-block; .cta { @@ -350,205 +351,204 @@ header.global-new { } } - ol { - &.left { - float: left; + .left { + float: left; + } + + .guest { + float: right; + } + + > li { + display: inline-block; + margin-right: 20px; + position: relative; + vertical-align: middle; + + &:last-child { + margin-right: 0px; } - &.guest { - float: right; + a { + vertical-align: middle; } + } - > li { + li.secondary { + > a { + color: $link-color; + font-family: $sans-serif; display: inline-block; - margin-right: 20px; - position: relative; + margin: 0px 30px 0px 0px; + text-decoration: none; + text-transform: uppercase; + text-shadow: 0 1px rgba(255,255,255, 0.6); + + &:last-child { + margin-right: 0px; + } + + &:hover, &:focus { + color: $base-font-color; + } + } + } + + .primary { + margin-right: 5px; + + > a { + @include background-image($button-bg-image); + background-color: $button-bg-color; + border: 1px solid $border-color-2; + border-radius: 3px; + @include box-sizing(border-box); + box-shadow: 0 1px 0 0 rgba(255,255,255, 0.6); + color: $base-font-color; + font-family: $header-sans-serif; + display: inline-block; + line-height: 1em; + margin: 1px 5px; + padding: 10px 12px; + text-decoration: none; + text-transform: uppercase; + text-shadow: 0 1px rgba(255,255,255, 0.6); vertical-align: middle; &:last-child { margin-right: 0px; } - a { - vertical-align: middle; + &:hover, &:focus, &:active { + background: $button-bg-hover-color; } } + } - li.secondary { - > a { - color: $link-color; - font-family: $sans-serif; - display: inline-block; - margin: 0px 30px 0px 0px; - text-decoration: none; - text-transform: uppercase; - text-shadow: 0 1px rgba(255,255,255, 0.6); + .user { + float: right; + margin-top: 4px; - &:last-child { - margin-right: 0px; - } - - &:hover, &:focus { - color: $base-font-color; - } - } - } - - li.primary { - margin-right: 5px; + > .primary { + display: block; + float: left; + margin: 0px; + position: relative; > a { - @include background-image($button-bg-image); - background-color: $button-bg-color; - border: 1px solid $border-color-2; - border-radius: 3px; - @include box-sizing(border-box); - box-shadow: 0 1px 0 0 rgba(255,255,255, 0.6); - color: $base-font-color; - font-family: $header-sans-serif; - display: inline-block; - line-height: 1em; - margin: 1px 5px; - padding: 10px 12px; - text-decoration: none; - text-transform: uppercase; - text-shadow: 0 1px rgba(255,255,255, 0.6); - vertical-align: middle; - - &:last-child { - margin-right: 0px; - } - - &:hover, &:focus, &:active { - background: $button-bg-hover-color; - } - } - } - - &.user { - float: right; - margin-top: 4px; - - > li.primary { - display: block; - float: left; margin: 0px; + @include border-right-radius(0px); + } + + &:last-child { + > a { + border-radius: 0 4px 4px 0; + border-left: none; + padding: 5px 8px 7px 8px; + + &.shopping-cart { + border-radius: 4px; + border: 1px solid $border-color-2; + margin-right: 10px; + padding-bottom: 6px; + } + } + } + } + + a.user-link { + padding: 6px 12px 8px 35px; + position: relative; + text-transform: none; + font-size: 14px; + font-weight: bold; + letter-spacing: 0; + + .avatar { + @include background-image(url('../images/small-header-home-icon.png')); + background-repeat: no-repeat; + height: 26px; + display: inline-block; + left: 8px; + opacity: 0.5; + overflow: hidden; + position: absolute; + top: 4px; + @include transition(all 0.15s linear 0s); + width: 26px; + } + + &:hover, &:focus { + .avatar { + opacity: 0.8; + } + } + } + + .dropdown-menu { + background: $border-color-4; + border-radius: 4px; + box-shadow: 0 2px 24px 0 rgba(0,0,0, 0.3); + border: 1px solid $border-color-3; + display: none; + padding: 5px 10px; + position: absolute; + right: 0px; + top: 34px; + width: 170px; + z-index: 3; + + &.expanded { + display: block; + } + + &::before { + background: transparent; + border: { + top: 6px solid $border-color-4; + right: 6px solid $border-color-4; + bottom: 6px solid transparent; + left: 6px solid transparent; + } + box-shadow: 1px 0 0 0 $border-color-3, 0 -1px 0 0 $border-color-3; + content: ""; + display: block; + height: 0px; + position: absolute; + @include transform(rotate(-45deg)); + right: 12px; + top: -6px; + width: 0px; + } + + li { + display: block; + border-top: 1px dotted $border-color-2; + box-shadow: inset 0 1px 0 0 rgba(255,255,255, 0.05); + + &:first-child { + border: none; + box-shadow: none; + } > a { - margin: 0px; - @include border-right-radius(0px); - } - - &:last-child { - > a { - border-radius: 0 4px 4px 0; - border-left: none; - padding: 5px 8px 7px 8px; - - &.shopping-cart { - border-radius: 4px; - border: 1px solid $border-color-2; - margin-right: 10px; - padding-bottom: 6px; - } - } - } - } - - a.user-link { - padding: 6px 12px 8px 35px; - position: relative; - text-transform: none; - font-size: 14px; - font-weight: bold; - letter-spacing: 0; - - .avatar { - @include background-image(url('../images/small-header-home-icon.png')); - background-repeat: no-repeat; - height: 26px; - display: inline-block; - left: 8px; - opacity: 0.5; + border: 1px solid transparent; + border-radius: 3px; + @include box-sizing(border-box); + color: $link-color; + cursor: pointer; + display: block; + margin: 5px 0px; overflow: hidden; - position: absolute; - top: 4px; - @include transition(all 0.15s linear 0s); - width: 26px; - } + padding: 3px 5px 4px; + text-overflow: ellipsis; + @include transition(padding 0.15s linear 0s); + white-space: nowrap; + width: 100%; - &:hover, &:focus { - .avatar { - opacity: 0.8; - } - } - } - - ul.dropdown-menu { - background: $border-color-4; - border-radius: 4px; - box-shadow: 0 2px 24px 0 rgba(0,0,0, 0.3); - border: 1px solid $border-color-3; - display: none; - padding: 5px 10px; - position: absolute; - right: 0px; - top: 34px; - width: 170px; - z-index: 3; - - &.expanded { - display: block; - } - - &::before { - background: transparent; - border: { - top: 6px solid $border-color-4; - right: 6px solid $border-color-4; - bottom: 6px solid transparent; - left: 6px solid transparent; - } - box-shadow: 1px 0 0 0 $border-color-3, 0 -1px 0 0 $border-color-3; - content: ""; - display: block; - height: 0px; - position: absolute; - @include transform(rotate(-45deg)); - right: 12px; - top: -6px; - width: 0px; - } - - li { - display: block; - border-top: 1px dotted $border-color-2; - box-shadow: inset 0 1px 0 0 rgba(255,255,255, 0.05); - - &:first-child { - border: none; - box-shadow: none; - } - - > a { - border: 1px solid transparent; - border-radius: 3px; - @include box-sizing(border-box); - color: $link-color; - cursor: pointer; - display: block; - margin: 5px 0px; - overflow: hidden; - padding: 3px 5px 4px; - text-overflow: ellipsis; - @include transition(padding 0.15s linear 0s); - white-space: nowrap; - width: 100%; - - &:hover, &:focus { - color: $base-font-color; - text-decoration: none; - } + &:hover, &:focus { + color: $base-font-color; + text-decoration: none; } } } @@ -558,8 +558,10 @@ header.global-new { .nav-global { margin-top: ($baseline/2); list-style: none; + float: left; - li { + li, + div { display: inline-block; margin: 0 $baseline+1 0 0; text-transform: uppercase; @@ -587,12 +589,22 @@ header.global-new { } } - .nav-courseware { @extend .nav-global; float: right; - li { + div { + display: inline-block; + margin: 0 21px 0 0; + text-transform: uppercase; + letter-spacing: 0!important; + position: relative; + vertical-align: middle; + + &:last-child { + margin-right: 0; + } + a { &.nav-courseware-button { padding: 5px 45px 5px 45px; diff --git a/lms/templates/courseware/course_navigation.html b/lms/templates/courseware/course_navigation.html index 267bc6896a..248ef0f45d 100644 --- a/lms/templates/courseware/course_navigation.html +++ b/lms/templates/courseware/course_navigation.html @@ -62,6 +62,10 @@ def url_class(is_active):