本文整理汇总了Python中notifications.signals.notify.send函数的典型用法代码示例。如果您正苦于以下问题:Python send函数的具体用法?Python send怎么用?Python send使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了send函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: jobrequest_delete
def jobrequest_delete(sender,**kwargs):
jobrequest=kwargs['instance']
job = jobrequest.job
# notify users of changed JobRequest
notify.send(job.creator,
verb="deleted {0}".format(jobrequest),
recipient=jobrequest.organization.group)
开发者ID:purdue-epics-ims,项目名称:boilerconnect,代码行数:7,代码来源:models.py
示例2: 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:aztrock,项目名称:django-notifications,代码行数:7,代码来源:views.py
示例3: add_perms_job
def add_perms_job(sender,**kwargs):
# check if this post_save signal was generated from a Model create
job=kwargs['instance']
if 'created' in kwargs and kwargs['created']:
# allow creator to view and edit job
assign_perm('view_job',job.creator,job)
assign_perm('edit_job',job.creator,job)
# allow requested orgs to view job
for org in job.organizations.all():
assign_perm('view_job',org.group,job)
else:
# notify users of changed JobRequest
if job.closed:
jobrequests = job.jobrequests_accepted()
else:
jobrequests = job.jobrequests_accepted() | job.jobrequests_pending()
for jobrequest in jobrequests:
notify.send(job.creator,
verb="modified",
action_object=jobrequest,
recipient=jobrequest.organization.group,
url=reverse('organization_dash',
kwargs = {'organization_id':jobrequest.organization.id})+
"?jobrequestID="+str(jobrequest.id)
)
开发者ID:purdue-epics-ims,项目名称:boilerconnect,代码行数:26,代码来源:models.py
示例4: event_notify
def event_notify(request, event, verb1, verb2):
#notify user and committee members
notify.send(request.user, recipient=request.user, verb=verb1 + ' ', target=event)
for committee_member in list(User.objects.filter(is_staff=True)):
#don't norify an attending committee member twice
if committee_member is not request.user:
notify.send(request.user, recipient=committee_member, verb= ' ' + verb2 + ' ', target=event)
开发者ID:ryanmac666,项目名称:IFB299-Team-Repo,代码行数:7,代码来源:utils.py
示例5: post
def post(self, *args, **kwargs):
form = self.get_form()
if form.is_valid():
parent_id = self.request.POST.get("parent_id")
parent_comment = None
if parent_id:
try:
parent_comment = Comment.objects.get(id=parent_id)
except:
parent_comment = None
clean_text = form.cleaned_data["text"]
new_comment = Comment.objects.create_comment(
user=self.request.user,
text=clean_text,
path=self.request.get_full_path(),
video=self.get_object(),
parent=parent_comment)
if parent_comment:
comment = parent_comment
else:
comment = new_comment
affected_users = comment.get_affected_users()
notify.send(self.request.user,
recipient=comment.user,
action=comment,
target=new_comment.video,
affected_users=affected_users,
verb=u'commented',
)
messages.success(self.request, "Thank you for your comment")
return HttpResponseRedirect(self.get_object().get_absolute_url())
else:
messages.error(self.request, "There was an error")
return HttpResponseRedirect(self.get_object().get_absolute_url())
开发者ID:LABETE,项目名称:srvup,代码行数:34,代码来源:views.py
示例6: copy
def copy(request, id):
new_ann = get_object_or_404(Announcement, pk=id)
new_ann.pk = None # autogen a new primary key (quest_id by default)
new_ann.title = "Copy of " + new_ann.title
form = AnnouncementForm(request.POST or None, instance = new_ann)
if form.is_valid():
new_announcement = form.save(commit=False)
new_announcement.author = request.user
new_announcement.datetime_created = timezone.now
new_announcement.save()
form.save()
affected_users = User.objects.all().filter(is_active=True)
notify.send(
request.user,
action=new_announcement,
target=new_announcement,
recipient=request.user,
affected_users=affected_users,
verb='posted')
# return redirect('announcements:list', id=new_announcement.id)
return redirect(new_announcement)
context = {
"title": "",
"heading": "Copy an Announcement",
"form": form,
"submit_btn_value": "Create",
}
return render(request, "announcements/form.html", context)
开发者ID:kinglyduck,项目名称:hackerspace,代码行数:30,代码来源:views.py
示例7: new_user_receiver
def new_user_receiver(sender,instance,created,*args, **kwargs):
if created:
new_profile, is_created = UserProfile.objects.get_or_create(user=instance)
print new_profile, is_created
notify.send(instance,
recipient=MyUser.objects.get(username="climberwb"),
verb="New User created")
开发者ID:climberwb,项目名称:video-membership,代码行数:7,代码来源:models.py
示例8: confirm
def confirm(self):
self.declined = False
self.accepted = True
self.confirmed = True
self.save()
notify.send(self.organization,
verb="confirmed",
action_object=self.job,
recipient=self.organization.group,
url=reverse('organization_dash',
kwargs={'organization_id': self.organization.id}) +
"?jobrequestID=" + str(self.id)
)
# iterate through all jobrequests in this job and remove permission
# for other jobrequests
job = self.job
job.closed = True
job.save()
for jr in job.jobrequests.all():
if jr != self:
remove_perm('view_jobrequest',jr.job.creator,jr)
remove_perm('view_jobrequest',jr.organization.group,jr)
notify.send(self.organization,
verb="has closed the job: ",
action_object=self.job,
recipient=jr.organization.group,
# questionable use of url since user will not have permission to view anymore
# url=reverse('organization_dash',
# kwargs={'organization_id': jr.organization.id}) +
# "?jobrequestID=" + str(jr.id)
)
开发者ID:purdue-epics-ims,项目名称:boilerconnect,代码行数:31,代码来源:models.py
示例9: register
def register(request):
'''注册视图'''
form = RegisterForm()
if request.method == "POST":
form = RegisterForm(request.POST.copy())
if form.is_valid():
username = form.cleaned_data["username"]
email = form.cleaned_data["email"]
password = form.cleaned_data["password"]
re_password = form.cleaned_data["re_password"]
real_name = form.cleaned_data["real_name"]
if password == re_password:
user = User.objects.create_user(username, email, password)
user.is_staff = 0
user.first_name=real_name
user.save()
try:
custom = Custom(user=user, is_custom = True)
custom.save()
except IntegrityError:
last_user = User.objects.all().order_by('-id')[0]
last_user.delete()
notify.send(User.objects.get(id=1),recipient=user, verb='register successfully!')
_login(request, username, password)
return HttpResponse('<script>alert("注册成功!");location.replace(document.referrer);;</script>')
else:
return HttpResponse('<script>alert("两次密码必须相同!");history.go(-1);</script>')
else:
reverse_lazy('404')
else:
reverse_lazy('501')
return render_to_response("custom-register.html", locals(), context_instance = RequestContext(request))
开发者ID:zhwei,项目名称:qipei,代码行数:35,代码来源:views.py
示例10: groups_member_abort
def groups_member_abort(request, pk):
"""
This API used to allow user to abort the specific Groups in the system. (API version 1)
* Requires token authentication.
"""
if request.method == 'POST':
group = get_object_or_404(Group, id=pk)
group.members.remove(request.user)
group.save()
# send action to action stream
action.send(request.user, verb="aborted", target=group)
notify.send(
request.user,
recipient=group.creator,
verb=u'has aborted from your Group',
level='success')
return Response({
"code": status.HTTP_202_ACCEPTED,
"status": "ok",
},
status=status.HTTP_202_ACCEPTED)
else:
return Response({
"code": status.HTTP_400_BAD_REQUEST,
"status": "error"
},
status=status.HTTP_400_BAD_REQUEST)
开发者ID:edXPDRLab,项目名称:CommonRepo,代码行数:30,代码来源:views.py
示例11: follow_group
def follow_group(request, pk):
"""
Creates the follow relationship between ``request.user`` and the ``Group``
"""
group = get_object_or_404(Group, id=pk)
# Check user is not member of the group
if not group.members.filter(id=request.user.id).exists():
actions.follow(request.user, group, send_action=True)
notify.send(
request.user,
recipient=group.creator,
verb=u'has followed your Group',
level='success')
request.user.userprofile.follow_groups.add(group)
messages.success(
request,
'Successed, you are now following this Group.')
else:
actions.follow(request.user, group, send_action=False)
messages.success(
request,
'You are the member of this Group and automatically become the follower.')
return redirect('groups:groups-detail', pk)
开发者ID:edXPDRLab,项目名称:CommonRepo,代码行数:25,代码来源:views.py
示例12: atwho
def atwho(text, sender, targetcomment, targetarticle, targetopic , targetproducts):
commmentdecode = text.decode("utf8")
pattern = re.compile(u'@([\u4e00-\u9fa5\w\-]+)')
results = pattern.findall(commmentdecode) #用正则把评论中有@的字符串分割开
userlist = []
for item in results:
try:
user = MyUser.objects.get(username = item.encode('utf8'))
except:
user = None
if user:
user = MyUser.objects.get(username = item.encode('utf8'))
notify.send(sender=sender, target_object=targetcomment
, recipient = user, verb="@"
, text=text, target_article = targetarticle
, target_products = targetproducts
, target_topic = targetopic)
cachekey = "user_unread_count" + str(user.id)
if cache.get(cachekey) != None:
cache.incr(cachekey)
else:
unread = Notification.objects.filter(recipient = user).filter(read = False).count()
cache.set(cachekey, unread, settings.CACHE_EXPIRETIME)
userlist.append(item.encode('utf8'))
return userlist
开发者ID:kij8323,项目名称:mynewspaper,代码行数:25,代码来源:atwho.py
示例13: suggestion_create
def suggestion_create(request):
template_name='suggestions/suggestion_form.html'
form = SuggestionForm(request.POST or None)
if form.is_valid():
new_suggestion = form.save(commit=False)
new_suggestion.user = request.user
new_suggestion.status_timestamp = timezone.now()
new_suggestion.save()
icon="<i class='fa fa-lg fa-fw fa-lightbulb-o'></i>"
notify.send(
request.user,
# action=profile.user,
target= new_suggestion,
recipient=request.user,
affected_users=User.objects.filter(is_staff=True),
verb='suggested:',
icon=icon,
)
messages.success(request, "Thank you for your suggestion! Mr C \
has to it review before it will be publicly visible.")
return redirect(new_suggestion.get_absolute_url())
return render(request, template_name, {'form':form})
开发者ID:alexmerser,项目名称:hackerspace,代码行数:27,代码来源:views.py
示例14: suggestion_approve
def suggestion_approve(request, id):
suggestion = get_object_or_404(Suggestion, id=id)
suggestion.status = Suggestion.APPROVED
suggestion.status_timestamp = timezone.now()
suggestion.save()
icon="<span class='fa-stack'>" + \
"<i class='fa fa-lightbulb-o fa-stack-1x'></i>" + \
"<i class='fa fa-check fa-stack-2x text-success'></i>" + \
"</span>"
suggestion_badge = get_object_or_404(Badge, name="Human Baby")
grant_badge(request, suggestion_badge.id ,suggestion.user.id)
notify.send(
request.user,
# action=profile.user,
target= suggestion,
recipient=suggestion.user,
affected_users=[suggestion.user,],
verb='approved',
icon=icon,
)
messages.success(request, "Suggestion by " + str(suggestion.user) + " approved.")
return redirect(suggestion.get_absolute_url())
开发者ID:alexmerser,项目名称:hackerspace,代码行数:26,代码来源:views.py
示例15: suggestion_approve
def suggestion_approve(request, id):
suggestion = get_object_or_404(Suggestion, id=id)
# Todo move this into the model, not view!
suggestion.status = Suggestion.APPROVED
suggestion.status_timestamp = timezone.now()
suggestion.save()
icon = "<span class='fa-stack'>" + \
"<i class='fa fa-lightbulb-o fa-stack-1x'></i>" + \
"<i class='fa fa-check fa-stack-2x text-success'></i>" + \
"</span>"
# TODO don't hardcode this, put it in the settings!
suggestion_badge = get_object_or_404(Badge, pk=config.hs_suggestion_badge)
grant_badge(request, suggestion_badge.id, suggestion.user.id)
notify.send(
request.user,
# action=profile.user,
target=suggestion,
recipient=suggestion.user,
affected_users=[suggestion.user, ],
verb='approved',
icon=icon,
)
messages.success(request, "Suggestion by " + str(suggestion.user) + " approved.")
return redirect(suggestion.get_absolute_url())
开发者ID:timberline-secondary,项目名称:hackerspace,代码行数:28,代码来源:views.py
示例16: comment_ban_toggle
def comment_ban_toggle(request, profile_id):
profile = get_object_or_404(Profile, id=profile_id)
profile.banned_from_comments = not profile.banned_from_comments
profile.save()
if profile.banned_from_comments:
icon="<span class='fa-stack'>" + \
"<i class='fa fa-comment-o fa-flip-horizontal fa-stack-1x'></i>" + \
"<i class='fa fa-ban fa-stack-2x text-danger'></i>" + \
"</span>"
notify.send(
request.user,
# action=profile.user,
target= profile.user,
recipient=request.user,
affected_users=[profile.user,],
verb='banned you from making public comments',
icon=icon,
)
messages.success(request, profile.user.username + " banned from commenting publicly")
return redirect('profiles:profile_list')
开发者ID:alexmerser,项目名称:hackerspace,代码行数:25,代码来源:views.py
示例17: 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:aztrock,项目名称:django-notifications,代码行数:7,代码来源:tests.py
示例18: assertion_delete
def assertion_delete(request, assertion_id):
assertion = get_object_or_404(BadgeAssertion, pk=assertion_id)
if request.method=='POST':
user = assertion.user
notify.send(
request.user,
# action=...,
target=assertion.badge,
recipient=user,
affected_users=[user,],
icon="<span class='fa-stack'>" + \
"<i class='fa fa-certificate fa-stack-1x text-warning'></i>" + \
"<i class='fa fa-ban fa-stack-2x text-danger'></i>" + \
"</span>",
verb='revoked')
messages.success(request,
("Badge " + str(assertion) + " revoked from " + str(assertion.user)
))
assertion.delete()
return redirect('profiles:profile_detail', pk = user.id)
template_name='badges/assertion_confirm_delete.html'
return render(request, template_name, {'object':assertion})
开发者ID:kinglyduck,项目名称:hackerspace,代码行数:25,代码来源:views.py
示例19: vehicle_create
def vehicle_create(request, user_id):
form = VehicleAddForm(request.POST or None, request.FILES or None)
user = get_object_or_404(CustomUser, pk=user_id)
if request.user != user:
raise Http404
if user.user_type == 'Passenger':
raise Http404
if form.is_valid():
ride = form.save(commit=False)
ride.user = user
ride.save()
rides = Vehicle.objects.filter(user=user).order_by('pk').reverse()
ride = Vehicle.objects.filter(user=user).latest('pk')
notify.send(user, recipient=user, verb='Added a Ride', level='success', action_object=ride,description='Ride Created Sucessfully')
return render(request, 'app/vehicles/view_vehicles.html',
{'user': user,
'rides': rides,
'message':True,
'message_title':'Ride Added Successfully.',
'message_body':'Your ride has been added successfully, view more options below',
})
context = {
'user': user,
'form': form,
}
return render(request, 'app/vehicles/vehicle_form.html', context)
开发者ID:othreecodes,项目名称:MY-RIDE,代码行数:29,代码来源:views.py
示例20: detail
def detail(request, pk):
post = Post.objects.get(pk=pk)
replies = post.reply_set.all()
if request.method == 'POST':
form = ReplyForm(data=request.POST)
if form.is_valid():
reply_content = form.cleaned_data['reply_content']
Reply.objects.create(post=post, replyer=request.user, content=reply_content)
post.reply_count += 1
post.last_reply_time = timezone.now()
post.save()
if request.user != post.author:
notify.send(request.user, recipient=post.author, verb='reply', target=post,
description=reply_content, level='success')
at_list = re.findall(r'@([A-Za-z0-9]+)', reply_content)
if at_list:
for at_user in at_list:
try:
user = GripUser.objects.get(username=at_user)
notify.send(request.user, recipient=user, verb='at', description=reply_content,
target=post, level='success')
except GripUser.DoesNotExist:
pass
return HttpResponseRedirect('/p/'+pk)
else:
form = ReplyForm()
context = {
'post': post,
'replies': replies,
'form': form,
}
template_name = 'payment/detail.html'
return render(request, template_name, context)
开发者ID:upczww,项目名称:grip,代码行数:33,代码来源:views.py
注:本文中的notifications.signals.notify.send函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论