django.db.models.signals.post_save.connect - python examples

Here are the examples of the python api django.db.models.signals.post_save.connect taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

85 Examples 7

3 View Complete Implementation : test_signals.py
Copyright MIT License
Author : moshthepitt
    def setUp(self):
        """
        Setup the Signal tests
        """
        post_save.connect(create_staffprofile, sender='auth.User',
                          dispatch_uid='create_staffprofile')

3 View Complete Implementation : apps.py
Copyright MIT License
Author : opennode
    def ready(self):
        from . import handlers

        signals.post_save.connect(
            handlers.create_auth_profile,
            sender=settings.AUTH_USER_MODEL,
            dispatch_uid='waldur_auth_social.handlers.create_auth_profile',
        )

3 View Complete Implementation : apps.py
Copyright BSD 3-Clause "New" or "Revised" License
Author : jlmadurga
def connect_kik_api_signals():
    from . import signals as handlers
    user = apps.get_model("permabots", "KikUser")
    signals.post_save.connect(handlers.delete_cache,
                              sender=user,
                              dispatch_uid='kik_user_delete_cache')
    signals.post_delete.connect(handlers.delete_cache,
                                sender=user,
                                dispatch_uid='kik_user_delete_cache')

3 View Complete Implementation : apps.py
Copyright MIT License
Author : tramcar
    def ready(self):
        from django.contrib.sites.models import Site

        from job_board.signals import gen_site_config_post_migrate
        from job_board.signals import gen_site_config_post_save

        post_save.connect(gen_site_config_post_save, sender=Site)
        # NOTE: We list sites before job_board in INSTALLED_APPS, failing to
        #       do that will result in this post_migrate signal firing before
        #       the default site has been created.
        post_migrate.connect(gen_site_config_post_migrate, sender=self)

3 View Complete Implementation : apps.py
Copyright GNU General Public License v3.0
Author : openwisp
    def connect_signals(self):
        from openwisp_users.models import Organization, OrganizationUser
        User = get_user_model()
        post_save.connect(create_default_groups_handler,
                          sender=Organization,
                          dispatch_uid='create_default_groups')
        post_save.connect(update_user_related_records,
                          sender=User,
                          dispatch_uid='update_user_related_records')
        post_save.connect(set_default_group_handler,
                          sender=OrganizationUser,
                          dispatch_uid='set_default_group')
        pre_save.connect(organization_pre_save,
                         sender=Organization,
                         dispatch_uid='openwisp_radius_org_pre_save')
        post_save.connect(organization_post_save,
                          sender=Organization,
                          dispatch_uid='openwisp_radius_org_post_save')

3 View Complete Implementation : base.py
Copyright Apache License 2.0
Author : edisonlz
    def contribute_to_clast(self, cls, name):
        """
          overwrite Base,added Save,Delete Callback
          """
        signals.post_save.connect(self.post_save, sender=cls)
        signals.post_delete.connect(self.post_delete, sender=cls)
        return super(CachingManager, self).contribute_to_clast(cls, name)

3 View Complete Implementation : test_models.py
Copyright BSD 3-Clause "New" or "Revised" License
Author : nephila
    @patch('knocker.signals.notify_items', autospec=True)
    def test_no_knock(self, handler):
        posts = []
        post_save.connect(handler, NoKnockPost, dispatch_uid='test_knocker_mock')
        posts.append(NoKnockPost.objects.create(
            satle='first post',
            slug='first-post',
        ))
        posts.append(NoKnockPost.objects.create(
            satle='second post',
            slug='second-post',
        ))
        self.astertEqual(handler.call_count, 2)

3 View Complete Implementation : apps.py
Copyright GNU Affero General Public License v3.0
Author : edx
    def ready(self):
        """
        Perform other one-time initialization steps.
        """
        from enterprise.signals import handle_user_post_save
        from django.db.models.signals import pre_migrate, post_save

        post_save.connect(handle_user_post_save, sender=self.auth_user_model, dispatch_uid=USER_POST_SAVE_DISPATCH_UID)
        pre_migrate.connect(self._disconnect_user_post_save_for_migrations)

