Commit fc2cb11b authored by Michal Čihař's avatar Michal Čihař

Add signals for VCS operations

Fixes #803
Signed-off-by: default avatarMichal Čihař <michal@cihar.com>
parent 39103cef
......@@ -38,6 +38,7 @@ from weblate.trans.filelock import FileLock
from weblate.trans.util import (
is_repo_link, get_site_url, cleanup_repo_url, get_clean_env, cleanup_path,
)
from weblate.trans.signals import vcs_post_push, vcs_post_update
from weblate.trans.vcs import RepositoryException, VCS_REGISTRY, VCS_CHOICES
from weblate.trans.models.translation import Translation
from weblate.trans.validators import (
......@@ -693,6 +694,7 @@ class SubProject(models.Model, PercentMixin, URLMixin, PathMixin):
# run post update hook
self.run_hook(self.post_update_script)
vcs_post_update.send(sender=self.__class__, subproject=self)
# create translation objects for all files
self.create_translations(request=request)
......@@ -751,6 +753,7 @@ class SubProject(models.Model, PercentMixin, URLMixin, PathMixin):
)
self.run_hook(self.post_push_script)
vcs_post_push.send(sender=self.__class__, subproject=self)
return True
except RepositoryException as error:
......
......@@ -38,6 +38,7 @@ from weblate.trans.formats import AutoFormat, StringIOMode
from weblate.trans.checks import CHECKS
from weblate.trans.models.unit import Unit
from weblate.trans.models.unitdata import Suggestion
from weblate.trans.signals import vcs_pre_commit, vcs_post_commit
from weblate.trans.util import (
get_site_url, translation_percent, split_plural,
)
......@@ -755,6 +756,7 @@ class Translation(models.Model, URLMixin, PercentMixin, LoggerMixin):
# Pre commit hook
self.subproject.run_pre_commit_script(self.get_filename())
vcs_pre_commit.send(sender=self.__class__, translation=self)
# Create list of files to commit
files = [self.filename]
......@@ -776,6 +778,7 @@ class Translation(models.Model, URLMixin, PercentMixin, LoggerMixin):
# Post commit hook
self.subproject.run_post_commit_script(self.get_filename())
vcs_post_commit.send(sender=self.__class__, translation=self)
# Optionally store updated hash
if sync:
......
# -*- coding: utf-8 -*-
#
# Copyright © 2012 - 2015 Michal Čihař <michal@cihar.com>
#
# This file is part of Weblate <http://weblate.org/>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
"""Custom Weblate signals"""
from django.dispatch import Signal
vcs_post_push = Signal(providing_args=['subproject'])
vcs_post_update = Signal(providing_args=['subproject'])
vcs_pre_commit = Signal(providing_args=['translation'])
vcs_post_commit = Signal(providing_args=['translation'])
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment