コード例 #1
0
ファイル: __init__.py プロジェクト: henriksa/pootle
# 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
# Pootle; if not, see <http://www.gnu.org/licenses/>.

from django.contrib.auth import get_user_model
from django.db.models.signals import post_save

from pootle_app.signals import (post_file_upload, post_template_update,
                                post_vc_commit, post_vc_update)
from pootle_language.models import Language
from pootle_project.models import Project

from . import signals


User = get_user_model()


post_save.connect(signals.new_language, sender=Language)
post_save.connect(signals.new_project, sender=Project)
post_save.connect(signals.new_user, sender=User)

post_file_upload.connect(signals.file_uploaded)

post_template_update.connect(signals.updated_against_template)

post_vc_commit.connect(signals.committed_to_version_control)

post_vc_update.connect(signals.updated_from_version_control)
コード例 #2
0
    This signal handler is called, for example, when a new translation is sent
    or a suggestion is accepted.
    """
    pootle_path = unit.store.parent.pootle_path
    Goal.flush_all_caches_for_path(pootle_path)


translation_submitted.connect(flush_goal_caches_for_unit)


def flush_goal_caches(sender, **kwargs):
    """Flush all goals caches for sender if a signal is received.

    This signal handler is called, for example, when the TP is updated against
    the templates, or a new file is uploaded, or the TP is updated from VCS.
    """
    # Not all signals has stats args, so we check their presence first.
    if 'oldstats' in kwargs and kwargs['oldstats'] == kwargs['newstats']:
        # Nothing changed, no need to flush goal cached stats.
        return
    else:
        #FIXME: It is too radical to remove all the caches even if just one
        # file was uploaded. Look at a more surgical way to perform this.
        Goal.flush_all_caches_in_tp(sender)


post_file_upload.connect(flush_goal_caches)
post_template_update.connect(flush_goal_caches)
post_vc_update.connect(flush_goal_caches)
コード例 #3
0
ファイル: __init__.py プロジェクト: cboylan/pootle
# terms of the GNU General Public License as published by the Free Software
# Foundation; either version 2 of the License, or (at your option) any later
# version.
#
# Pootle 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
# Pootle; if not, see <http://www.gnu.org/licenses/>.

from django.db.models.signals import post_save

from pootle_app.signals import (post_file_upload, post_template_update,
                                post_vc_commit, post_vc_update)
from pootle_language.models import Language
from pootle_project.models import Project

from . import signals

post_save.connect(signals.new_language, sender=Language)
post_save.connect(signals.new_project, sender=Project)

post_file_upload.connect(signals.file_uploaded)

post_template_update.connect(signals.updated_against_template)

post_vc_commit.connect(signals.committed_to_version_control)

post_vc_update.connect(signals.updated_from_version_control)