From 5f0151a3342f95ed90d0f0e91e6467833a5ad933 Mon Sep 17 00:00:00 2001 From: Charles Connell Date: Sat, 10 May 2014 19:12:43 -0400 Subject: [PATCH] Clean up how we edit notes and courses -- disable course edit for now until we figure out how to make it work --- karmaworld/apps/notes/views.py | 29 +------ karmaworld/assets/css/global.css | 23 ++++++ karmaworld/assets/css/home.css | 21 ----- .../templates/courses/course_detail.html | 58 ++----------- karmaworld/templates/notes/note_base.html | 1 - karmaworld/templates/partial/edit_course.html | 82 +++++++++++++++++++ karmaworld/urls.py | 3 +- 7 files changed, 112 insertions(+), 105 deletions(-) create mode 100644 karmaworld/templates/partial/edit_course.html diff --git a/karmaworld/apps/notes/views.py b/karmaworld/apps/notes/views.py index 6a4ea6e..26849b1 100644 --- a/karmaworld/apps/notes/views.py +++ b/karmaworld/apps/notes/views.py @@ -9,6 +9,7 @@ from django.contrib import messages from django.core import serializers from django.core.exceptions import ValidationError from django.forms.formsets import formset_factory +from karmaworld.apps.courses.forms import CourseForm from karmaworld.apps.courses.models import Course from karmaworld.apps.notes.search import SearchIndex from karmaworld.apps.quizzes.create_quiz import quiz_from_keywords @@ -302,34 +303,6 @@ class NoteSearchView(ListView): return super(NoteSearchView, self).get_context_data(**kwargs) -def handle_edit_note(request): - course = Course.objects.get(pk=pk) - original_name = course.name - course_form = CourseForm(request.POST or None, instance=course) - - if course_form.is_valid(): - course_form.save() - - course_json = serializers.serialize('json', [course,]) - resp = json.loads(course_json)[0] - - if (course.name != original_name): - course.set_slug() - resp['fields']['new_url'] = course.get_absolute_url() - - return HttpResponse(json.dumps(resp), mimetype="application/json") - else: - return HttpResponseBadRequest(json.dumps({'status': 'fail', 'message': 'Validation error', - 'errors': course_form.errors}), - mimetype="application/json") - -def edit_note(request, pk): - """ - Saves the edited note metadata - """ - ajax_base(request, edit_note, ['POST']) - - def process_note_thank_events(request_user, note): # Give points to the person who uploaded this note if note.user != request_user and note.user: diff --git a/karmaworld/assets/css/global.css b/karmaworld/assets/css/global.css index 3d5ba30..613f282 100644 --- a/karmaworld/assets/css/global.css +++ b/karmaworld/assets/css/global.css @@ -355,3 +355,26 @@ button.search-icon { opacity: 0.8; font-size: 0.8em; } + + +#add-course-form p { + margin: 0 0 0 0; +} + +#add-course-form .results_on_deck { + margin-top: -10px; +} + +.required-field { + opacity: 0.5; +} + +ul.validation_error { + margin: 0 0 0 0; + list-style-type: none; +} + +label.validation_error { + color: #F04124; +} + diff --git a/karmaworld/assets/css/home.css b/karmaworld/assets/css/home.css index 3c29050..0801794 100644 --- a/karmaworld/assets/css/home.css +++ b/karmaworld/assets/css/home.css @@ -40,27 +40,6 @@ box-shadow: 1px 1px 3px black; } -#add-course-form p { - margin: 0 0 0 0; -} - -#add-course-form .results_on_deck { - margin-top: -10px; -} - -.required-field { - opacity: 0.5; -} - -ul.validation_error { - margin: 0 0 0 0; - list-style-type: none; -} - -label.validation_error { - color: #F04124; -} - #add-course-btn { width: 100%; font-size: 1.2em; diff --git a/karmaworld/templates/courses/course_detail.html b/karmaworld/templates/courses/course_detail.html index a235aef..1476ad1 100644 --- a/karmaworld/templates/courses/course_detail.html +++ b/karmaworld/templates/courses/course_detail.html @@ -65,9 +65,11 @@ {% if user.is_authenticated %} + {% comment %} {% if user.get_profile.can_edit_items %}    {% endif %} + {% endcomment %} {% if already_flagged %} You have reported this course as inappropriate @@ -95,61 +97,11 @@ + {% comment %} {% if user.get_profile.can_edit_items %} -
- × -
- {% csrf_token %} - -
-
- {{ course_form.non_field_errors }} -
-
- -
-
- -
- -
-
-
- -
-
- - -
-
- -
-
- - -
- -
- - -
-
- -
-
- - -
-
- -
-
- -
-
-
-
+ {% include 'partial/edit_course.html' %} {% endif %} + {% endcomment %}