From 606b11a1c3c755d6fd012ee4ef28c5171075e794 Mon Sep 17 00:00:00 2001 From: Charles Connell Date: Sun, 9 Mar 2014 22:19:09 -0400 Subject: [PATCH] Starting on the course detail page --- karmaworld/apps/courses/views.py | 1 + karmaworld/apps/users/models.py | 11 +- karmaworld/assets/css/note_course_pages.css | 135 ++---------------- karmaworld/assets/js/add-course.js | 2 +- karmaworld/assets/js/course-detail.js | 9 +- karmaworld/assets/js/course.js | 7 + .../templates/courses/course_detail.html | 125 +++++++--------- karmaworld/templates/footer.html | 8 +- 8 files changed, 94 insertions(+), 204 deletions(-) diff --git a/karmaworld/apps/courses/views.py b/karmaworld/apps/courses/views.py index 211471e..d7ecef6 100644 --- a/karmaworld/apps/courses/views.py +++ b/karmaworld/apps/courses/views.py @@ -208,6 +208,7 @@ def flag_course(request, pk): """Record that somebody has flagged a note.""" return ajax_increment(Course, request, pk, FLAG_FIELD, USER_PROFILE_FLAGS_FIELD, process_course_flag_events) + def edit_course(request, pk): """ Saves the edited course content diff --git a/karmaworld/apps/users/models.py b/karmaworld/apps/users/models.py index f4a329d..7816b61 100644 --- a/karmaworld/apps/users/models.py +++ b/karmaworld/apps/users/models.py @@ -23,9 +23,9 @@ class UserProfileManager(models.Manager): class UserProfile(models.Model): user = models.OneToOneField(User) - thanked_notes = models.ManyToManyField('notes.Note', related_name='users_thanked') - flagged_notes = models.ManyToManyField('notes.Note', related_name='users_flagged') - flagged_courses = models.ManyToManyField('courses.Course', related_name='users_flagged') + thanked_notes = models.ManyToManyField('notes.Note', related_name='users_thanked', blank=True, null=True) + flagged_notes = models.ManyToManyField('notes.Note', related_name='users_flagged', blank=True, null=True) + flagged_courses = models.ManyToManyField('courses.Course', related_name='users_flagged', blank=True, null=True) school = models.ForeignKey(School, blank=True, null=True) def natural_key(self): @@ -41,7 +41,10 @@ class UserProfile(models.Model): return sum def can_edit_items(self): - return (self.get_points() >= 20) + if self.user.is_staff: + return True + else: + return (self.get_points() >= 20) NO_BADGE = 0 PROSPECT = 1 diff --git a/karmaworld/assets/css/note_course_pages.css b/karmaworld/assets/css/note_course_pages.css index c23bedd..8245fdc 100644 --- a/karmaworld/assets/css/note_course_pages.css +++ b/karmaworld/assets/css/note_course_pages.css @@ -1,135 +1,22 @@ -/* NOTE PAGE */ -#note_header +span.course-header-school { - padding-bottom: 20px; - margin-bottom: 20px; + font-weight: bold; } -#note_back_to_course img +#course-header-name { - margin-bottom: -1px; - margin-right: 3px; + font-size: 1.8em; } -#note_status, #note_pedigree, #note_tags +#course-header { - text-align: center; - padding-top: 10px; - padding-bottom: 10px; + line-height: 2em; + margin: 20px 0 0 0; } -#note_author +#end-header { - font-family: "MuseoSans-900"; - font-size: 10px; - text-align: center; - text-transform: uppercase; -} - -#note_author a, #note_author a:hover -{ - text-decoration: underline; - color: #555555; - font-family: "MuseoSlab-900"; - font-size: 11px; -} - -#note_actions -{ - padding-top: 22px; - padding-bottom: 17px; -} - -#note_actions .column -{ - text-align: center; -} - -#note_container -{ - padding-bottom: 45px; -} - -#note-buttons { - padding-bottom: 10px; -} - -#zoom-buttons { - margin-bottom: 20px; -} - -.zoom-button { - cursor: pointer; - margin-right: 10px; -} - -#thank-button-disabled, -#flag-button-disabled -{ - cursor: default; -} - -/* COURSES */ - -#course_meta, #school_meta, #course_link -{ - text-align: center; -} - -#course_actions, #school_actions -{ - padding-top: 15px; - padding-bottom: 17px; -} - -#course_meta_action_gear, #school_meta_action_gear -{ - text-align: center; -} - -.course_meta_action, .school_meta_action -{ - margin: 1px auto 0; -} - -#course_description -{ - text-align: center; - font-family: "MuseoSlab-500"; - font-size: 12px; - line-height: 150%; - padding-bottom: 15px; -} - -#course_container, #school_container -{ - padding-top: 45px; -} - -#course_header -{ - padding-bottom: 20px; - margin-bottom: 20px; -} - -.tag-span:after -{ - content: ', '; -} - -.tag-span:last-child:after -{ - content: ''; -} - -#note_tags_form -{ - text-align: center; -} - -#note_tags_input -{ - margin-left: 25%; - width: 50%; -} + margin-top: 20px; + border-bottom: 1px solid black; +} \ No newline at end of file diff --git a/karmaworld/assets/js/add-course.js b/karmaworld/assets/js/add-course.js index 7be82b0..25a4f3f 100644 --- a/karmaworld/assets/js/add-course.js +++ b/karmaworld/assets/js/add-course.js @@ -34,7 +34,7 @@ $(function() { autoOpen: false, modal: true, show: { effect: 'fade', duration: 500 }, - width: 700 + width: dialogWidth }); if (jump_to_form) { diff --git a/karmaworld/assets/js/course-detail.js b/karmaworld/assets/js/course-detail.js index d50fb2a..d119eb2 100644 --- a/karmaworld/assets/js/course-detail.js +++ b/karmaworld/assets/js/course-detail.js @@ -20,8 +20,15 @@ $(function() { } }); + $('#edit-course-form').dialog({ + autoOpen: false, + modal: true, + show: { effect: 'fade', duration: 500 }, + width: dialogWidth + }); + $('#edit-button').click(function(event) { - $('#edit-course-form').slideToggle(); + $('#edit-course-form').dialog("open"); }); $('#edit-save-btn').click(function(event) { diff --git a/karmaworld/assets/js/course.js b/karmaworld/assets/js/course.js index b0ddc76..26c4338 100644 --- a/karmaworld/assets/js/course.js +++ b/karmaworld/assets/js/course.js @@ -56,3 +56,10 @@ window.KARMAWORLD.Course = { $("#id_instructor_name").autocomplete(opts); } }; + +var bodyWidth = $('body').width(); +if (bodyWidth < 700) { + var dialogWidth = bodyWidth; +} else { + var dialogWidth = 700; +} \ No newline at end of file diff --git a/karmaworld/templates/courses/course_detail.html b/karmaworld/templates/courses/course_detail.html index abb9787..7fd63d3 100644 --- a/karmaworld/templates/courses/course_detail.html +++ b/karmaworld/templates/courses/course_detail.html @@ -7,7 +7,6 @@ -