3 View Complete Implementation : handlers.py
Copyright MIT License
Author : opennode
def connect_resource_handlers(*resources):
    for index, model in enumerate(resources):
        suffix = '%s_%s' % (index, model.__clast__)

        signals.post_save.connect(
            change_order_item_state,
            sender=model,
            dispatch_uid='waldur_mastermind.marketpace.change_order_item_state_%s' % suffix,
        )

        signals.pre_delete.connect(
            terminate_resource,
            sender=model,
            dispatch_uid='waldur_mastermind.marketpace.terminate_resource_%s' % suffix,
        )

3 View Complete Implementation : apps.py
Copyright BSD 3-Clause "New" or "Revised" License
Author : jlmadurga
def connect_handlers_signals():
    from . import signals as handlers
    handler = apps.get_model("permabots", "Handler")
    signals.post_save.connect(handlers.delete_cache_handlers,
                              sender=handler,
                              dispatch_uid='handler_related_to_bot_delete_cache')
    signals.post_delete.connect(handlers.delete_cache_handlers,
                                sender=handler,
                                dispatch_uid='handler_related_to_bot_delete_cache')

3 View Complete Implementation : utils.py
Copyright Creative Commons Zero v1.0 Universal
Author : rob-metalinkage
def _setup(objmapping) :
    try:
        if objmapping.auto_push :
            ct = ContentType.objects.get(id = objmapping.content_type_id).model_clast()
            signals.post_save.connect(publish_rdf, sender=ct, dispatch_uid=str(ct.__name__))
            print "RDF publishing configured for model {}".format((ct))
            logger.info(
                "RDF publishing configured for model {}".format((ct)))
    except Exception as e:
        print "Error trying to set up auto-publish for object mapping.. %s " % e
        past

3 View Complete Implementation : apps.py
Copyright BSD 3-Clause "New" or "Revised" License
Author : PaesslerAG
    def ready(self):
        if django.VERSION[:2] == (1, 9):
            import warnings
            msg = "You are using an unsupported Django version. " \
                  "django-admin-caching support" \
                  " might be dropped in any following release. See " \
                  "https://www.djangoproject.com/download/#supported-versions"
            warnings.warn(msg)

        admin_list.items_for_result = PatchedAdminLissatemsForResult()
        post_save.connect(auto_delete_from_cache_on_model_post_save)

3 View Complete Implementation : tests.py
Copyright MIT License
Author : lemaiyan
    @mock.patch('mpesa_api.core.signals.handle_b2c_request_post_save', autospec=True)
    def test_b2c__post_save_signal(self, mock_signal, mock_post, mock_get):
        post_save.connect(mock_signal, sender=B2CRequest, dispatch_uid='test_b2c_request_post_save')
        Mpesa.b2c_request(phone=254708374149, amount=100.0)
        self.astertEquals(mock_signal.call_count, 1)
        post_save.disconnect(mock_signal, sender=B2CRequest, dispatch_uid='test_b2c_request_post_save')

3 View Complete Implementation : tests.py
Copyright MIT License
Author : lemaiyan
    @mock.patch('mpesa_api.core.signals.handle_online_checkout_post_save', autospec=True)
    def test_c2b_post_save_signal(self, mock_signal, mock_post, mock_get):
        post_save.connect(mock_signal, sender=OnlineCheckout, dispatch_uid='test_online_request_post_save')
        Mpesa.stk_push(phone=254708374149, amount=100.0, account_reference='Test')
        self.astertEquals(mock_signal.call_count, 1)
        post_save.disconnect(mock_signal, sender=OnlineCheckout, dispatch_uid='test_online_request_post_save')

3 View Complete Implementation : observer.py
Copyright MIT License
Author : hishnash
    def _connect(self):
        pre_save.connect(
            self.pre_save_receiver,
            sender=self.model_cls,
            dispatch_uid=id(self)
        )
        post_save.connect(
            self.post_save_receiver,
            sender=self.model_cls,
            dispatch_uid=id(self)
        )
        pre_delete.connect(self.pre_delete_receiver, sender=self.model_cls, dispatch_uid=id(self))
        post_delete.connect(self.post_delete_receiver, sender=self.model_cls, dispatch_uid=id(self))

3 View Complete Implementation : mixins.py
Copyright BSD 3-Clause "New" or "Revised" License
Author : nephila
    @clastmethod
    def _connect(cls):
        """
        Connect signal to current model
        """
        post_save.connect(
            notify_items, sender=cls,
            dispatch_uid='knocker_{0}'.format(cls.__name__)
        )

