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

Python models.send函数代码示例

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

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



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

示例1: delete

 def delete(self):
     if notification:
         notification.send(User.objects.filter(watchrelation__listing=self).exclude(id=self.owner.id),
             "listing_delete",
             {'listing':self, },
         )
     super(Listing, self).delete()
开发者ID:cjs,项目名称:bme,代码行数:7,代码来源:models.py


示例2: notification_post_delete_resource

 def notification_post_delete_resource(instance, sender, **kwargs):
     """ Send a notification when a layer, map or document is deleted
     """
     notice_type_label = '%s_deleted' % instance.class_name.lower()
     recipients = get_notification_recipients(notice_type_label)
     notification.send(recipients, notice_type_label, {'resource': instance})
     send_queued_notifications.delay()
开发者ID:World-AgroForestry-Centre,项目名称:geonode,代码行数:7,代码来源:signals.py


示例3: delete

def delete(request, message_id, success_url=None):
    """
    Marks a message as deleted by sender or recipient. The message is not
    really removed from the database, because two users must delete a message
    before it's save to remove it completely. 
    A cron-job should prune the database and remove old messages which are 
    deleted by both users.
    As a side effect, this makes it easy to implement a trash with undelete.
    
    You can pass ?next=/foo/bar/ via the url to redirect the user to a different
    page (e.g. `/foo/bar/`) than ``success_url`` after deletion of the message.
    """
    user = request.user
    now = datetime.datetime.now()
    message = get_object_or_404(Message, id=message_id)
    deleted = False
    if success_url is None:
        success_url = reverse('messages_inbox')
    if request.GET.has_key('next'):
        success_url = request.GET['next']
    if message.sender == user:
        message.sender_deleted_at = now
        deleted = True
    if message.recipient == user:
        message.recipient_deleted_at = now
        deleted = True
    if deleted:
        message.save()
        messages.info(request, _(u"Message successfully deleted."))
        if notification:
            notification.send([user], "messages_deleted", {'message': message,})
        return HttpResponseRedirect(success_url)
    raise Http404
开发者ID:Dealstruck,项目名称:django-messages,代码行数:33,代码来源:views.py


示例4: undelete

def undelete(request, message_id, success_url=None):
    """
    Recovers a message from trash. This is achieved by removing the
    ``(sender|recipient)_deleted_at`` from the model.
    """
    user = request.user
    message = get_object_or_404(Message, id=message_id)
    undeleted = False
    if success_url is None:
        success_url = reverse('messages_inbox')
    if 'next' in request.GET:
        success_url = request.GET['next']
    if message.sender == user:
        message.sender_deleted_at = None
        undeleted = True
    if message.recipient == user:
        message.recipient_deleted_at = None
        undeleted = True
    if undeleted:
        message.save()
        messages.info(request, _(u"Message successfully recovered."))
        #signals added by [email protected]
        # signals.message_state_change.send(sender=user.__class__,
        #                                   request=request,
        #                                   user=user)
        if notification:
            notification.send([user], "messages_recovered", {'message': message,})
        return HttpResponseRedirect(success_url)
    raise Http404
开发者ID:jresins,项目名称:django-messages,代码行数:29,代码来源:views.py


示例5: mem_vip_appl

def mem_vip_appl(request, **kwargs):
    """
    VIP申请提醒
    """
    template_name = "member/memmin_upgrade_appl.html"
    MinUpgradeRecord = ""
    has_appl = False
    try:
        UserBasic = user_basic.objects.defer(None).get(user=request.user)
    except:
        raise Http404
    if request.method == "POST":

        bank_name_list = request.POST.get("bank_name_list")
        MinUpgradeRecord = min_upgrade_record(user=UserBasic)
        form = MemVipApllForm(request.POST, user=request.user)
        print form
        if form.is_valid():
            form = MemVipApllForm(request.POST, user=request.user, instance=MinUpgradeRecord)
            form.save()
            extra_context = UserBasic.number + "申请成为VIP"
            print extra_context
            users = User.objects.filter(is_superuser=True)
            notification.send(users, "vip_appl", extra_context, True, request.user)
            return HttpResponseRedirect(reverse("member_details"))
    else:
        MinUpgradeRecord = min_upgrade_record.objects.defer(None).filter(user=UserBasic)
        form = MemVipApllForm()
        if MinUpgradeRecord:
            has_appl = True
    ctx = {"form": form, "has_appl": has_appl}
    return render_to_response(template_name, RequestContext(request, ctx))
