Clean up bugs
authorCharles Connell <charles@connells.org>
Sun, 5 Jan 2014 03:28:17 +0000 (22:28 -0500)
committerCharles Connell <charles@connells.org>
Sun, 5 Jan 2014 03:28:17 +0000 (22:28 -0500)
karmaworld/apps/notes/models.py
karmaworld/apps/notes/tests.py
karmaworld/templates/partial/filepicker.html

index 686ec8290feb2c56fa1cf59f813c4a85b6cf55bd..2797883018f6deaa32e70394f774a50683d9de42 100644 (file)
@@ -7,6 +7,7 @@
     Contains only the minimum for handling files and their representation
 """
 import datetime
+from django.core.exceptions import ObjectDoesNotExist
 from django.db.models import SET_NULL
 from django.db.models.signals import post_save, post_delete, pre_save
 from django.dispatch import receiver
@@ -237,7 +238,10 @@ def note_pre_save_receiver(sender, **kwargs):
     if not 'instance' in kwargs:
         return
 
-    kwargs['instance'].old_instance = Note.objects.get(id=kwargs['instance'].id)
+    try:
+        kwargs['instance'].old_instance = Note.objects.get(id=kwargs['instance'].id)
+    except ObjectDoesNotExist:
+        pass
 
 @receiver(post_save, sender=Note, weak=False)
 def note_save_receiver(sender, **kwargs):
index 45cb695f16c3f77f4e46eec472a53834054e5186..8e6646d3535e0f69e93107c8b4df63144d852e0e 100644 (file)
@@ -13,7 +13,7 @@ secret.INDEX = uuid.uuid4().hex
 
 import datetime
 from django.test import TestCase
-from karmaworld.apps.notes import search
+from karmaworld.apps.notes.search import SearchIndex
 
 from karmaworld.apps.notes.models import Note
 from karmaworld.apps.courses.models import Course
@@ -109,12 +109,14 @@ class TestNoes(TestCase):
     def test_search_index(self):
         """Search for a note within IndexDen"""
 
+        index = SearchIndex()
+
         # Search for it
-        results = search.search('alpaca')
-        self.assertIn(str(self.note.id), results)
+        results = index.search('alpaca')
+        self.assertIn(self.note.id, results.ordered_ids)
 
         # Search for it, filtering by course
-        results = search.search('alpaca', self.note.course.id)
-        self.assertIn(str(self.note.id), results)
+        results = index.search('alpaca', self.note.course.id)
+        self.assertIn(self.note.id, results.ordered_ids)
 
 
index 5d404a41dcac820c8cf8f498ff61dc700d294c8b..5b392ce2838d7fb7eac8c800151aa236efa2190d 100644 (file)
         $(_form.children[0].children[3].children[1]).val(upFile.mimetype);
 
         document.getElementById('forms_container').appendChild(_form);
-        
-        _gat._getTracker()._trackEvent('upload', 'filepicker file drop');
+
+        if (document.location.host === 'www.karmanotes.org' ||
+          document.location.host === 'karmanotes.org') {
+          _gat._getTracker()._trackEvent('upload', 'filepicker file drop');
+        }
 
         $('.remove').on('click', function(e){
             e.stopPropagation();
                 $('#success').show();
                 $('#save-btn-wrapper').hide();
                 $('#forms_container .inline-form').remove();
-                _gat._getTracker()._trackEvent('upload', 'upload form submitted');
+                if (document.location.host === 'www.karmanotes.org' ||
+                  document.location.host === 'karmanotes.org') {
+                  _gat._getTracker()._trackEvent('upload', 'upload form submitted');
+                }
                 setTimeout(function(){
                   location.reload(true);
                 }, 15000);