コード例 #1
0
ファイル: models.py プロジェクト: knittingarch/commcare-hq
    def save(self, *args, **kwargs):
        from corehq.apps.commtrack.models import sync_supply_point
        from .document_store import publish_location_saved

        if not self.location_id:
            self.location_id = uuid.uuid4().hex
        set_site_code_if_needed(self)
        sync_supply_point(self)
        super(SQLLocation, self).save(*args, **kwargs)
        publish_location_saved(self.domain, self.location_id)
コード例 #2
0
ファイル: models.py プロジェクト: knittingarch/commcare-hq
    def delete(self, *args, **kwargs):
        from corehq.apps.commtrack.models import sync_supply_point
        from .document_store import publish_location_saved
        to_delete = self.get_descendants(include_self=True)

        for loc in to_delete:
            loc._remove_users()
            sync_supply_point(loc, is_deletion=True)

        super(SQLLocation, self).delete(*args, **kwargs)
        publish_location_saved(self.domain, self.location_id, is_deletion=True)
コード例 #3
0
ファイル: models.py プロジェクト: kkrampa/commcare-hq
    def save(self, *args, **kwargs):
        from corehq.apps.commtrack.models import sync_supply_point
        from .document_store import publish_location_saved

        if not self.location_id:
            self.location_id = uuid.uuid4().hex

        with transaction.atomic():
            set_site_code_if_needed(self)
            sync_supply_point(self)
            super(SQLLocation, self).save(*args, **kwargs)

        publish_location_saved(self.domain, self.location_id)
コード例 #4
0
ファイル: models.py プロジェクト: esmaeilinia/commcare-hq
    def delete(self, *args, **kwargs):
        from corehq.apps.commtrack.models import sync_supply_point
        from .document_store import publish_location_saved
        to_delete = self.get_descendants(include_self=True)

        # This deletion should ideally happen in a transaction. It's not
        # currently possible as supply point cases are stored either in a
        # separate database or in couch. Happy Debugging!
        for loc in to_delete:
            loc._remove_users()
            sync_supply_point(loc, is_deletion=True)

        super(SQLLocation, self).delete(*args, **kwargs)
        publish_location_saved(self.domain, self.location_id, is_deletion=True)
コード例 #5
0
ファイル: models.py プロジェクト: kkrampa/commcare-hq
    def save(self, *args, **kwargs):
        from corehq.apps.commtrack.models import sync_supply_point
        from .document_store import publish_location_saved

        if not self.location_id:
            self.location_id = uuid.uuid4().hex
            if six.PY2:
                self.location_id = self.location_id.decode('utf-8')

        with transaction.atomic():
            set_site_code_if_needed(self)
            sync_supply_point(self)
            super(SQLLocation, self).save(*args, **kwargs)

        publish_location_saved(self.domain, self.location_id)
コード例 #6
0
ファイル: models.py プロジェクト: saketkanth/commcare-hq
    def save(self, *args, **kwargs):
        from corehq.apps.commtrack.models import sync_supply_point
        self.supply_point_id = sync_supply_point(self)

        sync_to_couch = kwargs.pop('sync_to_couch', True)
        kwargs['sync_to_couch'] = False  # call it here
        super(SQLLocation, self).save(*args, **kwargs)
        if sync_to_couch:
            self._migration_do_sync()
コード例 #7
0
    def save(self, *args, **kwargs):
        from corehq.apps.commtrack.models import sync_supply_point
        self.supply_point_id = sync_supply_point(self)

        sync_to_couch = kwargs.pop('sync_to_couch', True)
        kwargs['sync_to_couch'] = False  # call it here
        super(SQLLocation, self).save(*args, **kwargs)
        if sync_to_couch:
            self._migration_do_sync()
コード例 #8
0
    def save(self, *args, **kwargs):
        from corehq.apps.commtrack.models import sync_supply_point
        from .document_store import publish_location_saved
        self.supply_point_id = sync_supply_point(self)

        sync_to_couch = kwargs.pop('sync_to_couch', True)
        kwargs['sync_to_couch'] = False  # call it here
        super(SQLLocation, self).save(*args, **kwargs)
        if sync_to_couch:
            self._migration_do_sync()

        publish_location_saved(self.domain, self.location_id)
コード例 #9
0
    def save(self, *args, **kwargs):
        from corehq.apps.commtrack.models import sync_supply_point
        from .document_store import publish_location_saved
        self.supply_point_id = sync_supply_point(self)

        sync_to_couch = kwargs.pop('sync_to_couch', True)
        kwargs['sync_to_couch'] = False  # call it here
        super(SQLLocation, self).save(*args, **kwargs)
        if sync_to_couch:
            self._migration_do_sync()

        publish_location_saved(self.domain, self.location_id)
コード例 #10
0
    def save(self, *args, **kwargs):
        from corehq.apps.commtrack.models import sync_supply_point
        from .document_store import publish_location_saved
        set_site_code_if_needed(self)

        sync_to_couch = kwargs.pop('sync_to_couch', True)

        if sync_to_couch:
            couch_obj = self.sync_couch_location()

        self.supply_point_id = sync_supply_point(self)

        if not self.location_id:
            raise ValueError("Expected non-empty location_id")

        super(SQLLocation, self).save(*args, **kwargs)

        if sync_to_couch:
            couch_obj.save(sync_to_sql=False)

        publish_location_saved(self.domain, self.location_id)
コード例 #11
0
ファイル: tasks.py プロジェクト: xbryanc/commcare-hq
def sync_supply_points(location_type):
    for location in SQLLocation.objects.filter(location_type=location_type):
        sync_supply_point(location)
        location.save()
コード例 #12
0
ファイル: models.py プロジェクト: philipkaare/commcare-hq
 def save(self, *args, **kwargs):
     from corehq.apps.commtrack.models import sync_supply_point
     self.supply_point_id = sync_supply_point(self)
     return super(SQLLocation, self).save(*args, **kwargs)
コード例 #13
0
def sync_supply_points(location_type):
    for location in SQLLocation.objects.filter(location_type=location_type):
        sync_supply_point(location)
        location.save()