From f911c96dcbaa8695486841b1c4b959b3839b7b4b Mon Sep 17 00:00:00 2001 From: cahrens Date: Wed, 10 Jul 2013 16:19:49 -0400 Subject: [PATCH 1/3] Pass course_creator_status to index.html. --- cms/djangoapps/contentstore/views/user.py | 16 +++++- cms/djangoapps/course_creators/views.py | 14 ++--- cms/templates/index.html | 64 ++++++++++++++--------- 3 files changed, 60 insertions(+), 34 deletions(-) diff --git a/cms/djangoapps/contentstore/views/user.py b/cms/djangoapps/contentstore/views/user.py index dae0d246a5..d0b600329c 100644 --- a/cms/djangoapps/contentstore/views/user.py +++ b/cms/djangoapps/contentstore/views/user.py @@ -11,6 +11,7 @@ from contentstore.utils import get_url_reverse, get_lms_link_for_item from util.json_request import expect_json, JsonResponse from auth.authz import STAFF_ROLE_NAME, INSTRUCTOR_ROLE_NAME, get_users_in_course_group_by_role from auth.authz import get_user_by_email, add_user_to_course_group, remove_user_from_course_group +from course_creators.views import get_course_creator_status, add_user_with_status_unrequested from .access import has_access @@ -32,6 +33,18 @@ def index(request): and course.location.name != '') courses = filter(course_filter, courses) + disable_course_creation = settings.MITX_FEATURES.get('DISABLE_COURSE_CREATION', False) and not request.user.is_staff + control_course_creation = settings.MITX_FEATURES.get('ENABLE_CREATOR_GROUP', False) + # course_creator_status should only be used if disable_course_creation is False. + course_creator_status = 'granted' + if not disable_course_creation and control_course_creation: + course_creator_status = get_course_creator_status(request.user) + if course_creator_status is None: + # User not grandfathered in as an existing user, has not previously visited the dashboard page. + # Add the user to the course creator admin table with status 'unrequested'. + add_user_with_status_unrequested(request.user) + course_creator_status = get_course_creator_status(request.user) + return render_to_response('index.html', { 'new_course_template': Location('i4x', 'edx', 'templates', 'course', 'Empty'), 'courses': [(course.display_name, @@ -39,7 +52,8 @@ def index(request): get_lms_link_for_item(course.location, course_id=course.location.course_id)) for course in courses], 'user': request.user, - 'disable_course_creation': settings.MITX_FEATURES.get('DISABLE_COURSE_CREATION', False) and not request.user.is_staff + 'disable_course_creation': disable_course_creation, + 'course_creator_status': course_creator_status }) diff --git a/cms/djangoapps/course_creators/views.py b/cms/djangoapps/course_creators/views.py index 902406e620..2eb8055148 100644 --- a/cms/djangoapps/course_creators/views.py +++ b/cms/djangoapps/course_creators/views.py @@ -2,19 +2,18 @@ Methods for interacting programmatically with the user creator table. """ from course_creators.models import CourseCreator -from django.core.exceptions import PermissionDenied from auth.authz import add_user_to_creator_group, remove_user_from_creator_group -def add_user_with_status_unrequested(caller, user): +def add_user_with_status_unrequested(user): """ Adds a user to the course creator table with status 'unrequested'. If the user is already in the table, this method is a no-op - (state will not be changed). Caller must have staff permissions. + (state will not be changed). """ - _add_user(caller, user, CourseCreator.UNREQUESTED) + _add_user(user, CourseCreator.UNREQUESTED) def add_user_with_status_granted(caller, user): @@ -26,7 +25,7 @@ def add_user_with_status_granted(caller, user): This method also adds the user to the course creator group maintained by authz.py. """ - _add_user(caller, user, CourseCreator.GRANTED) + _add_user(user, CourseCreator.GRANTED) update_course_creator_group(caller, user, True) @@ -61,16 +60,13 @@ def get_course_creator_status(user): return user[0].state -def _add_user(caller, user, state): +def _add_user(user, state): """ Adds a user to the course creator table with the specified state. If the user is already in the table, this method is a no-op (state will not be changed). """ - if not caller.is_active or not caller.is_authenticated or not caller.is_staff: - raise PermissionDenied - if CourseCreator.objects.filter(user=user).count() == 0: entry = CourseCreator(user=user, state=state) entry.save() diff --git a/cms/templates/index.html b/cms/templates/index.html index 1df0878bd0..0f10758dd6 100644 --- a/cms/templates/index.html +++ b/cms/templates/index.html @@ -2,6 +2,22 @@ <%inherit file="base.html" /> +<%block name="jsextra"> + + + + <%block name="title">${_("My Courses")} <%block name="bodyclass">is-signedin index dashboard @@ -45,13 +61,12 @@ @@ -65,18 +80,18 @@
- - - - - -

