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


Python notify.send函数代码示例

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


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

示例1: jobrequest_delete

def jobrequest_delete(sender,**kwargs):
    jobrequest=kwargs['instance']
    job = jobrequest.job
    # notify users of changed JobRequest
    notify.send(job.creator,
                verb="deleted {0}".format(jobrequest),
                recipient=jobrequest.organization.group)
开发者ID:purdue-epics-ims,项目名称:boilerconnect,代码行数:7,代码来源:models.py

示例2: live_tester

def live_tester(request):
    notify.send(sender=request.user, recipient=request.user, verb='you loaded the page')

    return render(request, 'test_live.html', {
        'unread_count': request.user.notifications.unread().count(),
        'notifications': request.user.notifications.all()
    })
开发者ID:aztrock,项目名称:django-notifications,代码行数:7,代码来源:views.py

示例3: add_perms_job

def add_perms_job(sender,**kwargs):
    # check if this post_save signal was generated from a Model create
    job=kwargs['instance']
    if 'created' in kwargs and kwargs['created']:

        # allow creator to view and edit job
        assign_perm('view_job',job.creator,job)
        assign_perm('edit_job',job.creator,job)
        # allow requested orgs to view job
        for org in job.organizations.all():
            assign_perm('view_job',org.group,job)
    else:
        # notify users of changed JobRequest
        if job.closed:
            jobrequests = job.jobrequests_accepted()
        else:
            jobrequests = job.jobrequests_accepted() | job.jobrequests_pending()
        for jobrequest in jobrequests:
            notify.send(job.creator,
                        verb="modified",
                        action_object=jobrequest,
                        recipient=jobrequest.organization.group,
                        url=reverse('organization_dash',
                                    kwargs = {'organization_id':jobrequest.organization.id})+
                                    "?jobrequestID="+str(jobrequest.id)
                        )
开发者ID:purdue-epics-ims,项目名称:boilerconnect,代码行数:26,代码来源:models.py

示例4: event_notify

def event_notify(request, event, verb1, verb2):
	#notify user and committee members
    notify.send(request.user, recipient=request.user, verb=verb1 + ' ', target=event)
    for committee_member in list(User.objects.filter(is_staff=True)):
        #don't norify an attending committee member twice
            if committee_member is not request.user:
                notify.send(request.user, recipient=committee_member, verb= ' ' + verb2 + ' ', target=event)
开发者ID:ryanmac666,项目名称:IFB299-Team-Repo,代码行数:7,代码来源:utils.py

示例5: post

 def post(self, *args, **kwargs):
     form = self.get_form()
     if form.is_valid():
         parent_id = self.request.POST.get("parent_id")
         parent_comment = None
         if parent_id:
             try:
                 parent_comment = Comment.objects.get(id=parent_id)
             except:
                 parent_comment = None
         clean_text = form.cleaned_data["text"]
         new_comment = Comment.objects.create_comment(
             user=self.request.user,
             text=clean_text,
             path=self.request.get_full_path(),
             video=self.get_object(),
             parent=parent_comment)
         if parent_comment:
             comment = parent_comment
         else:
             comment = new_comment
         affected_users = comment.get_affected_users()
         notify.send(self.request.user,
                     recipient=comment.user,
                     action=comment,
                     target=new_comment.video,
                     affected_users=affected_users,
                     verb=u'commented',
                     )
         messages.success(self.request, "Thank you for your comment")
         return HttpResponseRedirect(self.get_object().get_absolute_url())
     else:
         messages.error(self.request, "There was an error")
         return HttpResponseRedirect(self.get_object().get_absolute_url())
开发者ID:LABETE,项目名称:srvup,代码行数:34,代码来源:views.py

示例6: copy

def copy(request, id):
    new_ann = get_object_or_404(Announcement, pk=id)
    new_ann.pk = None # autogen a new primary key (quest_id by default)
    new_ann.title = "Copy of " + new_ann.title

    form = AnnouncementForm(request.POST or None, instance = new_ann)
    if form.is_valid():
        new_announcement = form.save(commit=False)
        new_announcement.author = request.user
        new_announcement.datetime_created = timezone.now
        new_announcement.save()
        form.save()

        affected_users = User.objects.all().filter(is_active=True)
        notify.send(
            request.user,
            action=new_announcement,
            target=new_announcement,
            recipient=request.user,
            affected_users=affected_users,
            verb='posted')
        # return redirect('announcements:list', id=new_announcement.id)
        return redirect(new_announcement)
    context = {
        "title": "",
        "heading": "Copy an Announcement",
        "form": form,
        "submit_btn_value": "Create",
    }
    return render(request, "announcements/form.html", context)
