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

Python models.Notification类代码示例

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

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



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

示例1: add_friend

def add_friend(request):
	if not request.user.is_authenticated():
		return redirect(gethome())
	if request.method != 'POST':
		return redirect(gethome())
	else:			
		print "HELLO I AM AT AN AJAX CALL AT FRIENDS.VIEW.add_friend-----------------------------------------------------"
		print request.POST
		if "user2" in request.POST:
			user2_id = request.POST["user2"] 
			Profile2_object = Profile.objects.filter(id=user2_id)
			user2 = Profile2_object[0].user
			user1 = request.user #user who clicked add friend ==> userFrom

			message = Profile2_object[0].first_name + " " + Profile2_object[0].last_name + " wants to be friends with you"
			if checkFriendExisted(user1,user2) == True:
				return redirect(gethome())
			#-------------BETA-------------------------------------#
			user2_uuid = Profile2_object[0].id
			user1_uuid = Profile.objects.filter(user=user1)[0].id
			#-------------BETA-------------------------------------#
			friend_object = Friends(user1=user1,user2=user2,status = "P",user1_uuid=user1_uuid,user2_uuid=user2_uuid)
			friend_object.save()
			if(checkNotificationExisted(user1,user2,"F") == False):
				notification_object = Notification( user1=user1,
													user2=user2,
													message=message,
													read=False,
													notification_type="FR",
													target_id=friend_object.friends_id,
													user1_uuid=user1_uuid,
													user2_uuid=user2_uuid)
				notification_object.save()
			print "-------------DONE-----------------"
		return redirect(gethome())
开发者ID:roomiehunt,项目名称:roomiehunt.github.io,代码行数:35,代码来源:views.py


示例2: test_notification_send

    def test_notification_send(self):
        notifications = Notification.objects.all()
        self.assertEqual(1, len(notifications))
        self.assertEqual(self.student.userprofile, notifications[0].sender)
        self.assertEqual(self.teacher.userprofile, notifications[0].recipient)
        self.assertEqual(self.course_instance, notifications[0].course_instance)
        self.assertEqual("testSubject", notifications[0].subject)
        self.assertEqual("testNotification", notifications[0].notification)
        self.assertFalse(notifications[0].seen)

        Notification.send(self.teacher.userprofile, self.student.userprofile, self.course_instance, "subject", "notification")
        notifications = Notification.objects.all()
        self.assertEqual(2, len(notifications))
        self.assertEqual(self.teacher.userprofile, notifications[0].sender)
        self.assertEqual(self.student.userprofile, notifications[0].recipient)
        self.assertEqual(self.course_instance, notifications[0].course_instance)
        self.assertEqual("subject", notifications[0].subject)
        self.assertEqual("notification", notifications[0].notification)
        self.assertFalse(notifications[0].seen)
        self.assertEqual(self.student.userprofile, notifications[1].sender)
        self.assertEqual(self.teacher.userprofile, notifications[1].recipient)
        self.assertEqual(self.course_instance, notifications[1].course_instance)
        self.assertEqual("testSubject", notifications[1].subject)
        self.assertEqual("testNotification", notifications[1].notification)
        self.assertFalse(notifications[1].seen)
开发者ID:LassiHaaranen,项目名称:a-plus,代码行数:25,代码来源:tests.py


示例3: handle

 def handle(self, *args, **kwargs):
     now = timezone.now()
     meal_list = Meal.objects.filter(
         scheduled_for__lt=now,
         review__isnull=True,
         status='a',
     )
     for meal in meal_list:
         print "Creating a KitchenReview object and sending email " \
             "for meal with ID: %d" % meal.id
         token = get_random_string()
         kitchen_review = KitchenReview.objects.create(
             token=token,
             guest=meal.guest,
             kitchen=meal.kitchen,
         )
         meal.review = kitchen_review
         meal.save()
         Notification.notify(
             'invite_guest_review', {
                 'to_address': meal.guest.email,
                 'meal': meal,
                 'kitchen_review': kitchen_review,
             }
         )
开发者ID:pabloportela,项目名称:narda,代码行数:25,代码来源:send_review_invitation.py


示例4: generateDangerNotification

