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


Python Activity.project方法代码示例

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


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

示例1: follow_handler

# 需要导入模块: from activity.models import Activity [as 别名]
# 或者: from activity.models.Activity import project [as 别名]
def follow_handler(sender, **kwargs):
    rel = kwargs.get("instance", None)
    if not isinstance(rel, Relationship):
        return
    user_subject = _("%(name)s is following you on Drumbeat!" % {"name": rel.source.name})
    project_subject = _("%(name)s is following your project on Drumbeat!" % {"name": rel.source.name})
    activity = Activity(actor=rel.source, verb="http://activitystrea.ms/schema/1.0/follow")
    subject = _(u"%(name)s is now following")
    if rel.target_user:
        activity.target_user = rel.target_user
        user = rel.target_user
        pref_key = "no_email_new_follower"
        subject = user_subject
    else:
        activity.project = rel.target_project
        user = rel.target_project.created_by
        pref_key = "no_email_new_project_follower"
        subject = project_subject
    activity.save()

    preferences = AccountPreferences.objects.filter(user=user)
    for pref in preferences:
        if pref.value and pref.key == pref_key:
            return

    body = render_to_string(
        "relationships/emails/new_follower.txt", {"user": rel.source, "project": rel.target_project}
    )
    SendUserEmail.apply_async((user, subject, body))
开发者ID:rossbruniges,项目名称:batucada,代码行数:31,代码来源:models.py

示例2: follow_handler

# 需要导入模块: from activity.models import Activity [as 别名]
# 或者: from activity.models.Activity import project [as 别名]
def follow_handler(sender, **kwargs):
    rel = kwargs.get('instance', None)
    created = kwargs.get('created', False)
    if not created or not isinstance(rel, Relationship):
        return
    activity = Activity(actor=rel.source,
                        verb='http://activitystrea.ms/schema/1.0/follow')
    receipts = []
    ulang=get_language()
    subject = {}
    body = {}
    if rel.target_user:
        activity.target_user = rel.target_user
        for l in settings.SUPPORTED_LANGUAGES:
            activate(l[0])
            subject[l[0]] = ugettext('%(display_name)s is following you on P2PU!') % {
                'display_name': rel.source.display_name,
            }
        preferences = AccountPreferences.objects.filter(user=rel.target_user)
        for pref in preferences:
            if pref.value and pref.key == 'no_email_new_follower':
                break
        else:
            receipts.append(rel.target_user)
    else:
        activity.project = rel.target_project
        for l in settings.SUPPORTED_LANGUAGES:
            activate(l[0])
            subject[l[0]] = ugettext('%(display_name)s is following %(project)s on P2PU!') % {
                'display_name': rel.source.display_name, 'project': rel.target_project }
        for organizer in rel.target_project.organizers():
            if organizer.user != rel.source:
                preferences = AccountPreferences.objects.filter(user=organizer.user)
                for pref in preferences:
                    if pref.value and pref.key == 'no_email_new_project_follower':
                        break
                else:
                    receipts.append(organizer.user)   
    activity.save()

    for l in settings.SUPPORTED_LANGUAGES:
        activate(l[0])
        body[l[0]] = render_to_string("relationships/emails/new_follower.txt", {
            'user': rel.source,
            'project': rel.target_project,
            'domain': Site.objects.get_current().domain,
            })
    activate(ulang)
    for user in receipts:
        pl = user.preflang or settings.LANGUAGE_CODE
        SendUserEmail.apply_async((user, subject[pl], body[pl]))
开发者ID:MJae,项目名称:lernanta,代码行数:53,代码来源:models.py

示例3: follow_handler

# 需要导入模块: from activity.models import Activity [as 别名]
# 或者: from activity.models.Activity import project [as 别名]
def follow_handler(sender, **kwargs):
    rel = kwargs.get('instance', None)
    created = kwargs.get('created', False)
    if not created or not isinstance(rel, Relationship):
        return
    user_subject = ugettext('%(display_name)s is following you on P2PU!') % {
        'display_name': rel.source.display_name,
    }
    project_subject = ugettext('%(display_name)s is following %(project)s on P2PU!') % {
        'display_name': rel.source.display_name,
        'project': rel.target_project,
    }
    activity = Activity(actor=rel.source,
                        verb='http://activitystrea.ms/schema/1.0/follow')
    subject = ugettext('%(display_name)s is now following')
    if rel.target_user:
        activity.target_user = rel.target_user
        user = rel.target_user
        pref_key = 'no_email_new_follower'
        subject = user_subject
    else:
        activity.project = rel.target_project
        user = rel.target_project.created_by
        pref_key = 'no_email_new_project_follower'
        subject = project_subject
    activity.save()

    preferences = AccountPreferences.objects.filter(user=user)
    for pref in preferences:
        if pref.value and pref.key == pref_key:
            return

    body = render_to_string("relationships/emails/new_follower.txt", {
        'user': rel.source,
        'project': rel.target_project,
        'domain': Site.objects.get_current().domain,
    })
    SendUserEmail.apply_async((user, subject, body))
开发者ID:AndyHendy,项目名称:lernanta,代码行数:40,代码来源:models.py


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