开发者ID:kinglyduck,项目名称:hackerspace,代码行数:30,代码来源:views.py

示例7: new_user_receiver

def new_user_receiver(sender,instance,created,*args, **kwargs):
    if created:
        new_profile, is_created = UserProfile.objects.get_or_create(user=instance)
        print new_profile, is_created
        notify.send(instance, 
                    recipient=MyUser.objects.get(username="climberwb"),
                    verb="New User created")
开发者ID:climberwb,项目名称:video-membership,代码行数:7,代码来源:models.py

示例8: confirm

 def confirm(self):
     self.declined = False
     self.accepted = True
     self.confirmed = True
     self.save()
     notify.send(self.organization,
                 verb="confirmed",
                 action_object=self.job,
                 recipient=self.organization.group,
                 url=reverse('organization_dash',
                             kwargs={'organization_id': self.organization.id}) +
                             "?jobrequestID=" + str(self.id)
                 )
     # iterate through all jobrequests in this job and remove permission
     # for other jobrequests
     job = self.job
     job.closed = True
     job.save()
     for jr in job.jobrequests.all():
         if jr != self:
             remove_perm('view_jobrequest',jr.job.creator,jr)
             remove_perm('view_jobrequest',jr.organization.group,jr)
             notify.send(self.organization,
                     verb="has closed the job: ",
                         action_object=self.job,
                         recipient=jr.organization.group,
                         # questionable use of url since user will not have permission to view anymore
                         # url=reverse('organization_dash',
                         #            kwargs={'organization_id': jr.organization.id}) +
                         #            "?jobrequestID=" + str(jr.id)
                         )
开发者ID:purdue-epics-ims,项目名称:boilerconnect,代码行数:31,代码来源:models.py

示例9: register

def register(request):
    '''注册视图'''
    form = RegisterForm()
    if request.method == "POST":
        form = RegisterForm(request.POST.copy())
        if form.is_valid():
            username = form.cleaned_data["username"]
            email = form.cleaned_data["email"]
            password = form.cleaned_data["password"]
            re_password = form.cleaned_data["re_password"]
            real_name = form.cleaned_data["real_name"]
            if password == re_password:
                user = User.objects.create_user(username, email, password)
                user.is_staff = 0
                user.first_name=real_name
                user.save()
                try:
                    custom = Custom(user=user, is_custom = True)
                    custom.save()
                except IntegrityError:
                    last_user = User.objects.all().order_by('-id')[0]
                    last_user.delete()

                notify.send(User.objects.get(id=1),recipient=user, verb='register successfully!')

                _login(request, username, password)
                return HttpResponse('<script>alert("注册成功!");location.replace(document.referrer);;</script>')
            else:
                return HttpResponse('<script>alert("两次密码必须相同!");history.go(-1);</script>')
        else:
            reverse_lazy('404')
    else:
        reverse_lazy('501')

    return render_to_response("custom-register.html", locals(), context_instance = RequestContext(request))
开发者ID:zhwei,项目名称:qipei,代码行数:35,代码来源:views.py

示例10: groups_member_abort

def groups_member_abort(request, pk):
    """
    This API used to allow user to abort the specific Groups in the system. (API version 1)

    * Requires token authentication.
    """

    if request.method == 'POST':
        group = get_object_or_404(Group, id=pk)
        group.members.remove(request.user)
        group.save()
        # send action to action stream
        action.send(request.user, verb="aborted", target=group)
        notify.send(
            request.user,
            recipient=group.creator,
            verb=u'has aborted from your Group',
            level='success')

        return Response({
            "code": status.HTTP_202_ACCEPTED,
            "status": "ok",
            },
            status=status.HTTP_202_ACCEPTED)
    else:
        return Response({
            "code": status.HTTP_400_BAD_REQUEST,
            "status": "error"
            },
            status=status.HTTP_400_BAD_REQUEST)
开发者ID:edXPDRLab,项目名称:CommonRepo,代码行数:30,代码来源:views.py

示例11: follow_group

def follow_group(request, pk):
    """
    Creates the follow relationship between ``request.user`` and the ``Group``
    """
    group = get_object_or_404(Group, id=pk)

    # Check user is not member of the group
    if not group.members.filter(id=request.user.id).exists():
        actions.follow(request.user, group, send_action=True)
        notify.send(
            request.user,
            recipient=group.creator,
            verb=u'has followed your Group',
            level='success')
        request.user.userprofile.follow_groups.add(group)
        messages.success(
            request,
            'Successed, you are now following this Group.')
    else:
        actions.follow(request.user, group, send_action=False)
        messages.success(
            request,
            'You are the member of this Group and automatically become the follower.')

    return redirect('groups:groups-detail', pk)
