• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python notify.send函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: add_developer

def add_developer(request):
    form = UserProfileForm()
    
    if request.method == 'POST':
        form = UserProfileForm(request.POST)
        if form.is_valid():
			#user_profile = form.save()
			data = form.cleaned_data
			site = Site.objects.get_current()
			new_user = RegistrationProfile.objects.create_inactive_user(data['username'] , data['email'],data['password'], site , send_email = False)
			userprofileobj = UserProfile(user = new_user, role_id=11, displayName = data['username'], thumbnailURL= '/static/main/img/user.png ')
			userprofileobj.save()

			s_admins = User.objects.filter(is_superuser = 1)
			for s_admin in s_admins:
				notify.send(new_user, recipient=s_admin, verb='signed_up' )

			return HttpResponseRedirect('/')
    


    return render(request, "userprofiles/registration.html", {
        'form': form, 
        'action' : 'Create'
    })
开发者ID:dithua,项目名称:collato,代码行数:25,代码来源:views.py


示例2: save

    def save(self, note=None):
        instance = self.cleaned_data["pk"]
        workshifter = instance.workshifter or instance.liable
        pool_hours = workshifter.pool_hours.get(pool=instance.pool)

        # Check if the shift was previously verified or marked as blown
        _undo_verify_blown(instance, pool_hours)
        instance.save(update_fields=["blown", "closed"])
        pool_hours.save(update_fields=["standing"])

        instance.logs.add(
            ShiftLogEntry.objects.create(
                person=self.profile,
                entry_type=ShiftLogEntry.UNBLOWN,
                note=note,
            )
        )

        # Notify the workshifter as well as the workshift manager
        targets = []
        if self.profile != instance.workshifter:
            targets.append(instance.workshifter.user)
        for manager in instance.pool.managers.all():
            if manager.incumbent and manager.incumbent.user != self.profile.user:
                targets.append(manager.incumbent.user)
        for target in targets:
            notify.send(
                self.profile.user,
                verb="marked as unblown",
                action_object=instance,
                recipient=target,
            )

        return instance
开发者ID:naderm,项目名称:farnsworth,代码行数:34,代码来源:forms.py


示例3: ajax_send_notification

def ajax_send_notification(request):
    
    pid=int(request.POST['pId'])
    pob=Player.objects.get(pk=pid)
    if pob.pBid==0:
        pob.pBid=pob.pBaseprice+1000000
    else:
        pob.pBid=pob.pBid+1000000

    pob.save()
    recipients = User.objects.all()
    
    

    for recipient in recipients:
        notify.send(
            request.user,
            recipient=recipient,
            verb=pob.pBid
            
            

        )

    return HttpResponse(json.dumps({"success": True}), content_type="application/json")
开发者ID:nsakhala,项目名称:ipl,代码行数:25,代码来源:views.py


示例4: test_disable_timezone

 def test_disable_timezone(self):
     from_user = User.objects.create(username="from2", password="pwd", email="[email protected]")
     to_user = User.objects.create(username="to2", password="pwd", email="[email protected]")
     notify.send(from_user, recipient=to_user, verb='commented', action_object=from_user)
     notification = Notification.objects.get(recipient=to_user)
     delta = timezone.now() - notification.timestamp
     self.assertTrue(delta.seconds < 60)
开发者ID:angebouabre,项目名称:django-notifications,代码行数:7,代码来源:tests.py


示例5: save

    def save(self):
        if not self.instance:
            event = Event(
                owner=self.profile,
                title=self.cleaned_data['title'],
                description=self.cleaned_data['description'],
                location=self.cleaned_data['location'],
                start_time=self.cleaned_data['start_time'],
                end_time=self.cleaned_data['end_time'],
                )
        else:
            self.instance.title = self.cleaned_data['title']
            self.instance.description = self.cleaned_data['description']
            self.instance.location = self.cleaned_data['location']
            self.instance.start_time = self.cleaned_data['start_time']
            self.instance.end_time = self.cleaned_data['end_time']
            self.instance.cancelled = self.cleaned_data['cancelled']
            event = self.instance
        event.save()
        if self.cleaned_data['rsvp'] and \
          self.profile.user.username != ANONYMOUS_USERNAME:
              event.rsvps.add(self.profile)
        as_manager = self.cleaned_data['as_manager']
        if as_manager:
            event.as_manager = as_manager
        else:
            event.as_manager = None
        event.save()

        for profile in event.rsvps.all():
            if profile.user == self.profile.user:
                continue
            notify.send(self.profile.user, verb="updated", action=event,
                        recipient=profile.user)
        return event