def generateDangerNotification(request):
	user = request.user
	bankingP = BankingPerson.objects.get(user=user)
	if bankingP.receiveDanger:
		n = Notification(title="Danger danger, we're gonna die", text="LAY, indeed, thought I, and such a lay! the seven hundred and seventy-seventh! Well, old Bildad, you are determined that I, for one, shall not LAY up many LAYS here below, where moth and rust do corrupt. It was an exceedingly LONG LAY that, indeed; and though from the magnitude of the figure it might at first deceive a landsman, yet the slightest consideration will show that though seven hundred and seventy-seven is a pretty large number, yet, when you come to make a TEENTH of it, you will then see, I say, that the seven hundred and seventy-seventh part of a farthing is a good deal less than seven hundred and seventy-seven gold doubloons; and so I thought at the time.", level = 3, to=user)
		n.save()
	return HttpResponseRedirect("/")
开发者ID:plamen-k,项目名称:Spendwell---Lloyds-banking-website,代码行数:7,代码来源:views.py


示例5: add_roomate

def add_roomate(request):
	print "AJAX---------------------------------------ROOMATE REQUEST"

	if request.method == "POST" and request.is_ajax():
		print "AJAX----ADD_ROOMATE"
		context = {}
		user1 = request.user
		user1_profile = Profile.objects.get(user=user1)		
		user1_uuid = user1_profile.id
		user2_uuid = request.POST['user2_uuid']
		user2_profile = Profile.objects.get(id=user2_uuid)
		user2 = user2_profile.user
		roomate_object = Roomate(user1=user1,user2=user2,status = "P",user1_uuid=user1_uuid,user2_uuid=user2_uuid)
		roomate_object.save()
		message = user1_profile.first_name + " " + user1_profile.last_name + " wants to be roomates with you"
		notification_object = Notification(
											user1=user1,
											user2=user2,
											message=message,
											read=False,
											notification_type="RR",
											target_id=roomate_object.roomate_id,
											user1_uuid=user1_uuid,
											user2_uuid=user2_uuid
											)
		notification_object.save()					
		print user2_uuid;
		return render(request,'error.html',context)
	return render(request,'error.html',{})
开发者ID:roomiehunt,项目名称:roomiehunt.github.io,代码行数:29,代码来源:views.py


示例6: form_valid

    def form_valid(self, form):
        assistant_feedback = form.cleaned_data["assistant_feedback"]
        feedback = form.cleaned_data["feedback"]

        note = ""
        if self.submission.assistant_feedback != assistant_feedback:
            note = assistant_feedback
        elif self.submission.feedback != feedback:
            note = feedback

        self.submission.set_points(form.cleaned_data["points"],
            self.exercise.max_points, no_penalties=True)
        self.submission.grader = self.profile
        self.submission.assistant_feedback = assistant_feedback
        self.submission.feedback = feedback
        self.submission.set_ready()
        self.submission.save()

        sub = _('Feedback to {name}').format(name=self.exercise)
        msg = _('<p>You have new personal feedback to exercise '
                '<a href="{url}">{name}</a>.</p>{message}').format(
            url=self.submission.get_absolute_url(),
            name=self.exercise,
            message=note,
        )
        for student in self.submission.submitters.all():
            Notification.send(self.profile, student, self.instance, sub, msg)

        messages.success(self.request, _("The review was saved successfully "
            "and the submitters were notified."))
        return super().form_valid(form)
开发者ID:LassiHaaranen,项目名称:a-plus,代码行数:31,代码来源:staff_views.py


示例7: show_interest

