From: Charles Connell Date: Sun, 5 Jan 2014 03:28:17 +0000 (-0500) Subject: Clean up bugs X-Git-Tag: release-20150131~306 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=031e7e7d9d6f87f12a442527e70ac3031f24e2a9;p=oweals%2Fkarmaworld.git Clean up bugs --- diff --git a/karmaworld/apps/notes/models.py b/karmaworld/apps/notes/models.py index 686ec82..2797883 100644 --- a/karmaworld/apps/notes/models.py +++ b/karmaworld/apps/notes/models.py @@ -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): diff --git a/karmaworld/apps/notes/tests.py b/karmaworld/apps/notes/tests.py index 45cb695..8e6646d 100644 --- a/karmaworld/apps/notes/tests.py +++ b/karmaworld/apps/notes/tests.py @@ -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) diff --git a/karmaworld/templates/partial/filepicker.html b/karmaworld/templates/partial/filepicker.html index 5d404a4..5b392ce 100644 --- a/karmaworld/templates/partial/filepicker.html +++ b/karmaworld/templates/partial/filepicker.html @@ -109,8 +109,11 @@ $(_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(); @@ -154,7 +157,10 @@ $('#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);