开发者ID:bsc-networks,项目名称:farnsworth,代码行数:35,代码来源:forms.py


示例6: delete_game

def delete_game(request):
	if request.method == 'POST':
		game_id = request.POST['game_id']
		g = Game.objects.get(id=game_id)
		verb = request.user.first_name+' '+request.user.last_name+' cancelled '+g.name;
		#action.send(request.user,verb=verb,action_object=g)
		receivers = []
		allUsers = g.users.all()
		if len(allUsers) != 0:
			for user in g.users.all():
				print user
				receivers.append(user.username)
				verb = request.user.first_name+' '+request.user.last_name+' cancelled '+g.name
				notify.send(request.user,recipient=user, verb=verb, description='#')

			game_maker = "%s %s" % (g.creator.first_name, g.creator.last_name)
			msg = "Unfortunately, %s has cancelled %s." % (game_maker, g.name)
			subj = "%s Game Cancellation" % (g.name)
			#send_an_email(receivers,subj,msg)

		msg = g.name + ' (' + g.sport.name + ')' + ' was deleted.'
		g.delete()
		messages.success(request, msg)

	return redirect('/home')
开发者ID:andyxmai,项目名称:pickup,代码行数:25,代码来源:views.py


示例7: save

 def save(self, sender, parent_msg=None):
     recipients = self.cleaned_data['recipient']
     subject = self.cleaned_data['subject']
     body = self.cleaned_data['body']
     message_list = []
     for r in recipients:
         msg = Message(
             sender = sender,
             recipient = r,
             subject = subject,
             body = body,
         )
         if parent_msg is not None:
             msg.parent_msg = parent_msg
             parent_msg.replied_at = datetime.datetime.now()
             parent_msg.save()
         msg.save()
         message_list.append(msg)
         notify.send(sender, url=msg.get_absolute_url(),recipient=r, verb=u'给你发送了一条新私信',)
         if notification:
             if parent_msg is not None:
                 notification.send([sender], "messages_replied", {'message': msg,})
                 notification.send([r], "messages_reply_received", {'message': msg,})
             else:
                 notification.send([sender], "messages_sent", {'message': msg,})
                 notification.send([r], "messages_received", {'message': msg,})
     return message_list
开发者ID:Co-Trip,项目名称:Co-Trip-Server,代码行数:27,代码来源:forms.py


示例8: vote_answer

def vote_answer(request, ans_id):
	"""
	handles the upvoting event, updates the Vote model, and sends notification to User
	"""
	if request.method == 'POST':
		vote = (request.POST.get('vote') == "true")
		answer = Answer.objects.get(pk=ans_id)
		Vote.objects.record_vote(answer, request.user, vote)
		if vote:
			notify.send(request.user, recipient=answer.answered_by, verb=u'upvoted', action_object=answer, target=answer)
		else:
			notification_old = Notification.objects.filter(actor_object_id=request.user.id, verb=u'upvoted', action_object_object_id=ans_id)
			if notification_old:
				notification_old[0].delete()
		response_data = {}
		response_data['updated_vote'] = Vote.objects.get_votes(answer)
		response_data['pk'] = answer.pk
		return HttpResponse(
			json.dumps(response_data),
			content_type="application/json"
		)
	return HttpResponse(
			json.dumps({"nothing to see": "this isn't happening"}),
			content_type="application/json"
		)
开发者ID:reemachugani,项目名称:empyou,代码行数:25,代码来源:views.py


示例9: create_remove_action

def create_remove_action(sender, author, action, instance, **kwargs):
	tipo = ContentType.objects.get_for_model(instance)
	if str(tipo) == 'ActivitieParent':
		objeto = 'una actividad'
	else:
		objeto = 'un quiz'

	for user in User.objects.all():
		if action == 'add':
			
			notify.send(
				author,
				recipient=user,
				verb=u'modificar',
		        #action_object=instance,
		        description='ha creado '+objeto+' , tu progreso se ha recalculado',
		        target=instance
		        )

		elif action == 'remove':
			
			notify.send(
					author,
					recipient=user,
					verb=u'modificar',
			        #action_object=instance,
			        description= 'ha elimidado '+objeto+' , tu progreso se ha recalculado',
			        #target= instance)
					)
开发者ID:degreeworkunivalle,项目名称:Services,代码行数:29,代码来源:receivers.py


示例10: comment_messages

