Ejemplo n.º 1
0
    def modifyContext(self, properties):
        """Update the user object with the given properties"""
        # If updating the twitterUsername, get its Twitter ID
        if properties.get("twitterUsername", None):
            api = get_twitter_api(self.request.registry)
            properties["twitterUsernameId"] = get_userid_from_twitter(api, properties["twitterUsername"])

        self.updateFields(properties)

        if self.get("twitterUsername", None) is None and self.get("twitterUsernameId", None) is not None:
            del self["twitterUsernameId"]

        # someone changed notifications settings for this context
        if "notifications" in properties:
            notifier = RabbitNotifications(self.request)
            if self.get("notifications", False):
                for user in self.subscribedUsers():
                    notifier.bind_user_to_context(self, user["username"])
            else:
                for user in self.subscribedUsers():
                    notifier.unbind_user_from_context(self, user["username"])

        if "url" in properties:
            self["hash"] = sha1(self["url"]).hexdigest()

        self.save()
Ejemplo n.º 2
0
 def _after_subscription_remove(self, username):
     """
         Removes rabbitmq bindings after new subscription
     """
     notifier = RabbitNotifications(self.request)
     notifier.unbind_user_from_context(self, username)