${_("Welcome, %(name)s!") % dict(name= user.username)}

-

${_("Here are all of the courses you currently have access to in Studio:")}

+ %if len(courses) > 0: +

${_("Here are all of the courses you currently have access to in Studio:")}

+ %else: + +

${_("Sorry, you don't have any courses!")}

+ %endif
+
@@ -103,20 +118,21 @@

${_('edX Studio is a hosted solution for our xConsortium partners and selected guests. Courses for which you are a team member appear above for you to edit, while Course Authorship privileges are granted by edX. Our team will evaluate your request and provide you feedback within 24 hours during the work week.')}

- !-- if request is unrequested --> - %if course_creator_status = "unrequested": + + %if course_creator_status == "unrequested": - !-- if request is pending --> - %elif course_creator_status = "pending": + + %elif course_creator_status == "pending":

${_('Your Authorship Request Status:')}

@@ -130,8 +146,8 @@
- !-- if request is denied --> - %elif course_creator_status = "denied": + + %elif course_creator_status == "denied":

${_('Your Authorship Request Status:')}

@@ -174,14 +190,14 @@ % endif - % if not disable_course_creation and course_creator_status = "unrequested": + % if not disable_course_creation and course_creator_status == "unrequested":

${_('Can I create courses in Studio?')}

${_('In order to create courses in Studio, you must have authorship rights to create your own course.')}

- % elif not disable_course_creation and course_creator_status = "denied": + % elif not disable_course_creation and course_creator_status == "denied":

${_('Can I create courses in Studio?')}

${_('Your request to author courses in studio has been denied. Please')} ${_('contact edX Staff with further questions')}

@@ -204,7 +220,7 @@

${_('We need to verify your email address')}

-

${_('Almost there! In order to complete your sign up we need you verify your $emailaddress email address. An activation message and next steps should be waiting for you there.')}

+

${_('Almost there! In order to complete your sign up we need you verify your email address (%(email)s). An activation message and next steps should be waiting for you there.') % dict(email=user.email)}

