def call_service_async(instance_pk): # load the parsed instance from onadata.apps.logger.models.instance import Instance try: instance = Instance.objects.get(pk=instance_pk) except Instance.DoesNotExist: # if the instance has already been removed we do not send it to the # service pass else: call_service(instance)
def save(self, asynchronous=False, *args, **kwargs): # start/end_time obsolete: originally used to approximate for # instanceID, before instanceIDs were implemented created = self.pk is None self.start_time = None self.end_time = None self._set_geopoint() super(ParsedInstance, self).save(*args, **kwargs) # insert into Mongo. # Signal has been removed because of a race condition. # Rest Services were called before data was saved in DB. success = self.update_mongo(asynchronous) if success and created: call_service(self) return success
def rest_service_form_submission(sender, **kwargs): parsed_instance = kwargs.get('instance') created = kwargs.get('created') if created: call_service(parsed_instance)
def save(self, async=False, *args, **kwargs): # start/end_time obsolete: originally used to approximate for # instanceID, before instanceIDs were implemented created = self.pk is None self.start_time = None self.end_time = None self._set_geopoint() super(ParsedInstance, self).save(*args, **kwargs) # insert into Mongo. # Signal has been removed because of a race condition. # Rest Services were called before data was saved in DB. success = self.update_mongo(async) if success and created: call_service(self) return success def add_note(self, note): note = Note(instance=self.instance, note=note) note.save() def remove_note(self, pk): note = self.instance.notes.get(pk=pk) note.delete() def get_notes(self): notes = [] note_qs = self.instance.notes.values('id', 'note', 'date_created', 'date_modified') for note in note_qs:
def save(self, async=False, *args, **kwargs): # start/end_time obsolete: originally used to approximate for # instanceID, before instanceIDs were implemented created = self.pk is None self.start_time = None self.end_time = None self._set_geopoint() super(ParsedInstance, self).save(*args, **kwargs) # insert into Mongo. # Signal has been removed because of a race condition. # Rest Services were called before data was saved in DB. success = self.update_mongo(async) if success and created: call_service(self) return success def add_note(self, note): note = Note(instance=self.instance, note=note) note.save() def remove_note(self, pk): note = self.instance.notes.get(pk=pk) note.delete() def get_notes(self): notes = [] note_qs = self.instance.notes.values( 'id', 'note', 'date_created', 'date_modified') for note in note_qs:
def call_service_async(instance_pk): # load the parsed instance from onadata.apps.viewer.models.parsed_instance import ParsedInstance instance = ParsedInstance.objects.get(pk=instance_pk) call_service(instance)