def comment_messages(sender, comment, request, **kwargs):
    """ 添加评论后,增加对应*瓦片*的评论数(冗余字段), 并跳转且作出提示 """
    tile = comment.content_object
    cid = request.REQUEST.get('cid')
    try:
        comment.content_object.after_add_comments()
        tile = comment.content_object
        href = request.REQUEST.get('notify','')
        channel = get_channel(tile)
        if not href:
            href = reverse('axis_tile_view',kwargs={'tile_id': tile.id}) + "?channel=" + channel
    
        #添加一条提醒
        actions = {'title':'新消息','href':href + "#comment_div_" + str(comment.id)}
        
        if tile.creator != request.user:
            notify.send(request.user, verb='新消息', action_object=tile, recipient=tile.creator, actions=actions)
        if cid:
            comment_obj = get_object_or_404(Comment, pk=cid)
            relation = Comment_relation()
            relation.target_object = comment_obj
            relation.action_object = comment
            relation.save()
            if comment_obj.user != request.user:
                notify.send(request.user, verb='新消息', action_object=comment_obj, recipient=comment_obj.user, actions=actions)
    except:
        pass

    if request.user.is_authenticated():
        comment._set_url("http://www." + str(time.mktime(datetime.datetime.now().timetuple())) + ".com")
        comment.save()
开发者ID:nuannuanwu,项目名称:weixiao,代码行数:31,代码来源:revision.py


示例11: test_use_timezone

 def test_use_timezone(self):
     from_user = User.objects.create(username="from", password="pwd", email="[email protected]")
     to_user = User.objects.create(username="to", password="pwd", email="[email protected]")
     notify.send(from_user, recipient=to_user, verb='commented', action_object=from_user)
     notification = Notification.objects.get(recipient=to_user)
     delta = datetime.datetime.utcnow().replace(tzinfo=utc) - notification.timestamp
     self.assertTrue(delta.seconds >= 8 * 60 * 59)
开发者ID:Mondego,项目名称:pyreco,代码行数:7,代码来源:allPythonContent.py


示例12: add_member

    def add_member(self, request, pk=None):
        taskforce = self.get_object()
        
        # Get User object from task force's team members; prevents non team members from being added
        try:
            userId = request.DATA.get('user_id', None)
            user = taskforce.team.users.all().get(id=userId)
        except User.DoesNotExist:
            raise UserNotFound()

        # Check if user is already a member
        if taskforce.members.filter(pk=user.pk).count() > 0:
            raise UserAlreadyInTaskForce()
        
        # Add user to members
        taskforce.members.add(user)

        if user != request.user:
            # Generate notification for added user
            notify.send(request.user,
                recipient=user,
                verb='added',
                action_object=user,
                target=taskforce,
                description='You have been added to a taskforce'
            )
        
        return Response({})
开发者ID:ael1qaz,项目名称:openCPM-static,代码行数:28,代码来源:views.py


示例13: deliver

    def deliver(self, recipient, sender, notice_type, extra_context):

        extra_context.update({
            "recipient": recipient,
            "title": ugettext(notice_type.display),
            "description": ugettext(notice_type.description),
        })

        # context = self.default_context()
        messages = self.get_formatted_messages((
            "notice.html",
            "full.html"
        ), notice_type.label, Context(extra_context))

        extra_context.update({
            'body': messages["notice.html"]
        })

        if not sender:
            sender = recipient

        notify.send(
            sender,
            verb=notice_type.label,
            **extra_context)
开发者ID:Afnarel,项目名称:django-notification,代码行数:25,代码来源:site.py


示例14: join_quit_game

def join_quit_game(request):
	#userID = request.user.id
	response = ''
	if request.method == 'POST': 
		game_id = request.POST['game_id']
		print game_id
		
		game = Game.objects.get(id=game_id)
		if request.user in game.users.all():
			game.users.remove(request.user)
			response = 'left'
			verb = request.user.first_name+' '+request.user.last_name+' left '+game.name
			description = '/game/'+str(game.id)
			notify.send(request.user,recipient=game.creator, verb=verb, description=description)
			action.send(request.user, verb="leave game", action_object=game)
		else:
			game.users.add(request.user)
			response = 'joined'
			verb = request.user.first_name+' '+request.user.last_name+' joined '+game.name
			description = '/game/'+str(game.id)
			notify.send(request.user,recipient=game.creator, verb=verb, description=description)
			action.send(request.user, verb="join game", action_object=game)
	
	#return HttpResponse(response)
	return redirect(request.META['HTTP_REFERER'])
开发者ID:andyxmai,项目名称:pickup,代码行数:25,代码来源:views.py