开发者ID:qingyuanzhang,项目名称:triple_mag,代码行数:32,代码来源:views.py


示例6: save

    def save(self, sender, parent_msg=None):
        r = self.cleaned_data['recipient']
        subject = self.cleaned_data['subject']
        body = self.cleaned_data['body']
        message_list = []

        r = User.objects.get(id=r)

        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)
        if notification:
            if parent_msg is not None:
                notification.send([sender], "messages_replied", {'message': msg,})
            else:
                notification.send([sender], "messages_sent", {'message': msg,})
        return message_list
开发者ID:jakebarnwell,项目名称:PythonGenerator,代码行数:26,代码来源:forms.py


示例7: edit

def edit(request, id, form_class=BlogForm, template_name="blog/edit.html"):
    post = get_object_or_404(Post, id=id)
    if request.method == "POST":
        if post.author != request.user:
            request.user.message_set.create(message="You can't edit posts that aren't yours")
            return HttpResponseRedirect(reverse("blog_list_yours"))
        if request.POST["action"] == "update":
            blog_form = form_class(request.user, request.POST, instance=post)
            if blog_form.is_valid():
                blog = blog_form.save(commit=False)
                blog.save()
                request.user.message_set.create(message=_("Successfully updated post '%s'") % blog.title)
                if notification:
                    if blog.status == 2: # published
                        if friends: # @@@ might be worth having a shortcut for sending to all friends
                            notification.send((x['friend'] for x in Friendship.objects.friends_for_user(blog.author)), "blog_friend_post", {"post": blog})
                
                return HttpResponseRedirect(reverse("blog_list_yours"))
        else:
            blog_form = form_class(instance=post)
    else:
        blog_form = form_class(instance=post)

    return render_to_response(template_name, {
        "blog_form": blog_form,
        "post": post,
    }, context_instance=RequestContext(request))
开发者ID:jialei,项目名称:linkedby,代码行数:27,代码来源:views.py


示例8: notify_about_event

def notify_about_event(instance, notice_type, employers):
    subscribers = Student.objects.filter(subscriptions__in=employers)
    to_users = list(set(map(lambda n: n.user, subscribers)))
    if not instance.is_public:
        to_users = filter(lambda u: Invitee.objects.filter(student = u.student, event=instance).exists(), to_users)
    # Batch the sending by unique groups of subscriptions.
    # This way someone subscribed to A, B, and C gets only one email.
    subscribers_by_user = {}
    employername_table = {}
    for employer in employers:
        employername_table[str(employer.id)] = employer.name
        for to_user in to_users:
            if to_user.student in employer.subscribers.all():
                if to_user.id in subscribers_by_user:
                    subscribers_by_user[to_user.id].append(employer.id)
                else:
                    subscribers_by_user[to_user.id] = [employer.id]
    subscription_batches = {}
    for userid,employerids in subscribers_by_user.items():
        key = ':'.join(map(lambda n: str(n), employerids))
        subscription_batches[key] = userid
    for key,userids in subscription_batches.items():
        employer_names = map(lambda n: employername_table[n], key.split(':'))
        has_word = "has" if len(employer_names)==1 else "have"
        employer_names = english_join(employer_names)
        for to_user in to_users:
            notification.send([to_user], notice_type, {
                'name': to_user.first_name,
                'employer_names': employer_names,
                'has_word': has_word,
                'event': instance,
            })
开发者ID:Dpetters,项目名称:Umeqo,代码行数:32,代码来源:models.py


示例9: price_add

def price_add(request, form_class=PriceForm, template_name="product/price_add.html"):
    if request.user.is_authenticated() and request.method == "POST":
        if request.POST["action"] == "create":
            product_form = form_class(request.POST)
            if product_form.is_valid():
                product = product_form.save(commit=False)
                product.creator = request.user
                product.save()