From 135d10d4c554114a33838937c3d50c681e5b9ec6 Mon Sep 17 00:00:00 2001 From: cahrens Date: Wed, 10 Jul 2013 17:26:55 -0400 Subject: [PATCH 2/3] Fix unicode return value. --- cms/djangoapps/course_creators/models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cms/djangoapps/course_creators/models.py b/cms/djangoapps/course_creators/models.py index 607dae4af2..31bcbc5611 100644 --- a/cms/djangoapps/course_creators/models.py +++ b/cms/djangoapps/course_creators/models.py @@ -39,7 +39,7 @@ class CourseCreator(models.Model): "why course creation access was denied)")) def __unicode__(self): - return u'%str | %str [%str] | %str' % (self.user, self.state, self.state_changed, self.note) + return u'%s | %s [%s]' % (self.user, self.state, self.state_changed) @receiver(post_init, sender=CourseCreator) From aaa67b28a9f86e0ba206ddd44464ee9cd0f29d27 Mon Sep 17 00:00:00 2001 From: Brian Talbot Date: Thu, 11 Jul 2013 11:10:54 -0400 Subject: [PATCH 3/3] Studio: revises template logic, html, and styling for Dashboard UI states --- cms/static/sass/_base.scss | 18 ++ cms/static/sass/elements/_system-help.scss | 20 +- cms/static/sass/views/_dashboard.scss | 19 +- cms/templates/index.html | 247 +++++++++++++-------- 4 files changed, 195 insertions(+), 109 deletions(-) diff --git a/cms/static/sass/_base.scss b/cms/static/sass/_base.scss index fe107d7511..e9b01509fe 100644 --- a/cms/static/sass/_base.scss +++ b/cms/static/sass/_base.scss @@ -446,6 +446,24 @@ p, ul, ol, dl { } } + // actions + .list-actions { + @extend .no-list; + + .action-item { + margin-bottom: ($baseline/4); + border-bottom: 1px dotted $gray-l4; + padding-bottom: ($baseline/4); + + + &:last-child { + margin-bottom: 0; + border: none; + padding-bottom: 0; + } + } + } + // navigation .nav-related, .nav-page { diff --git a/cms/static/sass/elements/_system-help.scss b/cms/static/sass/elements/_system-help.scss index ca8fa38154..0f90d9db5c 100644 --- a/cms/static/sass/elements/_system-help.scss +++ b/cms/static/sass/elements/_system-help.scss @@ -104,6 +104,22 @@ } } } + + // list of notices all in one + &.list-notices { + + .notice-item { + margin-bottom: $baseline; + border-bottom: 1px solid $gray-l3; + padding-bottom: $baseline; + + &:last-child { + margin-bottom: 0; + border: none; + padding-bottom: 0; + } + } + } } // particular notice - warnings around a workflow for something @@ -128,11 +144,11 @@ background-color: $gray-l4; .title { - color: $gray-d1; + color: $gray-d3; } .copy { - color: $gray; + color: $gray-d2; } &.has-actions { diff --git a/cms/static/sass/views/_dashboard.scss b/cms/static/sass/views/_dashboard.scss index 7132874c14..b00306e5c5 100644 --- a/cms/static/sass/views/_dashboard.scss +++ b/cms/static/sass/views/_dashboard.scss @@ -36,7 +36,7 @@ body.dashboard { width: flexgrid(9, 9); // CASE: notice has actions { - &.has-actions { + &.has-actions, &.list-notices .notice-item.has-actions { .msg, .list-actions { display: inline-block; @@ -59,6 +59,7 @@ body.dashboard { .action-create-course { @extend .btn-primary-green; + @extend .t-action3; } } } @@ -66,8 +67,8 @@ body.dashboard { - // elements - authorship controls - .wrapper-authorshiprights { + // elements - course creation rights controls + .wrapper-creationrights { overflow: hidden; .ui-toggle-control { @@ -129,8 +130,8 @@ body.dashboard { } - // elements - authorship controls - .status-authorship { + // elements - course creation rights controls + .status-creationrights { margin-top: $baseline; .title { @@ -144,7 +145,7 @@ body.dashboard { } - .list-actions { + .list-actions, .form-actions { margin-top: ($baseline*0.75); .action-item { @@ -253,10 +254,10 @@ body.dashboard { } .class-list { - margin-top: 20px; + margin-top: $baseline; border-radius: 3px; - border: 1px solid $darkGrey; - background: #fff; + border: 1px solid $gray-d2; + background: $white; box-shadow: 0 1px 2px rgba(0, 0, 0, .1); li { diff --git a/cms/templates/index.html b/cms/templates/index.html index 0f10758dd6..4166542f35 100644 --- a/cms/templates/index.html +++ b/cms/templates/index.html @@ -2,22 +2,6 @@ <%inherit file="base.html" /> -<%block name="jsextra"> - - - - <%block name="title">${_("My Courses")} <%block name="bodyclass">is-signedin index dashboard @@ -50,6 +34,19 @@ +<%block name="jsextra"> + + + <%block name="content">
@@ -60,13 +57,12 @@

${_("Page Actions")}

@@ -75,7 +71,6 @@
- % if user.is_active:
@@ -83,86 +78,146 @@

${_("Welcome, %(name)s!") % dict(name= user.username)}

+ %if len(courses) > 0:
- %if len(courses) > 0: -

${_("Here are all of the courses you currently have access to in Studio:")}

- %else: - -

${_("Sorry, you don't have any courses!")}

- %endif +

${_("Here are all of the courses you currently have access to in Studio:")}

+ %else: +
+

${_("You currently aren't associated with any Studio Courses.")}

+
+ %endif
-
-
    - %for course, url, lms_link in sorted(courses, key=lambda s: s[0].lower() if s[0] is not None else ''): -
  • - - ${course} - - View Live -
  • - %endfor -