示例15: add_attendee

    def add_attendee(self, request, pk=None):
        event = self.get_object()
        
        # Get attendee User object
        try:
            userId = request.DATA.get('user_id', None)
            user = User.objects.get(id=userId)
        except User.DoesNotExist:
            raise UserNotFound()
        
        # Create EventAttendee object
        try:
            EventAttendee.objects.create(
                event=event,
                user=user
            )
        except IntegrityError:
            raise EventAlreadyHasAttendee()

        if user != request.user:
            # Generate notification for added user
            notify.send(request.user,
                recipient=user,
                verb='invited',
                action_object=user,
                target=event,
                description='You have been invited to an event'
            )
        
        return Response({})
开发者ID:ael1qaz,项目名称:openCPM-static,代码行数:30,代码来源:EventViewSet.py


示例16: comment

def comment(request):
	if request.method == 'POST':
		#store comment
		comment_form = CommentForm(request.POST)
		if comment_form.is_valid():
			text = comment_form.cleaned_data['text']
			user_id = comment_form.cleaned_data['user_id']
			game_id = comment_form.cleaned_data['game_id']

			commenter = User.objects.get(id=user_id)
			game = Game.objects.get(id=game_id)

			comment = Comment.objects.create(text=text, commenter=commenter, game=game, timeStamp=datetime.datetime.now() - datetime.timedelta(hours=7))

			for player in game.users.all():
				if commenter != player:
					verb = commenter.first_name+' '+commenter.last_name+' left a comment for '+game.name
					description = '/game/'+str(game.id)
					notify.send(commenter,recipient=player, verb=verb, description=description)

			return redirect('/game/'+str(game.id))
		else:
			return redirect('/')
	else:
		return redirect('/')
开发者ID:andyxmai,项目名称:pickup,代码行数:25,代码来源:views.py


示例17: test_use_timezone

 def test_use_timezone(self):
     from_user = User.objects.create(username="from", password="pwd", email="[email protected]")
     to_user = User.objects.create(username="to", password="pwd", email="[email protected]")
     notify.send(from_user, recipient=to_user, verb='commented', action_object=from_user)
     notification = Notification.objects.get(recipient=to_user)
     delta = timezone.now().replace(tzinfo=utc) - localtime(notification.timestamp,pytz.timezone(settings.TIME_ZONE))
     self.assertTrue(delta.seconds < 60)
开发者ID:angebouabre,项目名称:django-notifications,代码行数:7,代码来源:tests.py


示例18: user_bookmarks

def user_bookmarks(request, pk, format=None):
    check_object_permissions(request, user_bookmarks.cls.permission_classes, User.objects.get(pk=pk))
    if request.method == 'GET':
	serializer = BookmarkSerializer(request.user, context={request: request}) 
	return Response(serializer.data)
    elif request.method == 'PUT':
	bookmarks = request.DATA.get('bookmarks')
	request.user.bookmarks.add(*bookmarks)
	serializer = BookmarkSerializer(request.user)

	# Add notification.
	for bookmark in bookmarks:
	    try:
		bookmarked = Composition.objects.get(pk=bookmark)
		if request.user != bookmarked.artist:
		    notify.send(request.user, recipient=bookmarked.artist, verb='added to his collection', action_object=bookmarked)
	    except Composition.DoesNotExist:
		# No such user, skip notification.
		pass
	return Response(serializer.data)
    elif request.method == 'POST':
	bookmarks = request.DATA['bookmarks']
	request.user.bookmarks.remove(*bookmarks)
	serializer = BookmarkSerializer(request.user)
	return Response(serializer.data)
开发者ID:hobbes09,项目名称:ShowCase,代码行数:25,代码来源:views.py


示例19: 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:aman-iitj,项目名称:Event-Management-System,代码行数:7,代码来源:views.py


示例20: user_follows

def user_follows(request, pk, format=None):
    check_object_permissions(request, user_follows.cls.permission_classes, User.objects.get(pk=pk))
    if request.method == 'GET':
	serializer = FollowSerializer(request.user, context={request: request}) 
	return Response(serializer.data)
    elif request.method == 'PUT':
	follows = request.DATA.get('follows')
	request.user.follows.add(*follows)
	serializer = FollowSerializer(request.user)

	# TODO add notification.
	for follow in follows:
	    try:
		followed = User.objects.get(pk=follow)
		if request.user != followed:
		    notify.send(request.user, recipient=followed, verb='followed you.')
	    except User.DoesNotExist:
		# No such user, skip notification.
		pass

	return Response(serializer.data)
    elif request.method == 'POST':
	follows = request.DATA['follows']
	request.user.follows.remove(*follows)
	serializer = FollowSerializer(request.user)
	return Response(serializer.data)
开发者ID:hobbes09,项目名称:ShowCase,代码行数:26,代码来源:views.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python notify.send函数代码示例发布时间:2022-05-27
下一篇:
Python models.Notification类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap