本文整理汇总了Python中notification.models.Notification.save方法的典型用法代码示例。如果您正苦于以下问题:Python Notification.save方法的具体用法?Python Notification.save怎么用?Python Notification.save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类notification.models.Notification
的用法示例。
在下文中一共展示了Notification.save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: add_roomate
# 需要导入模块: from notification.models import Notification [as 别名]
# 或者: from notification.models.Notification import save [as 别名]
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',{})
示例2: envoyer_commentaire_notification
# 需要导入模块: from notification.models import Notification [as 别名]
# 或者: from notification.models.Notification import save [as 别名]
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())
示例3: upload_photo
# 需要导入模块: from notification.models import Notification [as 别名]
# 或者: from notification.models.Notification import save [as 别名]
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")
示例4: generateDangerNotification
# 需要导入模块: from notification.models import Notification [as 别名]
# 或者: from notification.models.Notification import save [as 别名]
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: generateWarningNotification
# 需要导入模块: from notification.models import Notification [as 别名]
# 或者: from notification.models.Notification import save [as 别名]
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("/")
示例6: add_friend
# 需要导入模块: from notification.models import Notification [as 别名]
# 或者: from notification.models.Notification import save [as 别名]
def add_friend(request):
if request.method == "POST" and request.is_ajax():
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
friend_object = Friends(user1=user1,user2=user2,status = "P",user1_uuid=user1_uuid,user2_uuid=user2_uuid)
message = user1_profile.first_name + " " + user1_profile.last_name + "shows interest with you"
friend_object.save()
notification_object = Notification(
user1=user1,
user2=user2,
message=message,
read=False,
notification_type="I",
target_id=friend_object.roomate_id,
user1_uuid=user1_uuid,
user2_uuid=user2_uuid,
)
notification_object.save()
return render(request,"error.html",{})
return render(request,"error.html",{})
示例7: generateInfoNotification
# 需要导入模块: from notification.models import Notification [as 别名]
# 或者: from notification.models.Notification import save [as 别名]
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("/")
示例8: show_interest
# 需要导入模块: from notification.models import Notification [as 别名]
# 或者: from notification.models.Notification import save [as 别名]
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',{})
示例9: generateSuccessNotification
# 需要导入模块: from notification.models import Notification [as 别名]
# 或者: from notification.models.Notification import save [as 别名]
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("/")
示例10: envoyer_notification
# 需要导入模块: from notification.models import Notification [as 别名]
# 或者: from notification.models.Notification import save [as 别名]
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
示例11: envoyer_notification
# 需要导入模块: from notification.models import Notification [as 别名]
# 或者: from notification.models.Notification import save [as 别名]
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
示例12: post
# 需要导入模块: from notification.models import Notification [as 别名]
# 或者: from notification.models.Notification import save [as 别名]
def post(self, request):
message={}
if request.user.is_authenticated():
objectid=request.POST.get('objectid','')
objecttype=request.POST.get('objecttype','')
votetype=request.POST.get('votetype','')
if objectid and objecttype and votetype:
if objecttype=='question':
currentobject=Question.objects.get(pk=objectid);
elif objecttype=='answer':
currentobject=Answer.objects.get(pk=objectid);
if currentobject:
if votetype=="vote":
if request.user.profile in currentobject.votes.all():
message['status']='False'
message['message']="Bạn chỉ được thích một lần"
else:
currentobject.votes.add(request.user.profile)
currentobject.save()
currentobject.author.rank+=0.01
currentobject.author.save()
message['status']='OK'
message['message']=""
message['votes_count']=currentobject.votes_count
elif votetype=="downvote":
if request.user.profile in currentobject.downvotes.all():
message['status']='False'
message['message']="Bạn chỉ được không thích một lần"
else:
currentobject.downvotes.add(request.user.profile)
currentobject.save()
currentobject.author.rank-=0.05
currentobject.author.save()
message['status']='OK'
message['message']=""
message['votes_count']=currentobject.downvotes_count
#notification
if currentobject.author!=request.user.profile:
notification=Notification()
notification.action=votetype
notification.sender=request.user.profile
notification.recipient=currentobject.author
notification.content_object=currentobject
notification.save()
else:
message['status']='False'
message['message']="{} không tồn tại".format(objecttype)
else:
message['status']='False'
message['message']='Thông tin không chính xác'
else:
message['status']='False'
message['message']='Bạn cần đăng nhập'
return HttpResponse(json.dumps(message), content_type = "application/json")
示例13: envoyer_message_notification
# 需要导入模块: from notification.models import Notification [as 别名]
# 或者: from notification.models.Notification import save [as 别名]
def envoyer_message_notification(self):
message = self.association.nom + " a publie un nouveau message"
notification = Notification(content_object=self, message=message)
notification.save()
if self.destinataire is None:
notification.envoyer_multiple(self.association.suivi_par.all())
else:
recipients = self.association.suivi_par.all().filter(
Q(userprofile__in=self.destinataire.membres.all) | Q(userprofile__in=self.association.membres.all)
)
notification.envoyer_multiple(recipients)
示例14: send_notification
# 需要导入模块: from notification.models import Notification [as 别名]
# 或者: from notification.models.Notification import save [as 别名]
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)
示例15: envoyer_commentaire_notification
# 需要导入模块: from notification.models import Notification [as 别名]
# 或者: from notification.models.Notification import save [as 别名]
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, message=message)
notification.save()
if self.destinataire is None:
notification.envoyer_multiple(self.association.suivi_par.all())
else:
recipients = self.association.suivi_par.all().filter(
Q(userprofile__in=self.destinataire.membres.all) | Q(userprofile__in=self.association.membres.all)
)
notification.envoyer_multiple(recipients)