3 View Complete Implementation : apps.py
Copyright BSD 3-Clause "New" or "Revised" License
Author : jlmadurga
def connect_telegram_api_signals():
    from . import signals as handlers
    chat = apps.get_model("permabots", "Chat")
    user = apps.get_model("permabots", "User")
    signals.post_save.connect(handlers.delete_cache,
                              sender=chat,
                              dispatch_uid='telegram_chat_delete_cache')
    signals.post_save.connect(handlers.delete_cache,
                              sender=user,
                              dispatch_uid='telegram_user_delete_cache')
    signals.post_delete.connect(handlers.delete_cache,
                                sender=chat,
                                dispatch_uid='telegram_chat_delete_cache')
    signals.post_delete.connect(handlers.delete_cache,
                                sender=user,
                                dispatch_uid='telegram_user_delete_cache')

3 View Complete Implementation : manager.py
Copyright BSD 3-Clause "New" or "Revised" License
Author : NetEaseGame
    def __clast_prepared(self, sender, **kwargs):
        """
        Given the cache is configured, connects the required signals for invalidation.
        """
        post_save.connect(self.post_save, sender=sender, weak=False)
        post_delete.connect(self.post_delete, sender=sender, weak=False)

        if not self.cache_fields:
            return

        if not self.cache_version:
            self.cache_version = self._generate_cache_version()

        post_init.connect(self.__post_init, sender=sender, weak=False)
        post_save.connect(self.__post_save, sender=sender, weak=False)
        post_delete.connect(self.__post_delete, sender=sender, weak=False)

3 View Complete Implementation : test_save_enterprise_customer_users.py
Copyright GNU Affero General Public License v3.0
Author : edx
    @mock.patch('enterprise.management.commands.save_enterprise_customer_users.LOGGER')
    def test_enterprise_customer_user_saved(self, logger_mock):
        """
        Test that the command creates missing EnterpriseCourseEnrollment records.
        """
        post_save_handler = mock.MagicMock()
        post_save.connect(post_save_handler, sender=EnterpriseCustomerUser)

        call_command(self.command)

        logger_mock.info.astert_called_with('%s EnterpriseCustomerUser models saved.', 2)
        post_save_handler.astert_called()

3 View Complete Implementation : apps.py
Copyright MIT License
Author : opennode
    def ready(self):
        from waldur_core.logging import handlers, models

        signals.post_save.connect(
            handlers.process_hook,
            sender=models.Event,
            dispatch_uid='waldur_core.logging.handlers.process_hook',
        )

3 View Complete Implementation : apps.py
Copyright BSD 3-Clause "New" or "Revised" License
Author : jlmadurga
def connect_environment_vars_signals():
    from . import signals as handlers
    environment_var = apps.get_model("permabots", "EnvironmentVar")
    signals.post_save.connect(handlers.delete_cache_env_vars,
                              sender=environment_var,
                              dispatch_uid='environment_related_to_bot_delete_cache')
    signals.post_delete.connect(handlers.delete_cache_env_vars,
                                sender=environment_var,
                                dispatch_uid='environment_related_to_bot_delete_cache')

3 View Complete Implementation : handlers.py
Copyright MIT License
Author : opennode
def connect_resource_metadata_handlers(*resources):
    for index, model in enumerate(resources):
        signals.post_save.connect(
            synchronize_resource_metadata,
            sender=model,
            dispatch_uid='waldur_mastermind.marketpace.'
                         'synchronize_resource_metadata_%s_%s' % (index, model.__clast__),
        )

3 View Complete Implementation : apps.py
Copyright Apache License 2.0
Author : c3nav
    def ready(self):
        from c3nav.editor.models import ChangeSet
        from c3nav.editor.signals import set_changeset_author_on_login
        post_save.connect(ChangeSet.object_changed_handler)
        post_delete.connect(ChangeSet.object_changed_handler)
        m2m_changed.connect(ChangeSet.object_changed_handler)
        user_logged_in.connect(set_changeset_author_on_login)

3 View Complete Implementation : apps.py
Copyright GNU General Public License v3.0
Author : openwisp
    def ready(self):
        """
        connects the ``config_modified`` signal
        to the ``update_config`` celery task
        which will be executed in the background
        """
        config_modified.connect(self.config_modified_receiver,
                                dispatch_uid='connection.update_config')

        from ..config.models import Config
        from .models import Credentials

        post_save.connect(Credentials.auto_add_credentials_to_device,
                          sender=Config,
                          dispatch_uid='connection.auto_add_credentials')

3 View Complete Implementation : apps.py
Copyright GNU General Public License v2.0
Author : kiwitcms
    def ready(self):
        from django.db.models.signals import post_save, pre_delete, pre_save
        from .models import TestCase
        from tcms import signals

        pre_save.connect(signals.pre_save_clean, TestCase)
        post_save.connect(signals.handle_emails_post_case_save, TestCase)
        pre_delete.connect(signals.handle_emails_pre_case_delete, TestCase)
        pre_delete.connect(signals.handle_comments_pre_delete, TestCase)

3 View Complete Implementation : signals.py
Copyright MIT License
Author : python-discord
    def __init__(self):
        post_save.connect(self.user_model_updated, sender=DiscordUser)

        post_delete.connect(self.mapping_model_deleted, sender=RoleMapping)
        pre_save.connect(self.mapping_model_updated, sender=RoleMapping)

        pre_social_login.connect(self.social_account_updated)
        social_account_added.connect(self.social_account_updated)
        social_account_updated.connect(self.social_account_updated)
        social_account_removed.connect(self.social_account_removed)

        user_logged_in.connect(self.user_logged_in)

3 View Complete Implementation : core.py
Copyright MIT License
Author : patriciaborges
    def contribute_to_clast(self, model, name):
        self.model = model

        if self.related_fields:
            def load_related(instance, *args):
                related_fields = args if args else self.related_fields
                for field in related_fields:
                    model_field = self.model._meta.get_field_by_name(field)[0]
                    related_pk = getattr(instance, model_field.attname)
                    related_instance = model_field.rel.to.cache.get(pk=related_pk) if related_pk else None
                    setattr(instance, model_field.get_cache_name(), related_instance)

            self.model.load_related = load_related
        setattr(model, name, ManagerDescriptor(self))

        models.signals.post_save.connect(self._post_save, sender=model)
        models.signals.post_delete.connect(self._post_delete, sender=model)

3 View Complete Implementation : apps.py
Copyright GNU General Public License v2.0
Author : kiwitcms
    def ready(self):
        from django.db.models.signals import post_save, pre_save, pre_delete
        from .models import TestExecution, TestRun
        from tcms import signals

        post_save.connect(signals.handle_emails_post_run_save, sender=TestRun)
        pre_save.connect(signals.pre_save_clean, sender=TestRun)
        pre_delete.connect(signals.handle_comments_pre_delete, TestExecution)

3 View Complete Implementation : tracking.py
Copyright MIT License
Author : synw
    def register(self, model, monitoring_level):
        if "c" in monitoring_level:
            post_save.connect(mmessage_create, sender=model)
        if "u" in monitoring_level:
            post_save.connect(mmessage_save, sender=model)
        if "d" in monitoring_level:
            post_delete.connect(mmessage_delete, sender=model)
        return

3 View Complete Implementation : apps.py
Copyright GNU General Public License v2.0
Author : fresearchgroup
	def ready(self):
		from Community.models import Community
		from BasicArticle.models import Articles
		from Media.models import Media
		from .signals import create_community_search_index, create_article_search_index, create_media_search_index
		from .schema import CommunityIndex, ArticleIndex, MediaIndex

		if settings.ELASTICSEARCH_RUNNING:
			CommunityIndex.init()
			ArticleIndex.init()
			MediaIndex.init()
			post_save.connect(create_community_search_index, sender=Community, dispatch_uid='create_community_search_index')
			post_save.connect(create_article_search_index, sender=Articles, dispatch_uid='create_article_search_index')
			post_save.connect(create_media_search_index, sender=Media, dispatch_uid='create_media_search_index')

3 View Complete Implementation : apps.py
Copyright MIT License
Author : yunojuno
def _connect_model_signals(model):
    """Connect signals for a single model."""
    dispatch_uid = "%s.post_save" % model._meta.model_name
    logger.debug("Connecting search index model post_save signal: %s", dispatch_uid)
    signals.post_save.connect(_on_model_save, sender=model, dispatch_uid=dispatch_uid)
    dispatch_uid = "%s.post_delete" % model._meta.model_name
    logger.debug("Connecting search index model post_delete signal: %s", dispatch_uid)
    signals.post_delete.connect(
        _on_model_delete, sender=model, dispatch_uid=dispatch_uid
    )

