From ac71da1535528ed9ab21a613397a13ed0c688d98 Mon Sep 17 00:00:00 2001 From: Calen Pennington Date: Thu, 11 Oct 2012 14:18:02 -0400 Subject: [PATCH] Make header tabs work --- cms/djangoapps/contentstore/views.py | 27 +++++++++++++++++++++++++- cms/static/sass/_header.scss | 29 ++++++++++++++++++++++++---- cms/templates/base.html | 3 +-- cms/templates/manage_users.html | 1 - cms/templates/overview.html | 2 +- cms/templates/widgets/header.html | 17 ++++++++++------ 6 files changed, 64 insertions(+), 15 deletions(-) diff --git a/cms/djangoapps/contentstore/views.py b/cms/djangoapps/contentstore/views.py index 85d0253a7e..535862a784 100644 --- a/cms/djangoapps/contentstore/views.py +++ b/cms/djangoapps/contentstore/views.py @@ -157,6 +157,8 @@ def course_index(request, org, course, name): sections = course.get_children() return render_to_response('overview.html', { + 'active_tab': 'courseware', + 'context_course': course, 'sections': sections, 'parent_location': course.location, 'new_section_template': Location('i4x', 'edx', 'templates', 'chapter', 'Empty'), @@ -198,6 +200,7 @@ def edit_subsection(request, location): return render_to_response('edit_subsection.html', {'subsection': item, + 'context_course': course, 'create_new_unit_template': Location('i4x', 'edx', 'templates', 'vertical', 'Empty'), 'lms_link': lms_link, 'parent_item' : parent, @@ -256,6 +259,7 @@ def edit_unit(request, location): published_date = None return render_to_response('unit.html', { + 'context_course': course, 'unit': item, 'unit_location': location, 'components': components, @@ -679,7 +683,11 @@ def manage_users(request, location): if not has_access(request.user, location, role=INSTRUCTOR_ROLE_NAME): raise PermissionDenied() + course_module = modulestore().get_item(location) + return render_to_response('manage_users.html', { + 'active_tab': 'users', + 'context_course': course_module, 'staff': get_users_in_course_group_by_role(location, STAFF_ROLE_NAME), 'add_user_postback_url' : reverse('add_user', args=[location]).rstrip('/'), 'remove_user_postback_url' : reverse('remove_user', args=[location]).rstrip('/') @@ -755,7 +763,19 @@ def landing(request, org, course, coursename): def static_pages(request, org, course, coursename): - return render_to_response('static-pages.html', {}) + + location = ['i4x', org, course, 'course', coursename] + + # check that logged in user has permissions to this item + if not has_access(request.user, location): + raise PermissionDenied() + + course = modulestore().get_item(location) + + return render_to_response('static-pages.html', { + 'active_tab': 'pages', + 'context_course': course, + }) def edit_static(request, org, course, coursename): @@ -784,11 +804,14 @@ def asset_index(request, org, course, name): if not has_access(request.user, location): raise PermissionDenied() + upload_asset_callback_url = reverse('upload_asset', kwargs = { 'org' : org, 'course' : course, 'coursename' : name }) + + course_module = modulestore().get_item(location) course_reference = StaticContent.compute_location(org, course, name) assets = contentstore().get_all_content_for_course(course_reference) @@ -811,6 +834,8 @@ def asset_index(request, org, course, name): asset_display.append(display_info) return render_to_response('asset_index.html', { + 'active_tab': 'assets', + 'context_course': course_module, 'assets': asset_display, 'upload_asset_callback_url': upload_asset_callback_url }) diff --git a/cms/static/sass/_header.scss b/cms/static/sass/_header.scss index d70f53b4df..be207c600f 100644 --- a/cms/static/sass/_header.scss +++ b/cms/static/sass/_header.scss @@ -4,6 +4,11 @@ body.no-header { } } +@mixin active { + @include linear-gradient(top, rgba(0, 0, 0, 0.6), rgba(0, 0, 0, 0.3)); + @include box-shadow(0 2px 8px rgba(0, 0, 0, .7) inset); +} + .primary-header { width: 100%; height: 36px; @@ -13,6 +18,26 @@ body.no-header { color: #fff; @include box-shadow(0 1px 1px rgba(0, 0, 0, 0.2), 0 -1px 0px rgba(255, 255, 255, 0.05) inset); + &.active-tab-courseware #courseware-tab { + @include active; + } + + &.active-tab-assets #assets-tab { + @include active; + } + + &.active-tab-pages #pages-tab { + @include active; + } + + &.active-tab-users #users-tab { + @include active; + } + + &.active-tab-import #import-tab { + @include active; + } + .left { width: 700px; } @@ -48,9 +73,5 @@ body.no-header { background: rgba(255, 255, 255, .1); } - &.active { - @include linear-gradient(top, rgba(0, 0, 0, 0.6), rgba(0, 0, 0, 0.3)); - @include box-shadow(0 2px 8px rgba(0, 0, 0, .7) inset); - } } } \ No newline at end of file diff --git a/cms/templates/base.html b/cms/templates/base.html index f847ad6f7b..f839cb9753 100644 --- a/cms/templates/base.html +++ b/cms/templates/base.html @@ -18,8 +18,7 @@ - - <%include file="widgets/header.html"/> + <%include file="widgets/header.html" args="active_tab=active_tab"/> <%include file="courseware_vendor_js.html"/> diff --git a/cms/templates/manage_users.html b/cms/templates/manage_users.html index e479bc0942..142afc2304 100644 --- a/cms/templates/manage_users.html +++ b/cms/templates/manage_users.html @@ -1,7 +1,6 @@ <%inherit file="base.html" /> <%block name="title">Course Staff Manager <%block name="bodyclass">users -<%include file="widgets/header.html"/> <%block name="content">
diff --git a/cms/templates/overview.html b/cms/templates/overview.html index d31e1e4823..e89d94b9c6 100644 --- a/cms/templates/overview.html +++ b/cms/templates/overview.html @@ -83,7 +83,7 @@
- ${units.enum_units(subsection)} + ${units.enum_units(subsection)} % endfor diff --git a/cms/templates/widgets/header.html b/cms/templates/widgets/header.html index fb436ddde2..b46baebae3 100644 --- a/cms/templates/widgets/header.html +++ b/cms/templates/widgets/header.html @@ -1,16 +1,21 @@ <%! from django.core.urlresolvers import reverse %> -
+<% active_tab_class = 'active-tab-' + active_tab if active_tab else '' %> +