def show_interest(request):
	if request.method == "POST" and request.is_ajax():
		print "AJAX------------------------------------SHOW INTEREST"
		context = {}
		#----GET VARIABLES---#
		user1 = request.user
		user1_profile = Profile.objects.get(user=user1)		
		user1_uuid = user1_profile.id
		user2_uuid = request.POST['user2_uuid']
		user2_profile = Profile.objects.get(id=user2_uuid)
		user2 = user2_profile.user
		#----INTERESTS ARE DIRECTED GRAPHS----#
		friends_object = Friends(user1=user1,user2=user2,status = "I",user1_uuid=user1_uuid,user2_uuid=user2_uuid)
		friends_object.save()
		message = user1_profile.first_name + " " + user1_profile.last_name + " shown interest on you"
		notification_object = Notification(
											user1=user1,
											user2=user2,
											message=message,
											read=False,
											notification_type="SI",
											target_id=friends_object.friends_id,
											user1_uuid=user1_uuid,
											user2_uuid=user2_uuid
											)
		notification_object.save()					
		print user2_uuid;
		notification_delete = request.POST['notification_delete']
		if notification_delete == "ok":
			notification_id = request.POST['notification_id']
			notification_object_delete = Notification.objects.get(notification_id=notification_id)
			notification_object_delete.delete()	

		return render(request,'error.html',context)
	return render(request,'error.html',{})
开发者ID:roomiehunt,项目名称:roomiehunt.github.io,代码行数:35,代码来源:views.py


示例8: envoyer_commentaire_notification

 def envoyer_commentaire_notification(self, comment_pk, username):
     eleve = UserProfile.objects.get(user__username=username)
     message = eleve.first_name + " " + eleve.last_name + " a commente un message de " + self.association.nom
     commentaire = Comment.objects.get(pk=comment_pk)
     notification = Notification(content_object=commentaire, description=message)
     notification.save()
     notification.envoyer_multiple(self.association.suivi_par.all())
开发者ID:wumzi,项目名称:portail,代码行数:7,代码来源:models.py


示例9: generateInfoNotification

def generateInfoNotification(request):
	user = request.user
	bankingP = BankingPerson.objects.get(user=user)
	if bankingP.receiveInfo:
		n = Notification(title="Information triggered", text="I thought him the queerest old Quaker I ever saw, especially as Peleg,his friend and old shipmate, seemed such a blusterer. But I said nothing, only looking round me sharply. Peleg now threw open a chest, and drawing forth the ship's articles, placed pen and ink before him, and seated himself at a little table. I began to think it was high time to settle with myself at what terms I would be willing to engage for the voyage. I was already aware that in the whaling business they paid no wages; but all hands, including the captain, received certain shares of the profits called lays, and that these lays were proportioned to the degree of importance pertaining to the respective duties of the ship's company. I was also aware that being a green hand at whaling, my own lay would not be very large; but considering that I was used to the sea, could steer a ship, splice a rope, and all that, I made no doubt that from all I had heard I should be offered at least the 275th lay--that is, the 275th part of the clear net proceeds of the voyage, whatever that might eventually amount to. And though the 275th lay was what they call a rather LONG LAY, yet it was better than nothing; and if we had a lucky voyage, might pretty nearly pay for the clothing I would wear out on it, not to speak of my three years' beef and board, for which I would not have to pay one stiver.", level = 0, to=user)
		n.save()
	return HttpResponseRedirect("/")
开发者ID:plamen-k,项目名称:Spendwell---Lloyds-banking-website,代码行数:7,代码来源:views.py


示例10: upload_photo

def upload_photo(request):
	if request.method == 'POST':
		sim_file= request.FILES['sim_id']
		f=sim_file.read()
		sim_id=int(f)
		#test if Sim with number=sim_id  exists
		if Sim.objects.filter(number = sim_id).count()==1:
			#Creating Photo object
			uploaded_photo = Photo(phototype= 'Blank', image = request.FILES['file_upload'])
			#Creating Notification object and save to DBB
			mySim=Sim.objects.get(number = sim_id)
			myBox=Box.objects.get(sim = mySim)
			if Notification.objects.filter(title__contains = uploaded_photo.image).count() > 1:
				i=0
				for notification in Notification.objects.filter(title__contains = uploaded_photo.image):
					i+=1			
				titleu=str(uploaded_photo.image) + str(i)
				myNotification = Notification(title = titleu, box=myBox)
			else:
				myNotification = Notification(title = uploaded_photo.image, box=myBox)
			#Traitement d'image
			myNotification.save()
			#Polishing Photo object and save to DBB
			uploaded_photo.notification=myNotification
			uploaded_photo.save()
			#to remove str(sim_id)
			return HttpResponse("Image Uploaded, owner of sim_id = " + str(sim_id))
		else:
			return HttpResponse("ACCESS DENIED: Box Not Identified")
	else:
		return HttpResponse("GET Denied")
