本文整理汇总了Python中notification.models.Notification类的典型用法代码示例。如果您正苦于以下问题:Python Notification类的具体用法?Python Notification怎么用?Python Notification使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Notification类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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())
示例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)
示例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,
}
)
示例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("/")
示例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',{})
示例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)
示例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',{})
示例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())
示例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("/")
示例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")
示例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("/")
示例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("/")
示例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
示例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
示例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()
)