#                product.members.add(request.user)
#                product.save()
                if notification:
                    # @@@ might be worth having a shortcut for sending to all users
                    notification.send(User.objects.all(), "product_new_product", {"product": product}, queue=True)
                    if friends: # @@@ might be worth having a shortcut for sending to all friends
                        notification.send((x['friend'] for x in Friendship.objects.friends_for_user(product.creator)), "product_friend_product", {"product": product})
                #return render_to_response("base.html", {
                #}, context_instance=RequestContext(request))
                return HttpResponseRedirect(product.get_absolute_url())
        else:
            product_form = form_class()
    else:
        product_form = form_class()

    return render_to_response(template_name, {
        "product_form": product_form,
    }, context_instance=RequestContext(request))
开发者ID:flynhigher,项目名称:terry-play-ground,代码行数:26,代码来源:views.py


示例10: group

def group(request, group_slug=None, form_class=BasicGroupUpdateForm, template_name="basic_groups/group.html"):
    group = get_object_or_404(BasicGroup, slug=group_slug)
    
    group_form = form_class(request.POST or None, instance=group)
    
    action = request.POST.get('action')
    
    if action == "update" and group_form.is_valid():
        group = group_form.save()
    elif action == "join":
        group.members.add(request.user)
        request.user.message_set.create(message="You have joined the group %s" % group.name)
        if notification:
            notification.send([group.creator], "groups_created_new_member", {"user": request.user, "group": group})
            notification.send(group.members.all(), "groups_new_member", {"user": request.user, "group": group})
    elif action == "leave":
        group.members.remove(request.user)
        request.user.message_set.create(message="You have left the group %s" % group.name)
        if notification:
            pass # @@@ no notification on departure yet
    
    if not request.user.is_authenticated():
        is_member = False
    else:
        is_member = group.user_is_member(request.user)
    
    return render_to_response(template_name, {
        "group_form": group_form,
        "group": group,
        "is_member": is_member,
    }, context_instance=RequestContext(request))
开发者ID:rhec,项目名称:pinax,代码行数:31,代码来源:views.py


示例11: edit

def edit(request,incident_id=None,form_class=EditIncidentForm, template_name='incidents/create.html'):
    incident = get_object_or_404(Incident,id=incident_id)
    incdict = incident.__dict__
    incdict['priority'] = incdict['priority_id']
    incdict['status'] = incdict['status_id']
    incident_form = form_class(request.POST or incdict)
    if request.POST and incident_form.is_valid():
        fcd = incident_form.cleaned_data
        for k in fcd.keys():
                incident.__dict__[k] = fcd[k] 
        isaved = incident_form.save(commit=False)
        incident.priority = isaved.priority
        incident.status = isaved.status
        incident.mentor = request.user
        incident.save()
        if incident.priority.hierarchy == 5:
            admins = User.objects.filter(is_superuser = 1)
            for admin in admins:
                notification.send([admin], "new_high_priority_manager", {"date": datetime.now(),
                                                                        "incident":incident,
                                                                        "categories":incident.categories,
                                                                        "author":request.user,
                                                                        "description":incident.description})
        return HttpResponseRedirect('/incidents/incident/'+str(incident_id)+'/')
    return render_to_response(template_name, {
        "incident_form" : incident_form,
        "action" : 'Edit',
        }, context_instance = RequestContext(request))
开发者ID:radowit,项目名称:bummer,代码行数:28,代码来源:views.py


示例12: promo_add

def promo_add(request):
    """
    Process a new promo submission.
    """

    if request.method == "POST":
        form = PromoForm(request.POST)
        if form.is_valid():
            promo = form.save(commit=False)
            promo.submitter = request.user
            promo.save()
            if notification:
                to_user  = User.objects.all()[0]
                from_user  = User.objects.all()[0]
                notification.send([to_user], "promo_submitted", "you have received a promo.", [from_user])
            request.user.message_set.create(
                message='Your promo has been submitted.')

            return HttpResponseRedirect(reverse('promos_promo_list'))

    else:
        form = PromoForm()

    return render_to_response(
              'promos/promo_add.html',
              {'form':form},
              context_instance=RequestContext(request))
开发者ID:gc2gh,项目名称:django-newsroom,代码行数:27,代码来源:views.py


