Ejemplo n.º 1
0
    def init_from_templates(self):
        """Initializes the current translation project files using
        the templates TP ones.
        """

        template_tp = self.project.get_template_translationproject()
        template_stores = template_tp.stores.live().exclude(file="")

        for template_store in template_stores.iterator():
            init_store_from_template(self, template_store)

        self.update_from_disk()
Ejemplo n.º 2
0
    def init_from_templates(self):
        """Initializes the current translation project files using
        the templates TP ones.
        """
        template_stores = self.templates_tp.stores.live().select_related(
            "filetype__template_extension",
            "filetype__extension").exclude(file="")

        for template_store in template_stores.iterator():
            init_store_from_template(self, template_store)

        self.update_from_disk()
Ejemplo n.º 3
0
    def init_from_templates(self):
        """Initializes the current translation project files using
        the templates TP ones.
        """

        template_tp = self.project.get_template_translationproject()
        template_stores = template_tp.stores.live().exclude(file="")

        for template_store in template_stores.iterator():
            init_store_from_template(self, template_store)

        self.update_from_disk()
Ejemplo n.º 4
0
    def init_from_templates(self):
        """Initializes the current translation project files using
        the templates TP ones.
        """
        template_stores = self.templates_tp.stores.live().select_related(
            "filetype__template_extension",
            "filetype__extension").exclude(file="")

        for template_store in template_stores.iterator():
            init_store_from_template(self, template_store)

        self.update_from_disk()
Ejemplo n.º 5
0
Archivo: models.py Proyecto: haf/pootle
    def save(self, *args, **kwargs):
        created = self.id is None

        if created:
            from pootle_app.project_tree import translation_project_dir_exists

            template_tp = self.project.get_template_translationproject()
            initialize_from_templates = (
                not self.is_template_project
                and template_tp is not None
                and not translation_project_dir_exists(self.language,
                                                       self.project))

        self.directory = self.language.directory \
                                      .get_or_make_subdir(self.project.code)
        self.pootle_path = self.directory.pootle_path

        project_dir = self.project.get_real_path()
        from pootle_app.project_tree import get_translation_project_dir
        self.abs_real_path = get_translation_project_dir(
            self.language, project_dir, self.file_style, make_dirs=not
            self.directory.obsolete)

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

        if created:
            if initialize_from_templates:
                # We are adding a new TP and there are no files to import from
                # disk, so initialize the TP files using the templates TP ones.
                from pootle_app.project_tree import init_store_from_template

                template_stores = template_tp.stores.live().exclude(file="")

                for template_store in template_stores.iterator():
                    init_store_from_template(self, template_store)

            self.scan_files()

            # If this TP has no stores, cache should be updated forcibly.
            if self.stores.live().count() == 0:
                self.update_all_cache()

            # Create units from disk store
            for store in self.stores.live().iterator():
                changed = store.update_from_disk()

                # If there were changes stats will be refreshed anyway -
                # otherwise...  Trigger stats refresh for TP added from UI.
                # FIXME: This won't be necessary once #3547 is fixed.
                if not changed:
                    store.save(update_cache=True)
Ejemplo n.º 6
0
    def save(self, *args, **kwargs):
        created = self.id is None

        if created:
            from pootle_app.project_tree import translation_project_dir_exists

            template_tp = self.project.get_template_translationproject()
            initialize_from_templates = (not self.is_template_project
                                         and template_tp is not None and
                                         not translation_project_dir_exists(
                                             self.language, self.project))

        self.directory = self.language.directory \
                                      .get_or_make_subdir(self.project.code)
        self.pootle_path = self.directory.pootle_path

        project_dir = self.project.get_real_path()
        from pootle_app.project_tree import get_translation_project_dir
        self.abs_real_path = get_translation_project_dir(
            self.language,
            project_dir,
            self.file_style,
            make_dirs=not self.directory.obsolete)

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

        if created:
            if initialize_from_templates:
                # We are adding a new TP and there are no files to import from
                # disk, so initialize the TP files using the templates TP ones.
                from pootle_app.project_tree import init_store_from_template

                for template_store in template_tp.stores.live().iterator():
                    init_store_from_template(self, template_store)

            self.scan_files()

            # Create units from disk store
            for store in self.stores.live().iterator():
                changed = store.update_from_disk()

                # If there were changes stats will be refreshed anyway - otherwise...
                # Trigger stats refresh for TP added from UI.
                # FIXME: This won't be necessary once #3547 is fixed.
                if not changed:
                    store.save(update_cache=True)
Ejemplo n.º 7
0
    def save(self, *args, **kwargs):
        created = self.id is None

        if created:
            from pootle_app.project_tree import translation_project_should_exist

            template_tp = self.project.get_template_translationproject()
            initialize_from_templates = False

            if (not self.is_template_project and
                template_tp is not None and
                not translation_project_should_exist(self.language,
                                                     self.project)):

                initialize_from_templates = True

        self.directory = self.language.directory \
                                      .get_or_make_subdir(self.project.code)
        self.pootle_path = self.directory.pootle_path

        project_dir = self.project.get_real_path()
        from pootle_app.project_tree import get_translation_project_dir
        self.abs_real_path = get_translation_project_dir(self.language,
             project_dir, self.file_style,
             make_dirs=not self.directory.obsolete)

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

        if created:
            if initialize_from_templates:
                # We are adding a new TP and there are no files to import from
                # disk, so initialize the TP files using the templates TP ones.
                from pootle_app.project_tree import init_store_from_template

                for template_store in template_tp.stores.iterator():
                    init_store_from_template(self, template_store)

            self.scan_files()

            if initialize_from_templates:
                # Trigger stats refresh for TP added from UI.
                # FIXME: This won't be necessary once #3547 is fixed.
                for store in self.stores.live().iterator():
                    store.update()
Ejemplo n.º 8
0
    def save(self, *args, **kwargs):
        created = self.id is None

        if created:
            from pootle_app.project_tree import translation_project_dir_exists

            template_tp = self.project.get_template_translationproject()
            initialize_from_templates = (
                not self.is_template_project
                and template_tp is not None
                and not translation_project_dir_exists(self.language,
                                                       self.project))

        self.directory = self.language.directory \
                                      .get_or_make_subdir(self.project.code)
        self.pootle_path = self.directory.pootle_path

        project_dir = self.project.get_real_path()
        from pootle_app.project_tree import get_translation_project_dir
        self.abs_real_path = get_translation_project_dir(
            self.language, project_dir, self.file_style, make_dirs=not
            self.directory.obsolete)

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

        if created:
            if initialize_from_templates:
                # We are adding a new TP and there are no files to import from
                # disk, so initialize the TP files using the templates TP ones.
                from pootle_app.project_tree import init_store_from_template

                template_stores = template_tp.stores.live().exclude(file="")

                for template_store in template_stores.iterator():
                    init_store_from_template(self, template_store)

                self.update_from_disk()