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


Python action.send函数代码示例

本文整理汇总了Python中nnmware.core.signals.action.send函数的典型用法代码示例。如果您正苦于以下问题:Python send函数的具体用法?Python send怎么用?Python send使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: form_valid

 def form_valid(self, form):
     link = form.cleaned_data.get('video_url')
     consumer = oembed.OEmbedConsumer(link)
     result = consumer.result()
     obj = Video()
     obj.embedcode = result['html']
     obj.thumbnail = image_from_url(result['thumbnail_url'])
     if 'duration' in result:
         obj.duration = result['duration']
     obj.user = self.request.user
     obj.project_name = form.cleaned_data.get('project_name')
     obj.project_url = form.cleaned_data.get('project_url')
     obj.video_provider = get_video_provider_from_link(form.cleaned_data.get('video_url'))
     obj.publish = True
     obj.description = form.cleaned_data.get('description')
     obj.video_url = link
     obj.save()
     obj.slug = gen_shortcut(obj.id)
     tags = form.cleaned_data.get('tags')
     alltags = Tag.objects.all().filter(name__in=tags)
     for tag in tags:
         obj.tags.add(alltags.get(name=tag))
         obj.save()
     self.success_url = obj.get_absolute_url()
     action.send(self.request.user, verb=_('added the video'), action_type=ACTION_ADDED, target=obj,
                 request=self.request)
     return super(VideoAdd, self).form_valid(form)
开发者ID:biomassives,项目名称:nnmware,代码行数:27,代码来源:views.py

示例2: push_user

def push_user(request, object_id):
    # Link used for User press button in user panel
    try:
        user = settings.AUTH_USER_MODEL.objects.get(id=object_id)
        if request.user == user:
            raise AccessError
        ctype = ContentType.objects.get_for_model(settings.AUTH_USER_MODEL)
        status = False
        if Follow.objects.filter(user=request.user,content_type=ctype,object_id=object_id).count():
            unfollow(request.user, user)
            action.send(request.user, verb=_('unfollow the user'), target=user)
            if request.user.get_profile().followers_count:
                for u in settings.AUTH_USER_MODEL.objects.filter(pk__in=request.user.get_profile().followers):
                    notice.send(request.user, user=u, verb=_('now unfollow'), target=user)
        else:
            follow(request.user, user)
            status = True
            action.send(request.user, verb=_('follow the user'), target=user)
            if request.user.get_profile().followers_count:
                for u in settings.AUTH_USER_MODEL.objects.filter(pk__in=request.user.get_profile().followers):
                    if u.follow_set.filter(content_type=ctype, object_id=user.pk).count:
                        notice.send(request.user, user=u, verb=_('also now follow'), target=user)
                    else:
                        notice.send(request.user, user=u, verb=_('now follow'), target=user)
        result = Follow.objects.filter(content_type=ctype, object_id=object_id).count()
        payload = {'success': True, 'count': result, 'id': user.pk, 'status':status}
    except AccessError:
        payload = {'success': False}
    except :
        payload = {'success': False}
    return AjaxLazyAnswer(payload)
开发者ID:ksenor,项目名称:nnmware,代码行数:31,代码来源:views.py

示例3: comment_add

def comment_add(request, content_type, object_id, parent_id=None):
    """
    Its Ajax posted comments
    """
    try:
        if not request.user.is_authenticated():
            raise AccessError
        comment = JComment()
        comment.user = request.user
        comment.content_type = get_object_or_404(ContentType, id=int(content_type))
        comment.object_id = int(object_id)
        comment.ip = request.META['REMOTE_ADDR']
        comment.user_agent = request.META['HTTP_USER_AGENT']
        comment.comment = request.REQUEST['comment']
        if not len(comment.comment):
            raise AccessError
        kwargs={'content_type': content_type, 'object_id': object_id}
        if parent_id is not None:
            comment.parent_id = int(parent_id)
        comment.save()
        action.send(request.user, verb=_('commented'), action_type=ACTION_COMMENTED,
            description= comment.comment, target=comment.content_object, request=request)
        avatar_id = False
        kwargs['parent_id'] = comment.pk
        reply_link = reverse("jcomment_parent_add", kwargs=kwargs)
        comment_text = linebreaksbr(comment.comment)
        comment_date = comment.created_date.strftime(settings.COMMENT_DATE_FORMAT)
        try:
            avatar_id = comment.user.avatar.pk
        except :
            pass
        payload = {'success': True, 'id':comment.pk, 'username':comment.user.get_name,
                   'username_url':comment.get_absolute_url(),
                   'comment':comment_text, 'avatar_id':avatar_id,
                   'comment_date': comment_date, 'reply_link':reply_link,
                   'object_comments':comment.content_object.comments }
    except AccessError:
        payload = {'success': False, 'error':_('You are not allowed for add comment')}
    except :
        payload = {'success': False}
    return AjaxLazyAnswer(payload)
开发者ID:MrTomato8,项目名称:nnmware,代码行数:41,代码来源:ajax.py

示例4: form_valid

 def form_valid(self, form):
     link = form.cleaned_data.get('video_url')
     if not link[:7] == 'http://':
         link = 'http://%s' % link
     if link.find('youtu.be') != -1:
         link = link.replace('youtu.be/','www.youtube.com/watch?v=')
     consumer = oembed.OEmbedConsumer()
     # TODO: more code security here - big chance to get fatal error
     endpoint = get_oembed_end_point(link)
     #
     consumer.addEndpoint(endpoint)
     response = consumer.embed(link)
     result = response.getData()
     obj = Video()
     obj.embedcode = result['html']
     obj.thumbnail = image_from_url(result['thumbnail_url'])
     if result.has_key('duration'):
         obj.duration = result['duration']
     obj.user = self.request.user
     obj.project_name = form.cleaned_data.get('project_name')
     obj.project_url = form.cleaned_data.get('project_url')
     obj.video_provider = get_video_provider_from_link(form.cleaned_data.get('video_url'))
     obj.publish = True
     obj.description = form.cleaned_data.get('description')
     obj.video_url = link
     obj.save()
     obj.slug = gen_shortcut(obj.id)
     tags = form.cleaned_data.get('tags')
     alltags = Tag.objects.all().filter(name__in=tags)
     for tag in tags:
         obj.tags.add(alltags.get(name=tag))
         obj.save()
     self.success_url = obj.get_absolute_url()
     action.send(self.request.user, verb=_('added the video'), action_type=ACTION_ADDED, target=obj,
         request=self.request)
     return super(VideoAdd, self).form_valid(form)
开发者ID:ir4y,项目名称:nnmware,代码行数:36,代码来源:views.py


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