示例13: reply_to_thread

def reply_to_thread(thread,sender, body):  
    new_message = Message.objects.create(body=body, sender=sender)
    new_message.parent_msg = thread.latest_msg
    thread.latest_msg = new_message
    thread.all_msgs.add(new_message)
    thread.replied = True
    thread.save()
    new_message.save()
    
    recipients = []
    for participant in thread.participants.all():
        participant.deleted_at = None
        participant.save()
        if sender != participant.user: # dont send emails to the sender!
            recipients.append(participant.user)
    
    sender_part = Participant.objects.get(thread=thread, user=sender)
    sender_part.replied_at = sender_part.read_at = datetime.datetime.now()
    sender_part.save()
    
    if notification:
        for r in recipients:
            if tm_settings.THREADED_MESSAGES_USE_SENDGRID:
                reply_email = sendgrid_parse_api.utils.create_reply_email(tm_settings.THREADED_MESSAGES_ID, r, thread)
                notification.send(recipients, "received_email", 
                                        {"thread": thread,
                                         "message": new_message},
                                        from_email=reply_email.get_reply_email())
            else:
                notification.send([r], "received_email", 
                                    {"thread": thread,
                                     "message": new_message})
        
    return (thread, new_message)
开发者ID:michaelBenin,项目名称:django-threaded-messages,代码行数:34,代码来源:utils.py


示例14: send_document_notifications

 def send_document_notifications(sender, instance=None, **kwargs):
     if instance is None:
         return
     document = instance
     if not document.is_public():
         return
     subs = Subscription.objects.filter(author=document.author)
     for org in document.author.organization_set.all():
         subs |= Subscription.objects.filter(organization=org)
     for tag in document.tags.all():
         subs |= Subscription.objects.filter(tag=tag)
     recipients = []
     if document.in_reply_to_id:
         campaign = None
         try:
             campaign = document.in_reply_to.campaign
         except Campaign.DoesNotExist:
             pass
         if campaign:
             subs |= Subscription.objects.filter(campaign=campaign)
     for sub in subs:
         if NotificationBlacklist.objects.filter(email=sub.subscriber.email).exists():
             continue
         if document.adult and not sub.subscriber.profile.show_adult_content:
             continue
         log, created = DocumentNotificationLog.objects.get_or_create(recipient=sub.subscriber, document=document)
         if created:
             recipients.append(sub.subscriber)
     if recipients:
         notification.send(recipients, "new_post", {"document": document})
开发者ID:Shidash,项目名称:btb,代码行数:30,代码来源:models.py


示例15: profile_pre_save

def profile_pre_save(instance, sender, **kw):
    matching_profiles = Profile.objects.filter(id=instance.id)
    if matching_profiles.count() == 0:
        return
    if instance.is_active and not matching_profiles.get().is_active and \
            'notification' in settings.INSTALLED_APPS:
        notification.send([instance, ], "account_active")
开发者ID:Geocent,项目名称:geonode,代码行数:7,代码来源:models.py


示例16: create

def create(request, form_class=TribeForm, template_name="tribes/create.html"):
    if request.user.is_authenticated() and request.method == "POST":
        if request.POST["action"] == "create":
            tribe_form = form_class(request.POST)
            if tribe_form.is_valid():
                tribe = tribe_form.save(commit=False)
                tribe.creator = request.user
                tribe.save()
                tribe.members.add(request.user)
                tribe.save()
                # @@@ this is just temporary to give tribes a single calendar -- will revisit during whole
                # tribe/project merge effort
                calendar = Calendar(name = "%s Calendar" % tribe.name)
                calendar.save()
                CalendarRelation.objects.create_relation(calendar, tribe, distinction="default", inheritable=True)
                if notification:
                    # @@@ might be worth having a shortcut for sending to all users
                    notification.send(User.objects.all(), "tribes_new_tribe", {"tribe": tribe}, queue=True)
                    if friends: # @@@ might be worth having a shortcut for sending to all friends
                        notification.send((x['friend'] for x in Friendship.objects.friends_for_user(tribe.creator)), "tribes_friend_tribe", {"tribe": tribe})
                #return render_to_response("base.html", {
                #}, context_instance=RequestContext(request))
                return HttpResponseRedirect(tribe.get_absolute_url())
        else:
            tribe_form = form_class()
    else:
        tribe_form = form_class()
    
    return render_to_response(template_name, {
        "tribe_form": tribe_form,
    }, context_instance=RequestContext(request))
开发者ID:bikeshkumar,项目名称:pinax,代码行数:31,代码来源:views.py


示例17: new_comment

def new_comment(sender, instance, **kwargs):
    if isinstance(instance.content_object, Topic):
        topic = instance.content_object
        topic.modified = datetime.now()
        topic.save()
        if notification:
            notification.send([topic.creator], "tribes_topic_response", {"user": instance.user, "topic": topic})
开发者ID:RockHoward,项目名称:django-topics,代码行数:7,代码来源:models.py


示例18: watch

def watch(request, listing_id):
    ''' takes a POST and makes a watcher of the request.user

    '''
    listing = get_object_or_404(Listing, id=listing_id)

    if request.method == 'POST':
        if request.POST["action"] == "watch":
            w, created = WatchRelation.objects.get_or_create(
                watcher=request.user,
                listing=listing
            )
            notification.send([listing.owner], "listing_watch_start",{
                "listing":listing,
                "watcher":w.watcher,}
            )

        elif request.POST["action"] == "stop":
            w = WatchRelation.objects.get(listing=listing,
                    watcher=request.user)
            w.delete()
            notification.send([listing.owner], "listing_watch_stop",{
                "listing":listing,
                "watcher":w.watcher,}
            )
        return HttpResponseRedirect(reverse('listings_all'))

    else:
        return HttpResponseRedirect(reverse('listings_all'))
开发者ID:cjs,项目名称:bme,代码行数:29,代码来源:views.py


示例19: accept

    def accept(self, user):
        """Accept this nomination for the nominee.

        Also awards, if already approved.
        """
        if not self.allows_accept(user):
            raise NominationAcceptNotAllowedException()
        self.accepted = True
        nomination_will_be_accepted.send(sender=self.__class__,
                                         nomination=self)
        self.save()
        nomination_was_accepted.send(sender=self.__class__,
                                     nomination=self)

        if notification:
            if self.badge.creator:
                notification.send([self.badge.creator], 'nomination_accepted',
                                  dict(nomination=self,
                                       protocol=DEFAULT_HTTP_PROTOCOL))
            if self.creator:
                notification.send([self.creator], 'nomination_accepted',
                                  dict(nomination=self,
                                       protocol=DEFAULT_HTTP_PROTOCOL))

        return self
开发者ID:no-dice,项目名称:django-badger,代码行数:25,代码来源:models.py


示例20: notify_topic_subscribers

def notify_topic_subscribers(post):
    topic = post.topic
    if post != topic.head:
        delete_url = reverse("pybb:delete_subscription", args=[post.topic.id])
        current_site = Site.objects.get_current()
        if notification:
            notification.send(
                topic.subscribers.exclude(pk=post.user.pk),
                "forum_subscription_reply",
                {"site": current_site, "post": post, "delete_url": delete_url},
            )
        else:
            for user in topic.subscribers.all():
                if user != post.user:
                    try:
                        email_validator.clean(user.email)
                    except:
                        # invalid email
                        continue
                    old_lang = translation.get_language()
                    lang = user.get_profile().language or dict(settings.LANGUAGES)[settings.LANGUAGE_CODE.split("-")[0]]
                    translation.activate(lang)
                    subject = render_to_string(
                        "pybb/mail_templates/subscription_email_subject.html", {"site": current_site, "post": post}
                    )
                    # Email subject *must not* contain newlines
                    subject = "".join(subject.splitlines())
                    message = render_to_string(
                        "pybb/mail_templates/subscription_email_body.html",
                        {"site": current_site, "post": post, "delete_url": delete_url},
                    )
                    send_mail(subject, message, settings.DEFAULT_FROM_EMAIL, [user.email], fail_silently=True)
                    translation.activate(old_lang)
开发者ID:wraithan,项目名称:pybbm,代码行数:33,代码来源:subscription.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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