当前位置: 首页>>代码示例>>Python>>正文


Python Activity.target_project方法代码示例

本文整理汇总了Python中activity.models.Activity.target_project方法的典型用法代码示例。如果您正苦于以下问题:Python Activity.target_project方法的具体用法?Python Activity.target_project怎么用?Python Activity.target_project使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在activity.models.Activity的用法示例。


在下文中一共展示了Activity.target_project方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: fire_activity

# 需要导入模块: from activity.models import Activity [as 别名]
# 或者: from activity.models.Activity import target_project [as 别名]
def fire_activity(sender, **kwargs):
    instance = kwargs.get('instance', None)
    created = kwargs.get('created', False)
    
    is_page = isinstance(instance, Page)
    is_comment = isinstance(instance, PageComment)
    if created and (is_page or is_comment):
        # Send notification.
        if is_comment and instance.page.slug == 'sign-up':
            instance.send_sign_up_notification()
            return
        else:
            send_content_notification(instance, is_comment)
        # Fire activity.
        activity = Activity(
            actor=instance.author,
            verb='http://activitystrea.ms/schema/1.0/post',
            target_object=instance,
        )
        activity.target_project = instance.project
        activity.save()
    elif not created and is_page and instance.publish:
        if instance.deleted:
            verb = 'http://activitystrea.ms/schema/1.0/delete'
        else:
            verb = 'http://activitystrea.ms/schema/1.0/update'
        activity = Activity(
            actor=instance.author,
            verb=verb,
            target_object=instance,
        )
        activity.target_project = instance.project
        activity.save()
开发者ID:foxtrotcharlie,项目名称:lernanta,代码行数:35,代码来源:models.py

示例2: create_activity_entry

# 需要导入模块: from activity.models import Activity [as 别名]
# 或者: from activity.models.Activity import target_project [as 别名]
 def create_activity_entry(self, entry, sender, activity_prefix=None):
     """Create activity feed entries for the provided feed entry."""
     verb, object_type = None, None
     if activity_prefix:
         verb = self.get_namespaced_attr(
             entry, activity_prefix, 'verb')
         object_type = self.get_namespaced_attr(
             entry, activity_prefix, 'object-type')
     if not verb:
         verb = 'http://activitystrea.ms/schema/1.0/post'
     if not object_type:
         object_type = 'http://activitystrea.ms/schema/1.0/article'
     title = getattr(entry, 'title', None)
     uri = getattr(entry, 'link', None)
     if not (title and uri):
         return
     for link in sender.link_set.all():
         remote_obj = RemoteObject(
             link=link, title=title, uri=uri, object_type=object_type)
         remote_obj.save()
         activity = Activity(
             actor=link.user, verb=verb, remote_object=remote_obj)
         if link.project:
             activity.target_project = link.project
         activity.save()
开发者ID:phastafrican,项目名称:lernanta,代码行数:27,代码来源:tasks.py

示例3: status_creation_handler

# 需要导入模块: from activity.models import Activity [as 别名]
# 或者: from activity.models.Activity import target_project [as 别名]
def status_creation_handler(sender, **kwargs):
    status = kwargs.get('instance', None)
    created = kwargs.get('created', False)

    if not created or not isinstance(status, Status):
        return

    # convert status body to markdown and bleachify
    bl = Bleach()
    status.status = urlize(status.status)
    status.status = bl.clean(markdown(status.status), tags=TAGS)
    status.save()

    # fire activity
    activity = Activity(
        actor=status.author,
        verb='http://activitystrea.ms/schema/1.0/post',
        status=status,
    )
    if status.project:
        activity.target_project = status.project
    activity.save()
    # Send notifications.
    if activity.target_project:
        activity.target_project.send_update_notification(activity)
开发者ID:Suggsgested,项目名称:lernanta,代码行数:27,代码来源:models.py

示例4: status_creation_handler

# 需要导入模块: from activity.models import Activity [as 别名]
# 或者: from activity.models.Activity import target_project [as 别名]
def status_creation_handler(sender, **kwargs):
    status = kwargs.get('instance', None)
    created = kwargs.get('created', False)

    if not created or not isinstance(status, Status):
        return

    # clean html
    status.status = bleach.clean(status.status, tags=settings.REDUCED_ALLOWED_TAGS, attributes=settings.REDUCED_ALLOWED_ATTRIBUTES, strip=True)
    status.save()

    # fire activity
    activity = Activity(
        actor=status.author,
        verb='http://activitystrea.ms/schema/1.0/post',
        status=status,
    )
    if status.project:
        activity.target_project = status.project
    if status.in_reply_to:
        activity.parent = status.in_reply_to
    activity.save()
    # Send notifications.
    if status.project:
        status.send_wall_notification()
开发者ID:MJae,项目名称:lernanta,代码行数:27,代码来源:models.py

示例5: fire_activity

# 需要导入模块: from activity.models import Activity [as 别名]
# 或者: from activity.models.Activity import target_project [as 别名]
def fire_activity(sender, **kwargs):
    instance = kwargs.get('instance', None)
    created = kwargs.get('created', False)

    is_page = isinstance(instance, Page)
    is_comment = isinstance(instance, PageComment)
    if created and (is_page or is_comment):
        # Do not fire activities for comments on the sign-up page.
        if is_comment and instance.page.slug == 'sign-up':
            instance.send_sign_up_notification()
            return
        # fire activity
        activity = Activity(
            actor=instance.author,
            verb='http://activitystrea.ms/schema/1.0/post',
            target_object=instance,
        )
        activity.target_project = instance.project
        activity.save()
        # Send notifications.
        activity.target_project.send_update_notification(activity, wall=False)
开发者ID:Suggsgested,项目名称:lernanta,代码行数:23,代码来源:models.py

示例6: todo_creation_handler

# 需要导入模块: from activity.models import Activity [as 别名]
# 或者: from activity.models.Activity import target_project [as 别名]
def todo_creation_handler(sender, **kwargs):
    todo = kwargs.get('instance', None)
    created = kwargs.get('created', False)

    if not created or not isinstance(todo, Todo):
        return

    # convert todo body to markdown and bleachify
    bl = Bleach()
    todo.title = urlize(todo.title)
    todo.description = urlize(todo.description)
    todo.title = bl.clean(markdown(todo.title), tags=TAGS)
    todo.description = bl.clean(markdown(todo.description), tags=TAGS)
    todo.save()

    # fire activity
    activity = Activity(
        actor=todo.author,
        verb='http://activitystrea.ms/schema/1.0/post',
        target_todo=todo,
    )
    if todo.project:
        activity.target_project = todo.project
    activity.save()
开发者ID:phastafrican,项目名称:lernanta,代码行数:26,代码来源:models.py


注:本文中的activity.models.Activity.target_project方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。