コード例 #1
0
ファイル: models.py プロジェクト: Gayathri-Palanimuthu/pootle
    """Flush all goals caches for the store that holds the unit.

    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.
    """
    if 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)
コード例 #2
0
ファイル: __init__.py プロジェクト: a-covar/pootle
#
# 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.contrib.auth.models import User
from django.db.models.signals import post_save, pre_save

from pootle_language.models import Language
from pootle_project.models import Project
from pootle_translationproject.models import TranslationProject
from pootle_store.models import Unit

from pootle_autonotices import signals

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_save.connect(signals.new_translationproject, sender=TranslationProject)
pre_save.connect(signals.unit_updated, sender=Unit)

from pootle_app.models.signals import post_vc_update, post_vc_commit
from pootle_app.models.signals import post_template_update, post_file_upload
post_vc_update.connect(signals.updated_from_version_control)
post_vc_commit.connect(signals.committed_to_version_control)
post_template_update.connect(signals.updated_against_template)
post_file_upload.connect(signals.file_uploaded)
コード例 #3
0
from pootle_language.models import Language
from pootle_project.models import Project
from pootle_translationproject.models import TranslationProject
from pootle_store.models import Unit

from pootle_autonotices import signals

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_save.connect(signals.new_translationproject, sender=TranslationProject)
pre_save.connect(signals.unit_updated, sender=Unit)

from pootle_app.models.signals import post_vc_update, post_vc_commit
from pootle_app.models.signals import post_template_update, post_file_upload
post_vc_update.connect(signals.updated_from_version_control)
post_vc_commit.connect(signals.committed_to_version_control)
post_template_update.connect(signals.updated_from_template)
post_file_upload.connect(signals.file_uploaded)

try:
    from django.db.models.signals import m2m_changed
    from pootle_profile.models import PootleProfile
    m2m_changed.connect(signals.user_joined_project,
                        sender=PootleProfile.projects.through)
    m2m_changed.connect(signals.user_joined_language,
                        sender=PootleProfile.languages.through)
except ImportError:
    pass
コード例 #4
0
ファイル: models.py プロジェクト: JMassapina/pootle
    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)