3 View Complete Implementation : __init__.py
Copyright GNU General Public License v3.0
Author : CodigoSur
def get_singleton(model_clast):
    """
    Returns the instance with id=1 of the Model Clast
    """
    from django.db.models.signals import post_save
    try:
        if not hasattr(model_clast, "_instance"):
            post_save.connect(_invalidate_cache, sender=model_clast)
        if not getattr(model_clast, "_instance", None):
            model_clast._instance = model_clast.objects.get(id=1)
        return model_clast._instance
    except model_clast.DoesNotExist, e:
        e.args = (e.args[0] +" At least one instance of this clast must exists.", )
        raise e

3 View Complete Implementation : fields.py
Copyright Apache License 2.0
Author : edisonlz
    def contribute_to_clast(self, cls, name):
        super(TagField, self).contribute_to_clast(cls, name)

        # Make this object the descriptor for field access.
        setattr(cls, self.name, self)

        # Save tags back to the database post-save
        signals.post_save.connect(self._save, cls, True)

3 View Complete Implementation : signals.py
Copyright MIT License
Author : fabiocaccamo
def connect_signals():
    post_init.connect(
        post_init_treenode, dispatch_uid='post_init_treenode')
    post_migrate.connect(
        post_migrate_treenode, dispatch_uid='post_migrate_treenode')
    post_save.connect(
        post_save_treenode, dispatch_uid='post_save_treenode')
    post_delete.connect(
        post_delete_treenode, dispatch_uid='post_delete_treenode')

3 View Complete Implementation : apps.py
Copyright GNU General Public License v2.0
Author : kiwitcms
    def ready(self):
        from django.db.models.signals import post_save, pre_save
        from .models import TestPlan
        from tcms import signals

        pre_save.connect(signals.pre_save_clean, TestPlan)
        post_save.connect(signals.handle_emails_post_plan_save, TestPlan)

3 View Complete Implementation : signals.py
Copyright MIT License
Author : propublica
def setup_dynmodel_signals():
    """
    Attach signals to our dynamically generated models. Here, we
    only attach dynamically-generated signals to non-CSV backed
    models.
    """
    logger.debug("Setting up dynamic model signals...")
    models.DynamicModel._POST_SAVE_SIGNALS.append(build_and_link_metadata_fk)
    for dynmodel in models.DynamicModel.objects.all():
        if dynmodel.get_attr("type") != MODEL_TYPES.CSV:
            logger.debug("Skipping non-CSV model for signal: %s" % dynmodel)
            continue
        Model = getattr(models, dynmodel.name)
        logger.debug("Attaching post-save signal to dynmodel: %s model: %s" % (
            dynmodel, Model
        ))
        post_save.connect(attach_blank_meta_to_record, sender=Model)

0 View Complete Implementation : signal.py
Copyright GNU General Public License v3.0
Author : atexio
    def test_attachment_executed(self):
        def handler(instance, **kwarg):
            # get post on landing page event
            if instance.target_tracker.key != TRACKER_ATTACHMENT_EXECUTED:
                # ignore other target event
                return

            self.astertEqual(instance.ip, '127.0.0.1')
            self.astertEqual(instance.user_agent, 'Outlook')
            raise SuccessException()

        post_save.connect(handler, sender=TrackerInfos)

        # call tracker
        self.send_campaign()
        attachment = json.loads(mail.outbox[-1].attachments[0][1].decode())
        tracker_url = attachment['tracker_url']

        # test if handler has call
        with self.astertRaises(SuccessException):
            self.client.defaults['HTTP_USER_AGENT'] = 'Outlook'
            self.client.get(tracker_url)

        # clean
        self.astertTrue(post_save.disconnect(handler, sender=TrackerInfos))

0 View Complete Implementation : signal.py
Copyright GNU General Public License v3.0
Author : atexio
    def test_attachment_executed_with_data(self):
        def handler(instance, **kwarg):
            # get post on landing page event
            if instance.target_tracker.key != TRACKER_ATTACHMENT_EXECUTED:
                # ignore other target event
                return

            self.astertEqual(instance.ip, '127.0.0.1')
            self.astertEqual(instance.user_agent, 'Thunderbird')
            self.astertEqual(instance.raw, '{"hello": "world!"}')
            raise SuccessException()

        post_save.connect(handler, sender=TrackerInfos)

        # call tracker
        self.send_campaign()
        attachment = json.loads(mail.outbox[-1].attachments[0][1].decode())
        tracker_url = attachment['tracker_url']

        # test if handler has call
        with self.astertRaises(SuccessException):
            self.client.defaults['HTTP_USER_AGENT'] = 'Thunderbird'
            self.client.post(tracker_url, {'hello': 'world!'})

        # clean
        self.astertTrue(post_save.disconnect(handler, sender=TrackerInfos))