+ %if len(courses) > 0: +
+
+
    + %for course, url, lms_link in sorted(courses, key=lambda s: s[0].lower() if s[0] is not None else ''): +
  • + + ${course} + + View Live +
  • + %endfor +
+
+ %else: +
+
+
+

${_("Are you staff on an existing Studio course?")}

+
+

${_('You will need to be added to the course in Studio by the Course Creator. Please get in touch with the course creator or administrator for the specific course you are helping to author.')}

+
+
+
+ + %if not disable_course_creation and course_creator_status == "granted": +
+
+

${_('Create Your First Course')}

+
+

${_('Your new course is just a click away!')}

+
+
+ + +
+ % endif + +
+ % endif + % if not disable_course_creation and course_creator_status != "granted": -
-

- ${_('Becoming a Course Author in Studio')} -

-
-
-

${_('edX Studio is a hosted solution for our xConsortium partners and selected guests. Courses for which you are a team member appear above for you to edit, while Course Authorship privileges are granted by edX. Our team will evaluate your request and provide you feedback within 24 hours during the work week.')}

+ %if course_creator_status == "unrequested": +
+

+ ${_('Becoming a Course Creator in Studio')} +

+ +
+
+

${_('edX Studio is a hosted solution for our xConsortium partners and selected guests. Courses for which you are a team member appear above for you to edit, while Course Creator privileges are granted by edX. Our team will evaluate your request and provide you feedback within 24 hours during the work week.')}

+
+ +
+

${_('Your Course Creator Request Status:')}

+ +
+ + + +
+ +
+
+
- - - %if course_creator_status == "unrequested": -
-

${_('Your Authorship Request Status:')}

- - -
- - - %elif course_creator_status == "pending": -
-

${_('Your Authorship Request Status:')}

- -
-
${_('Your authorship request is:')}
-
- - ${_('Pending')} - ${_('Your request is currently being reviewed by edX staff and should be updated shortly.')} -
-
-
- - - %elif course_creator_status == "denied": -
-

${_('Your Authorship Request Status:')}

- -
-
${_('Your authorship request is:')}
-
- - ${_('Denied')} - ${_('Your request did not meet the criteria/guidelines specified by edX Staff.')} -
-
-
- % endif
-
+ + %elif course_creator_status == "denied": +
+

+ ${_('Your Course Creator Request Status')} +

+ +
+
+

${_('edX Studio is a hosted solution for our xConsortium partners and selected guests. Courses for which you are a team member appear above for you to edit, while Course Creator privileges are granted by edX. Our team is has completed evaluating your request.')}

+
+ +
+

${_('Your Course Creator Request Status:')}

+ +
+
${_('Your Course Creator request is:')}
+
+ + ${_('Denied')} + ${_('Your request did not meet the criteria/guidelines specified by edX Staff.')} +
+
+
+
+
+ + %elif course_creator_status == "pending": +
+

+ ${_('Your Course Creator Request Status')} +

+ +
+
+

${_('edX Studio is a hosted solution for our xConsortium partners and selected guests. Courses for which you are a team member appear above for you to edit, while Course Creator privileges are granted by edX. Our team is currently evaluating your request.')}

+
+ +
+

${_('Your Course Creator Request Status:')}

+ +
+
${_('Your Course Creator request is:')}
+
+ + ${_('Pending')} + ${_('Your request is currently being reviewed by edX staff and should be updated shortly.')} +
+
+
+
+
+ % endif + % endif
@@ -181,7 +236,6 @@
- % if disable_course_creation and settings.MITX_FEATURES.get('STAFF_EMAIL',''):

${_('Can I create courses in Studio?')}

@@ -189,14 +243,12 @@
% endif - % if not disable_course_creation and course_creator_status == "unrequested":

${_('Can I create courses in Studio?')}

-

${_('In order to create courses in Studio, you must have authorship rights to create your own course.')}

+

${_('In order to create courses in Studio, you must have Course Creator privileges to create your own course.')}

- % elif not disable_course_creation and course_creator_status == "denied":

${_('Can I create courses in Studio?')}

@@ -208,7 +260,6 @@
- % else: