示例#1
0
    def purge(self):
        """Purges user from site reverting any changes that they have made.

        The following steps are taken:
        - Delete units created by user and without other submissions.
        - Revert units edited by user.
        - Revert reviews made by user.
        - Revert unit comments by user.
        - Revert unit state changes by user.
        - Delete any remaining submissions and suggestions.
        - Expire caches for relevant directories
        """

        stores = set()
        with keep_data():
            stores |= self.remove_units_created()
            stores |= self.revert_units_edited()
            stores |= self.revert_units_reviewed()
            stores |= self.revert_units_commented()
            stores |= self.revert_units_state_changed()

            # Delete remaining submissions.
            logger.debug("Deleting remaining submissions for: %s", self.user)
            self.user.submission_set.all().delete()

            # Delete remaining suggestions.
            logger.debug("Deleting remaining suggestions for: %s", self.user)
            self.user.suggestions.all().delete()
        for store in stores:
            update_data.send(store.__class__, instance=store)
        update_revisions.send(Directory,
                              object_list=Directory.objects.filter(id__in=set(
                                  store.parent.id for store in stores)))
示例#2
0
def handle_directory_save(**kwargs):
    update_revisions.send(
        Directory,
        instance=(
            kwargs["instance"].parent
            if kwargs.get("created")
            else kwargs["instance"]),
        keys=["stats", "checks"])
示例#3
0
 def update_tps_and_revisions(self, stores):
     tps = {}
     for store in stores:
         if store.translation_project_id not in tps:
             tps[store.translation_project_id] = store.translation_project
         update_revisions.send(store.__class__,
                               instance=store,
                               keys=["stats", "checks"])
     for tp in tps.values():
         update_data.send(tp.__class__, instance=tp)
示例#4
0
def _callback_handler(sender, updated, **kwargs):

    bulk_xtle = bulk_operations(
        models=(
            UserStoreScore,
            TPData,
            TPChecksData,
            StoreData,
            StoreChecksData))

    with keep_data(signals=(update_revisions, )):
        with bulk_xtle:

            @receiver(update_revisions)
            def handle_update_revisions(**kwargs):
                updated.revisions = True

            if updated.checks:
                update_checks.send(
                    sender.__class__,
                    instance=sender,
                    units=updated.checks,
                    **kwargs)
            if updated.data:
                update_data.send(
                    sender.__class__,
                    instance=sender,
                    **kwargs)
            if updated.scores:
                update_scores.send(
                    sender.__class__,
                    instance=sender,
                    users=updated.scores,
                    **kwargs)
    if updated.revisions:
        update_revisions.send(
            sender.__class__,
            instance=sender,
            keys=["stats", "checks"])
示例#5
0
def config_updated_handler(**kwargs):
    if kwargs["instance"] and kwargs["key"] == "xtle.core.lang_mapping":
        update_revisions.send(Project,
                              instance=kwargs["instance"],
                              keys=["stats"])
示例#6
0
def handle_project_save(**kwargs):
    update_revisions.send(
        Project,
        instance=kwargs["instance"],
        keys=["stats", "checks"])
示例#7
0
def handle_tp_delete(**kwargs):
    update_revisions.send(
        Directory,
        instance=kwargs["instance"].directory,
        keys=["stats", "checks"])
示例#8
0
def handle_storedata_save(**kwargs):
    update_revisions.send(
        Store,
        instance=kwargs["instance"].store,
        keys=["stats", "checks"])