开发者ID:elomario,项目名称:CMAIL-django,代码行数:31,代码来源:views.py


示例11: generateWarningNotification

def generateWarningNotification(request):
	user = request.user
	bankingP = BankingPerson.objects.get(user=user)
	if bankingP.receiveWarning:
		n = Notification(title="BE WARNED, mortal", text="But one thing, nevertheless, that made me a little distrustful about receiving a generous share of the profits was this: Ashore, I had heard something of both Captain Peleg and his unaccountable old crony Bildad; how that they being the principal proprietors of the Pequod, therefore the other and more inconsiderable and scattered owners, left nearly the whole management of the ship's affairs to these two. And I did not know but what the stingy old Bildad might have a mighty deal to say about shipping hands, especially as I now found him on board the Pequod, quite at home there in the cabin, and reading his Bible as if at his own fireside. Now while Peleg was vainly trying to mend a pen with his jack-knife, old Bildad, to my no small surprise, considering that he was such an interested party in these proceedings; Bildad never heeded us, but went on mumbling to himself out of his book, 'LAY not up for yourselves treasures upon earth, where moth.", level = 2, to=user)
		n.save()
	return HttpResponseRedirect("/")
开发者ID:plamen-k,项目名称:Spendwell---Lloyds-banking-website,代码行数:7,代码来源:views.py


示例12: generateSuccessNotification

def generateSuccessNotification(request):
	user = request.user
	bankingP = BankingPerson.objects.get(user=user)
	print bankingP.receiveSuccess
	if bankingP.receiveSuccess:
		n = Notification(title="Success may be on your way", text="hello world body", level = 1, to=user)
		n.save()
	return HttpResponseRedirect("/")
开发者ID:plamen-k,项目名称:Spendwell---Lloyds-banking-website,代码行数:8,代码来源:views.py


示例13: envoyer_notification

 def envoyer_notification(self):
     try: 
         bde = Association.objects.get(pseudo='bde') #On envoie seulement à ceux qui suivent le BDE
         notification = Notification(content_object=self, message='Un nouveau petit cours est disponible')
         notification.save()
         notification.envoyer_multiple(bde.suivi_par.all())
     except Association.DoesNotExist:
         pass
开发者ID:gcaner,项目名称:portail,代码行数:8,代码来源:models.py


示例14: envoyer_notification

 def envoyer_notification(self):
     try: 
         perm = Permission.objects.get(codename='add_sondage')  #On envoie seulement à ceux qui peuvent créer des sondages
         users = User.objects.filter(Q(is_superuser=True) | Q(groups__permissions=perm) | Q(user_permissions=perm) ).distinct()            
         notification = Notification(content_object=self, description='Un nouveau sondage a été proposé')
         notification.save()
         notification.envoyer_multiple(users)
     except Permission.DoesNotExist:
         pass
开发者ID:ensmp,项目名称:portail,代码行数:9,代码来源:models.py


示例15: save

 def save(self, *args, **kwargs):
     markdown = Markdown()
     self.content_html = markdown.render(self.content)
     super().save(*args, **kwargs)
     from notification.models import Notification
     Notification.create_notifications_from_reply(
         reply=self,
         mentions=markdown.get_mentions()
     )
开发者ID:20CM,项目名称:Sanctuary,代码行数:9,代码来源:models.py


示例16: notify

 def notify(self):
     # Guest confirmation
     Notification.notify('book_guest', {
         'to_address': self.guest.email,
         'meal': self,
     })
     # Chef confirmation
     Notification.notify('book_chef', {
         'to_address': self.kitchen.chef.email,
         'meal': self,
     })
开发者ID:pabloportela,项目名称:narda,代码行数:11,代码来源:models.py


