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