开发者ID:edXPDRLab,项目名称:CommonRepo,代码行数:25,代码来源:views.py

示例12: atwho

def atwho(text, sender, targetcomment, targetarticle, targetopic , targetproducts):
	commmentdecode = text.decode("utf8")
	pattern = re.compile(u'@([\u4e00-\u9fa5\w\-]+)') 
	results =  pattern.findall(commmentdecode) #用正则把评论中有@的字符串分割开
	userlist = []
	for item in results:
		try:
			user = MyUser.objects.get(username = item.encode('utf8'))
		except:
			user = None
		if user:
			user = MyUser.objects.get(username = item.encode('utf8'))
			notify.send(sender=sender, target_object=targetcomment
					, recipient = user, verb="@"
					, text=text, target_article = targetarticle
					, target_products = targetproducts
					, target_topic = targetopic)
			cachekey = "user_unread_count" + str(user.id)
			if cache.get(cachekey) != None:
				cache.incr(cachekey)
			else:
				unread = Notification.objects.filter(recipient = user).filter(read = False).count()
				cache.set(cachekey,  unread, settings.CACHE_EXPIRETIME)
			userlist.append(item.encode('utf8'))
	return userlist
开发者ID:kij8323,项目名称:mynewspaper,代码行数:25,代码来源:atwho.py

示例13: suggestion_create

def suggestion_create(request):
    template_name='suggestions/suggestion_form.html'
    form = SuggestionForm(request.POST or None)
    if form.is_valid():
        new_suggestion = form.save(commit=False)
        new_suggestion.user = request.user
        new_suggestion.status_timestamp = timezone.now()
        new_suggestion.save()

        icon="<i class='fa fa-lg fa-fw fa-lightbulb-o'></i>"

        notify.send(
            request.user,
            # action=profile.user,
            target= new_suggestion,
            recipient=request.user,
            affected_users=User.objects.filter(is_staff=True),
            verb='suggested:',
            icon=icon,
        )

        messages.success(request, "Thank you for your suggestion! Mr C \
            has to it review before it will be publicly visible.")

        return redirect(new_suggestion.get_absolute_url())

    return render(request, template_name, {'form':form})
开发者ID:alexmerser,项目名称:hackerspace,代码行数:27,代码来源:views.py

示例14: suggestion_approve

def suggestion_approve(request, id):
    suggestion = get_object_or_404(Suggestion, id=id)
    suggestion.status = Suggestion.APPROVED
    suggestion.status_timestamp = timezone.now()
    suggestion.save()

    icon="<span class='fa-stack'>" + \
        "<i class='fa fa-lightbulb-o fa-stack-1x'></i>" + \
        "<i class='fa fa-check fa-stack-2x text-success'></i>" + \
        "</span>"

    suggestion_badge = get_object_or_404(Badge, name="Human Baby")
    grant_badge(request, suggestion_badge.id ,suggestion.user.id)

    notify.send(
        request.user,
        # action=profile.user,
        target= suggestion,
        recipient=suggestion.user,
        affected_users=[suggestion.user,],
        verb='approved',
        icon=icon,
    )
    messages.success(request, "Suggestion by " +  str(suggestion.user) + " approved.")

    return redirect(suggestion.get_absolute_url())
开发者ID:alexmerser,项目名称:hackerspace,代码行数:26,代码来源:views.py

示例15: suggestion_approve

def suggestion_approve(request, id):
    suggestion = get_object_or_404(Suggestion, id=id)
    # Todo move this into the model, not view!
    suggestion.status = Suggestion.APPROVED
    suggestion.status_timestamp = timezone.now()
    suggestion.save()

    icon = "<span class='fa-stack'>" + \
           "<i class='fa fa-lightbulb-o fa-stack-1x'></i>" + \
           "<i class='fa fa-check fa-stack-2x text-success'></i>" + \
           "</span>"

    # TODO don't hardcode this, put it in the settings!
    suggestion_badge = get_object_or_404(Badge, pk=config.hs_suggestion_badge)
    grant_badge(request, suggestion_badge.id, suggestion.user.id)

    notify.send(
        request.user,
        # action=profile.user,
        target=suggestion,
        recipient=suggestion.user,
        affected_users=[suggestion.user, ],
        verb='approved',
        icon=icon,
    )
    messages.success(request, "Suggestion by " + str(suggestion.user) + " approved.")

    return redirect(suggestion.get_absolute_url())
开发者ID:timberline-secondary,项目名称:hackerspace,代码行数:28,代码来源:views.py


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