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
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):
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
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)
$(_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);