Пример #1
0
    def save(self, *args, **kwargs):
        from weblate.trans.tasks import component_alerts

        update_tm = self.contribute_shared_tm

        # Renaming detection
        old = None
        if self.id:
            old = Project.objects.get(pk=self.id)
            # Detect slug changes and rename directory
            self.check_rename(old)
            # Rename linked repos
            if old.slug != self.slug:
                for component in old.component_set.iterator():
                    new_component = self.component_set.get(pk=component.pk)
                    new_component.project = self
                    component.linked_childs.update(
                        repo=new_component.get_repo_link_url())
            update_tm = self.contribute_shared_tm and not old.contribute_shared_tm

        self.create_path()

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

        # Update alerts if needed
        if old is not None and old.web != self.web:
            component_alerts.delay(
                list(self.component_set.values_list("id", flat=True)))

        # Update translation memory on enabled sharing
        if update_tm:
            transaction.on_commit(lambda: import_memory.delay(self.id))
Пример #2
0
def change_screenshot_assignment(sender, instance, action, **kwargs):
    # Update alerts in case there is change in string assignment
    if instance.translation.component.alert_set.filter(
            name="UnusedScreenshot").exists():
        component_alerts.delay([instance.pk])