示例17: setUp

	def setUp(self):
		self.user = factory.create_user('[email protected]', '[email protected]', 'john123', 'John', 'Doe')
		self.location = factory.create_location('Thailand', 'Nakhonsawan')
		self.category = factory.create_category('Travel', 'travel')
		self.blog = factory.create_blog('Travel in Nakhonsawan', self.user, self.category, self.location)

		self.love_user = factory.create_user('[email protected]', '[email protected]', 'adam123', 'Adam', 'Johnson')
		self.love_notification = Notification(subject=self.love_user, action=1, blog=self.blog)
		self.love_notification.save()

		self.download_notification = Notification(subject=self.user, action=2, blog=self.blog)
		self.download_notification.save()
开发者ID:opendream,项目名称:livestory,代码行数:12,代码来源:test_models.py


示例18: send_notification

def send_notification(request):
    params = request.POST  
    client_id = params['client_id']
    group_id = params['group_id']
    title = params['title']
    message = params['message']
    target_url = params['target_url']
    notification = Notification(title=title, message=message, target_url=target_url,
     client_id=client_id, group_id=group_id)
    notification.save()
    args = (user_list, title, message, target_url, notification_id)
    add_to_task(args, notification, client_id, group_id)
开发者ID:webnotification,项目名称:notifier,代码行数:12,代码来源:views.py


示例19: post

    def post(self, request, goal_slug, suggestion_slug):  # noqa
        self._get_data(request, goal_slug, suggestion_slug)
        if not self.review:
            self._create_review()

        data = ReviewSerializer(self.review).data
        data.update(request.data)

        serializer = ReviewSerializer(instance=self.review, data=data)
        if serializer.is_valid():
            self.review = serializer.save(is_draft=False)
            update_rating_and_save(self.review.revision.suggestion)
            self.review.comments.filter(is_draft=False).delete()
            notification = Notification.create_for_review(self.review)
            if notification.owner != self.review.owner:
                notification.save()
            return Response(
                {'success': 1},
                status=status.HTTP_200_OK
            )
        else:
            return Response(
                {
                    'success': 0,
                    'errors': serializer.errors
                },
                status=status.HTTP_200_OK
            )
开发者ID:mnieber,项目名称:shared-goals,代码行数:28,代码来源:react_views.py


示例20: change_friend_status

def change_friend_status(request):
	if not request.user.is_authenticated():
		return redirect(gethome())

	if request.method != 'POST':
		print "NOT POST-----------------"
		return redirect(gethome())
	else:
		print "CHANGE REQUEST ENTER AJAX CALL--------------------------"
		print request.POST
		notification_id = request.POST['this_id']
		notification_object = Notification.objects.filter(notification_id=notification_id)
		response_type = str(request.POST['type']) 
		if "delete_notification" == response_type:
			print "DELETe NOTIFICATION--------------------AJAX------------------"			
			notification_object.delete()
			return redirect(gethome())

		target_id = request.POST['target_id']
		friend_object = Friends.objects.filter(friends_id=target_id)				
		#-------------BETA-------------------------------------#			
		user1_uuid = request.POST['user1_uuid']
		user2_uuid = request.POST['user2_uuid']
		#-------------BETA-------------------------------------#	
		if "accept" == response_type:
			print "ACCEPT-------------------AJAX------------------"
			friend_object.update(status="F")			
			notification_object.delete()
			#-------------BETA-------------------------------------#			
			profile1 = Profile.objects.get(id=user1_uuid)
			profile2 = Profile.objects.get(id=user2_uuid)
			#-------------BETA-------------------------------------#
			message =  str(profile2.first_name) + " " +str(profile2.last_name) +" " +"HAVE BECOME FRIENDS WITH YOU"
			accept_notification = Notification( user1=profile2.user,
												user2=profile1.user,
												message=message,
												user1_uuid=user2_uuid,
												user2_uuid=user1_uuid,
												notification_type="FA")
			accept_notification.save()
		elif "ignore" == response_type:
			print "IGNORE-------------------AJAX------------------"
			friend_object.delete()						
			notification_object.delete()			
		elif "block" == response_type:
			print "BLOCK--------------------AJAX------------------"
	return redirect(gethome())
开发者ID:roomiehunt,项目名称:roomiehunt.github.io,代码行数:47,代码来源:views.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python models.ScheduledNotification类代码示例发布时间:2022-05-27
下一篇:
Python models.send函数代码示例发布时间: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