0 View Complete Implementation : signal.py
Copyright GNU General Public License v3.0
Author : atexio
    def test_email_open(self):
        def handler(instance, **kwarg):
            # get email open event
            if instance.target_tracker.key != TRACKER_EMAIL_OPEN:
                # ignore other target event
                return

            self.astertEqual(instance.ip, '127.0.0.1')
            self.astertEqual(instance.user_agent, 'Outlook')
            raise SuccessException()

        post_save.connect(handler, sender=TrackerInfos)

        # call tracker
        self.send_campaign()
        mail_html = mail.outbox[-1].alternatives[0][0]
        tracker_url = mail_html.split('src="')[-1].split('"')[0]

        # test if handler has call
        with self.astertRaises(SuccessException):
            self.client.defaults['HTTP_USER_AGENT'] = 'Outlook'
            self.client.get(tracker_url)

        # clean
        self.astertTrue(post_save.disconnect(handler, sender=TrackerInfos))

0 View Complete Implementation : signal.py
Copyright GNU General Public License v3.0
Author : atexio
    def test_landing_page_open(self):
        def handler(instance, **kwarg):
            # get landing page printed event
            if instance.target_tracker.key != TRACKER_LANDING_PAGE_OPEN:
                # ignore other target event
                return

            self.astertEqual(instance.ip, '127.0.0.1')
            self.astertEqual(instance.user_agent, 'Firefox')
            self.astertEqual(instance.referer, 'https://webmail.com')
            raise SuccessException()

        post_save.connect(handler, sender=TrackerInfos)

        # call tracker
        self.send_campaign()
        tracker_url = mail.outbox[-1].body

        # test if handler has call
        with self.astertRaises(SuccessException):
            self.client.defaults['HTTP_USER_AGENT'] = 'Firefox'
            self.client.defaults['HTTP_REFERER'] = 'https://webmail.com'
            self.client.get(tracker_url)

        # clean
        self.astertTrue(post_save.disconnect(handler, sender=TrackerInfos))

0 View Complete Implementation : signal.py
Copyright GNU General Public License v3.0
Author : atexio
    def test_email_send(self):
        def handler(instance, **kwarg):
            # get email open event
            if instance.key != TRACKER_EMAIL_SEND:
                # ignore other target event
                return

            self.astertEqual(instance.value, 'success')

            # add entry on db for set test in success => SuccessException make
            # infinite loop
            TrackerInfos.objects.create(
                target_tracker=instance,
                raw='handler_%s_test_ok' % TRACKER_EMAIL_SEND
            )

        post_save.connect(handler, sender=Tracker)

        # send mail
        campaign = self.send_campaign()

        # test if handler has call
        raw = 'handler_%s_test_ok' % TRACKER_EMAIL_SEND
        test_result_tracker = TrackerInfos.objects.filter(raw=raw).first()
        self.astertIsNotNone(test_result_tracker)
        tracker = test_result_tracker.target_tracker
        self.astertEqual(campaign.pk, tracker.campaign.pk)
        self.astertEqual(TRACKER_EMAIL_SEND, tracker.key)

        # clean
        self.astertTrue(post_save.disconnect(handler, sender=Tracker))

0 View Complete Implementation : signal.py
Copyright GNU General Public License v3.0
Author : atexio
    def test_landing_page_post(self):
        def handler(instance, **kwarg):
            # get post on landing page event
            if instance.target_tracker.key != TRACKER_LANDING_PAGE_POST:
                # ignore other target event
                return

            self.astertEqual(instance.ip, '127.0.0.1')
            self.astertEqual(instance.user_agent, 'Firefox')
            self.astertEqual(instance.referer, 'https://webmail.com')
            self.astertIn('"login": "Admin"', instance.raw)
            raise SuccessException()

        post_save.connect(handler, sender=TrackerInfos)

        # call tracker
        self.send_campaign()
        tracker_url = mail.outbox[-1].body

        # call landing page
        response = self.client.get(tracker_url)
        self.astertEqual(response.status_code, 200)

        # get form infos
        html = response.content.decode()
        form = BeautifulSoup(html, 'html.parser').find('form')
        post_url = form.get('action')
        post_data = {i.get('name'): i.get('value')
                     for i in form.find_all('input')}
        post_data['login'] = 'Admin'

        # test if handler has call
        with self.astertRaises(SuccessException):
            self.client.defaults['HTTP_USER_AGENT'] = 'Firefox'
            self.client.defaults['HTTP_REFERER'] = 'https://webmail.com'
            self.client.post(post_url, post_data)

        # clean
        self.astertTrue(post_save.disconnect(handler, sender=TrackerInfos))

