本文整理汇总了Python中taiga.projects.notifications.services.analize_object_for_watchers函数的典型用法代码示例。如果您正苦于以下问题:Python analize_object_for_watchers函数的具体用法?Python analize_object_for_watchers怎么用?Python analize_object_for_watchers使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了analize_object_for_watchers函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: send_notifications
def send_notifications(self, obj, history=None):
"""
Shortcut method for resources with special save
cases on actions methods that not uses standard
`post_save` hook of drf resources.
"""
if history is None:
history = self.get_last_history()
# If not history found, or it is empty. Do notthing.
if not history:
return
if self._not_notify:
return
obj = self.get_object_for_snapshot(obj)
# Process that analizes the corresponding diff and
# some text fields for extract mentions and add them
# to watchers before obtain a complete list of
# notifiable users.
services.analize_object_for_watchers(obj, history.comment, history.owner)
# Get a complete list of notifiable users for current
# object and send the change notification to them.
services.send_notifications(obj, history=history)
示例2: test_analize_object_for_watchers_adding_owner_non_empty_comment
def test_analize_object_for_watchers_adding_owner_non_empty_comment():
user1 = f.UserFactory.create()
issue = MagicMock()
issue.description = "Foo"
issue.content = ""
history = MagicMock()
history.comment = "Comment"
history.owner = user1
services.analize_object_for_watchers(issue, history.comment, history.owner)
assert issue.add_watcher.call_count == 1
示例3: test_analize_object_for_watchers
def test_analize_object_for_watchers():
user1 = f.UserFactory.create()
user2 = f.UserFactory.create()
issue = MagicMock()
issue.description = "Foo @{0} @{1} ".format(user1.username, user2.username)
issue.content = ""
history = MagicMock()
history.comment = ""
services.analize_object_for_watchers(issue, history.comment, history.owner)
assert issue.add_watcher.call_count == 2
示例4: _create_wiki_page_when_create_wiki_link_if_not_exist
def _create_wiki_page_when_create_wiki_link_if_not_exist(self, request, wiki_link):
try:
self.check_permissions(request, "create_wiki_page", wiki_link)
except exc.PermissionDenied:
# Create only the wiki link because the user doesn't have permission.
pass
else:
# Create the wiki link and the wiki page if not exist.
wiki_page, created = models.WikiPage.objects.get_or_create(
slug=wiki_link.href,
project=wiki_link.project,
defaults={"owner": self.request.user, "last_modifier": self.request.user})
if created:
# Creaste the new history entre, sSet watcher for the new wiki page
# and send notifications about the new page created
history = take_snapshot(wiki_page, user=self.request.user)
analize_object_for_watchers(wiki_page, history.comment, history.owner)
send_notifications(wiki_page, history=history)
示例5: persist_history_snapshot
def persist_history_snapshot(self, obj=None, delete: bool = False):
"""
Shortcut for resources with special save/persist
logic.
"""
user = self.request.user
comment = self.request.DATA.get("comment", "")
if obj is None:
obj = self.get_object()
sobj = self.get_object_for_snapshot(obj)
if sobj != obj and delete:
delete = False
notifications_services.analize_object_for_watchers(obj, comment, user)
self.__last_history = take_snapshot(sobj, comment=comment, user=user, delete=delete)
self.__object_saved = True