From 85de85a74392aa016a797fe77add9457ed43823f Mon Sep 17 00:00:00 2001 From: Seth Woodworth Date: Thu, 21 Mar 2013 15:02:52 -0400 Subject: [PATCH] fix add-note form action and server handling for save --- karmaworld/apps/notes/views.py | 4 +++- karmaworld/assets/js/lightboxupload.js | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/karmaworld/apps/notes/views.py b/karmaworld/apps/notes/views.py index 9a78b70..0f9e37e 100644 --- a/karmaworld/apps/notes/views.py +++ b/karmaworld/apps/notes/views.py @@ -33,6 +33,7 @@ class NoteSaveView(FormView, SingleObjectMixin): context = { 'object': self.get_object(), } + print "get context for NoteSaveView" return super(NoteSaveView, self).get_context_data(**context) def get_success_url(self): @@ -51,7 +52,7 @@ class NoteSaveView(FormView, SingleObjectMixin): """ self.object = self.get_object() self.object.name = form.cleaned_data['name'] - self.object.desc = form.cleaned_data['desc'] + self.object.year = form.cleaned_data['year'] # use *arg expansion to pass tags a list of tags self.object.tags.add(*form.cleaned_data['tags']) self.object.save() @@ -59,6 +60,7 @@ class NoteSaveView(FormView, SingleObjectMixin): def form_invalid(self, form): """ Do stuff when the form is invalid !!! TODO """ + print "running form_invalid" print self.form print self.form.errors diff --git a/karmaworld/assets/js/lightboxupload.js b/karmaworld/assets/js/lightboxupload.js index 582d30c..a38dd9b 100644 --- a/karmaworld/assets/js/lightboxupload.js +++ b/karmaworld/assets/js/lightboxupload.js @@ -29,11 +29,13 @@ $(function(){ onComplete: function( id, fileName, responseJSON ) { if( responseJSON.success ) { // activate the form for submitting - $('form#upload_form').attr('action', responseJSON.note_url); + $('form#add-note').attr('action', responseJSON.note_url); // inform the user of success $('#add-note-status').text('Uploaded'); // TODO: activate the save button $('#save-btn').removeClass('disabled'); + // add the save url to form as ACTION + // add a click handler to submit the add-note form $('#save-btn').click(function(){ $('form#add-note').submit(); -- 2.25.1