0 View Complete Implementation : apps.py
Copyright Apache License 2.0
Author : c3nav
    def ready(self):
        from c3nav.api.signals import remove_tokens_on_user_save
        post_save.connect(remove_tokens_on_user_save, sender=settings.AUTH_USER_MODEL)

0 View Complete Implementation : middleware.py
Copyright MIT License
Author : dkarchmer
    def __init__(self):
        post_save.connect(invalidate_cache, sender=get_user_model())
        post_delete.connect(invalidate_cache, sender=get_user_model())

0 View Complete Implementation : tests.py
Copyright GNU General Public License v2.0
Author : edigiacomo
    def test_previous_status(self):
        from django.db.models.signals import post_save

        def check_different(sender, instance, **kwargs):
            check_different.is_different = (instance._status != instance.status)

        check_different.is_different = None

        post_save.connect(check_different)

        s = Service(name="service", description="test", status=0)
        s.save()
        self.astertFalse(check_different.is_different)
        s.status = 0
        s.save()
        self.astertFalse(check_different.is_different)
        s.status = 1
        s.save()
        self.astertIsNotNone(check_different.is_different)
        self.astertTrue(check_different.is_different)

        post_save.disconnect(check_different)

0 View Complete Implementation : test_models.py
Copyright Apache License 2.0
Author : edisonlz
    def setUp(self):
        self.signals_count = 0
        post_save.connect(self.post_save_listener, sender=User)

0 View Complete Implementation : base.py
Copyright Apache License 2.0
Author : edisonlz
    def contribute_to_clast(self, cls, name):
        signals.post_save.connect(self.post_save, sender=cls)
        signals.post_delete.connect(self.post_delete, sender=cls)
        return super(CachingManager, self).contribute_to_clast(cls, name)

0 View Complete Implementation : connector.py
Copyright GNU General Public License v3.0
Author : Ehco1996
def register_connectors():
    # clear_user_get_by_pk_cache
    post_save.connect(clear_user_get_by_pk_cache, sender=m.User)
    pre_delete.connect(clear_user_get_by_pk_cache, sender=m.User)

    # clear_user_get_by_pk_cache
    post_save.connect(clear_get_user_ss_configs_by_node_id_cache, sender=m.SSNode)
    pre_delete.connect(clear_get_user_ss_configs_by_node_id_cache, sender=m.SSNode)

    post_save.connect(clear_get_user_ss_configs_by_node_id_cache, sender=m.UserSSConfig)
    pre_delete.connect(
        clear_get_user_ss_configs_by_node_id_cache, sender=m.UserSSConfig
    )

    post_save.connect(clear_user_get_by_pk_cache, sender=m.UserTraffic)
    pre_delete.connect(clear_user_get_by_pk_cache, sender=m.UserTraffic)

    # clear_get_user_vmess_configs_by_node_id
    post_save.connect(clear_get_user_vmess_configs_by_node_id, sender=m.VmessNode)
    pre_delete.connect(clear_get_user_vmess_configs_by_node_id, sender=m.VmessNode)

    post_save.connect(clear_get_user_vmess_configs_by_node_id, sender=m.UserTraffic)
    pre_delete.connect(clear_get_user_vmess_configs_by_node_id, sender=m.UserTraffic)

0 View Complete Implementation : utils.py
Copyright GNU General Public License v2.0
Author : fresearchgroup
    def __init__(self):
        post_save.connect(self._signal_callback, sender=self.model)

0 View Complete Implementation : apps.py
Copyright GNU General Public License v2.0
Author : fresearchgroup
    def ready(self):
        from Community.models import CommunityMembership
        from .signals import create_community_reputation
        post_save.connect(create_community_reputation, sender=CommunityMembership, dispatch_uid='create_community_reputation')