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

Python models.Message类代码示例

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

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



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

示例1: sendSMS

def sendSMS(request, facility_pk=0):
    groups = Group.objects.filter(name__in=['FHD', 'HC',
                                            'Incharge', 'Records Assistant', 'VHT']).order_by('name')
    facility = HealthFacility.objects.get(pk=facility_pk)
    if request.method == "GET":
        return render_to_response("cvs/facility/partials/facility_sendsms.html",
                                  {'groups': groups, 'facility': facility},
                                  context_instance=RequestContext(request)
                                  )
    else:
        msg = request.POST['msg']
        grp = request.POST['group']
        if not grp:
            json = simplejson.dumps({'error': "role is required"})
            return HttpResponse(json, mimetype='application/json')
        if not msg:
            json = simplejson.dumps({'error': "message is required"})
            return HttpResponse(json, mimetype='application/json')
        reporters = HealthProvider.objects.filter(facility=request.POST['facility'],
                                                  groups__in=[grp])
        recipient_count = reporters.count()
        conns = Connection.objects.filter(contact__in=reporters)
        Message.mass_text(msg, conns, status='Q', batch_status='Q')
        json = simplejson.dumps({'msg': "sent to %s recipients" % recipient_count, 'error': ""})
        return HttpResponse(json, mimetype='application/json')
开发者ID:unicefuganda,项目名称:rapidsms-cvs,代码行数:25,代码来源:facilities.py


示例2: create_poll

def create_poll(name, type, question, default_response, contacts, user, start_immediately=False):
    localized_messages = {}
    bad_conns = Blacklist.objects.values_list('connection__pk', flat=True).distinct()
    contacts = contacts.exclude(connection__in=bad_conns)
    poll = Poll.objects.create(name=name, type=type, question=question, default_response=default_response, user=user)
    for language in dict(settings.LANGUAGES).keys():
        if language == "en":
            """default to English for contacts with no language preference"""
            localized_contacts = contacts.filter(language__in=["en", ''])
        else:

            localized_contacts = contacts.filter(language=language)
        if localized_contacts:
            if start_immediately:
                messages = Message.mass_text(gettext_db(field=question, language=language),
                                             Connection.objects.filter(contact__in=localized_contacts).distinct(),
                                             status='Q', batch_status='Q')
            else:
                messages = Message.mass_text(gettext_db(field=question, language=language),
                                             Connection.objects.filter(contact__in=localized_contacts).distinct(),
                                             status='L', batch_status='L')

            poll.messages.add(*messages.values_list('pk', flat=True))

    if 'django.contrib.sites' in settings.INSTALLED_APPS:
        poll.sites.add(Site.objects.get_current())
    if start_immediately:
        poll.start_date = datetime.datetime.now()
        poll.save()
    return poll
开发者ID:mbanje,项目名称:Ureport_project3,代码行数:30,代码来源:utils.py


示例3: create_message

    def create_message(self, id, backend, batch=None):
        fake_connection = Connection(identity=str(id))
        fake_connection.backend, created = Backend.objects.get_or_create(name=backend)
        fake_connection.save()
        message = Message(status='Q', direction="O")
        message.connection = fake_connection

        message.batch = self.batch1 if batch is None else batch
        message.save()
        return message
开发者ID:Senescyt,项目名称:rapidsms-httprouter,代码行数:10,代码来源:test_send_messages.py


示例4: perform

    def perform(self, request, results):
        if results is None or len(results) == 0:
            return ('A message must have one or more recipients!', 'error')

        if request.user and request.user.has_perm('contact.can_message'):
            connections = \
                list(Connection.objects.filter(contact__in=results).distinct())

            text = self.cleaned_data.get('text', "")
            text = text.replace('%', u'\u0025')

            messages = Message.mass_text(text, connections)

            MassText.bulk.bulk_insert(send_pre_save=False,
                    user=request.user,
                    text=text,
                    contacts=list(results))
            masstexts = MassText.bulk.bulk_insert_commit(send_post_save=False, autoclobber=True)
            masstext = masstexts[0]
            if settings.SITE_ID:
                masstext.sites.add(Site.objects.get_current())

            return ('Message successfully sent to %d numbers' % len(connections), 'success',)
        else:
            return ("You don't have permission to send messages!", 'error',)
开发者ID:unicefzambia,项目名称:rapidsms-contact,代码行数:25,代码来源:forms.py


示例5: start

    def start(self):
        """
        This starts the poll: outgoing messages are sent to all the contacts
        registered with this poll, and the start date is updated accordingly.
        All incoming messages from these users will be considered as
        potentially a response to this poll.
        """
        if self.start_date:
            return
        contacts = self.contacts
        localized_messages = {}
        for language in dict(settings.LANGUAGES).keys():
            if language == "en":
                """default to English for contacts with no language preference"""
                localized_contacts = contacts.filter(language__in=["en", ''])
            else:

                localized_contacts = contacts.filter(language=language)
            if localized_contacts.exists():
                messages = Message.mass_text(gettext_db(field=self.question, language=language), Connection.objects.filter(contact__in=localized_contacts).distinct(), status='Q', batch_status='Q')
                #localized_messages[language] = [messages, localized_contacts]
                self.messages.add(*messages.values_list('pk',flat=True))

        self.start_date = datetime.datetime.now()
        self.save()
        poll_started.send(sender=self)
开发者ID:krelamparo,项目名称:edtrac,代码行数:26,代码来源:models.py


示例6: perform

    def perform(self, request, results):
        if results is None or len(results) == 0:
            return ("A message must have one or more recipients!", "error")

        if request.user and request.user.has_perm("contact.can_message"):
            if type(results[0]).__name__ == "Reporters":

                con_ids = [
                    r.default_connection.split(",")[1] if len(r.default_connection.split(",")) > 1 else 0
                    for r in results
                ]
                connections = list(Connection.objects.filter(pk__in=con_ids).distinct())
                contacts = list(Contact.objects.filter(pk__in=results.values_list("id", flat=True)))
            else:
                connections = list(
                    Connection.objects.filter(contact__pk__in=results.values_list("id", flat=True)).distinct()
                )
                contacts = list(results)
            text = self.cleaned_data.get("text", "")
            text = text.replace("%", u"\u0025")
            messages = Message.mass_text(text, connections)

            MassText.bulk.bulk_insert(send_pre_save=False, user=request.user, text=text, contacts=contacts)
            masstexts = MassText.bulk.bulk_insert_commit(send_post_save=False, autoclobber=True)
            masstext = masstexts[0]
            if settings.SITE_ID:
                masstext.sites.add(Site.objects.get_current())

            return ("Message successfully sent to %d numbers" % len(connections), "success")
        else:
            return ("You don't have permission to send messages!", "error")
开发者ID:asseym,项目名称:rapidsms-contact,代码行数:31,代码来源:forms.py


示例7: perform

    def perform(self, request, results):
        if type(results).__name__ != 'QuerySet':
            results = Contact.objects.filter(pk__in=request.REQUEST.get('results', ""))
        if results is None or len(results) == 0:
            return 'A message must have one or more recipients!', 'error'

        if request.user and request.user.has_perm('contact.can_message'):
            if type(results[0]).__name__ == 'Reporters':

                con_ids = \
                    [r.default_connection.split(',')[1] if len(r.default_connection.split(',')) > 1 else 0 for r in
                     results]
                connections = list(Connection.objects.filter(pk__in=con_ids).distinct())
                contacts = list(Contact.objects.filter(pk__in=results.values_list('id', flat=True)))
                print contacts
            else:
                connections = \
                    list(Connection.objects.filter(contact__pk__in=results.values_list('id', flat=True)).distinct())
                contacts = list(results)
            text = self.cleaned_data.get('text', "")
            text = text.replace('%', u'\u0025')
            messages = Message.mass_text(text, connections)

            MassText.bulk.bulk_insert(send_pre_save=False,
                                      user=request.user,
                                      text=text,
                                      contacts=contacts)
            masstexts = MassText.bulk.bulk_insert_commit(send_post_save=False, autoclobber=True)
            masstext = masstexts[0]
            if settings.SITE_ID:
                masstext.sites.add(Site.objects.get_current())

            return 'Message successfully sent to %d numbers' % len(connections), 'success',
        else:
            return "You don't have permission to send messages!", 'error',
开发者ID:unicefuganda,项目名称:rapidsms-contact,代码行数:35,代码来源:forms.py


示例8: mass_text

    def mass_text(self):
        # get one scriptprogress since they are all supposed to be on the same step
        if self.exists():
            prog = self[0]
        else:
            return False
        if prog.step.poll:
            text = prog.step.poll.question
        elif prog.step.email:
            text = prog.step.email
        else:
            text = prog.step.message

        for language in dict(settings.LANGUAGES).keys():
            if language == "en":
                """default to English for contacts with no language preference"""
                localized_progs = self.filter(Q(language__in=["en", '']) | Q(language=None))
            else:
                localized_progs = self.filter(language=language)

            if localized_progs.exists():
                localized_conns = localized_progs.values_list('connection', flat=True)
                messages = Message.mass_text(gettext_db(field=text, language=language),
                                             Connection.objects.filter(pk__in=localized_conns).distinct(), status='P')
        return True
开发者ID:askpaul,项目名称:rapidsms-script,代码行数:25,代码来源:managers.py


示例9: start

    def start(self):
        """
        This starts the poll: outgoing messages are sent to all the contacts
        registered with this poll, and the start date is updated accordingly.
        All incoming messages from these users will be considered as
        potentially a response to this poll.
        """
        if self.start_date:
            return
        contacts = self.contacts
        localized_messages = {}
        for language in dict(settings.LANGUAGES).keys():
            if language == "en":
                """default to English for contacts with no language preference"""
                localized_contacts = contacts.filter(language__in=["en", ''])
            else:

                localized_contacts = contacts.filter(language=language)
            if localized_contacts.exists():
                messages = Message.mass_text(gettext_db(field=self.question, language=language), Connection.objects.filter(contact__in=localized_contacts).distinct(), status='Q', batch_status='Q')
                localized_messages[language] = [messages, localized_contacts]

        # This is the fastest (pretty much only) was to get messages M2M into the
        # DB fast enough at scale
        cursor = connection.cursor()
        for language in localized_messages.keys():

            raw_sql = "insert into poll_poll_messages (poll_id, message_id) values %s" % ','.join(\
                ["(%d, %d)" % (self.pk, m.pk) for m in localized_messages.get(language)[0].iterator()])
            cursor.execute(raw_sql)

        self.start_date = datetime.datetime.now()
        self.save()
        poll_started.send(sender=self)
开发者ID:revence27,项目名称:rapidsms-polls,代码行数:34,代码来源:models.py


示例10: add_to_poll

def add_to_poll(poll, contacts):
    localized_messages = {}
    bad_conns = Blacklist.objects.values_list('connection__pk', flat=True).distinct()
    contacts = contacts.exclude(connection__in=bad_conns)
    for language in dict(settings.LANGUAGES).keys():
        if language == "en":
            """default to English for contacts with no language preference"""
            localized_contacts = contacts.filter(language__in=["en", ''])
        else:

            localized_contacts = contacts.filter(language=language)
        if localized_contacts:
            messages = Message.mass_text(gettext_db(field=poll.question, language=language),
                                         Connection.objects.filter(contact__in=localized_contacts).distinct(),
                                         status='Q', batch_status='Q')

            localized_messages[language] = [messages, localized_contacts]



            # This is the fastest (pretty much only) was to get contacts and messages M2M into the
            # DB fast enough at scale
        #    cursor = connection.cursor()
        #    for language in localized_messages.keys():
        #        raw_sql = "insert into poll_poll_contacts (poll_id, contact_id) values %s" % ','.join(\
        #            ["(%d, %d)" % (poll.pk, c.pk) for c in localized_messages.get(language)[1].iterator()])
        #        cursor.execute(raw_sql)
        #
        #        raw_sql = "insert into poll_poll_messages (poll_id, message_id) values %s" % ','.join(\
        #            ["(%d, %d)" % (poll.pk, m.pk) for m in localized_messages.get(language)[0].iterator()])
        #        cursor.execute(raw_sql)

    return poll
开发者ID:mbanje,项目名称:Ureport_project3,代码行数:33,代码来源:utils.py


示例11: perform

    def perform(self, request, results):
        if results is None or len(results) == 0:
            return ('A message must have one or more recipients!', 'error')

        if request.user and request.user.has_perm('contact.can_message'):
            blacklists = Blacklist.objects.values_list('connection')
            connections = \
                Connection.objects.filter(contact__in=results).exclude(pk__in=blacklists).distinct()

            text = self.cleaned_data.get('text', "")
            text = text.replace('%', u'\u0025')


            if not self.cleaned_data['text_luo'] == '':
                (translation, created) = \
                    Translation.objects.get_or_create(language='ach',
                        field=self.cleaned_data['text'],
                        value=self.cleaned_data['text_luo'])



            messages = Message.mass_text(text, connections)
            contacts=Contact.objects.filter(pk__in=results)

            MassText.bulk.bulk_insert(send_pre_save=False,
                    user=request.user,
                    text=text,
                    contacts=list(contacts))
            masstexts = MassText.bulk.bulk_insert_commit(send_post_save=False, autoclobber=True)
            masstext = masstexts[0]
            
            return ('Message successfully sent to %d numbers' % len(connections), 'success',)
        else:
            return ("You don't have permission to send messages!", 'error',)
开发者ID:JamesMura,项目名称:rapidsms-ureport,代码行数:34,代码来源:forms.py


示例12: perform

    def perform(self, request, results):
        from poll.models import gettext_db
        if results is None or len(results) == 0:
            return ('A message must have one or more recipients!', 'error')

        if request.user and request.user.has_perm('contact.can_message'):
            blacklists = Blacklist.objects.values_list('connection')
            
            #TODO: Revise for proper internationalization
            languages = ["fr"]
            text_fr = self.cleaned_data.get('text_fr', "")
            text_fr = text_fr.replace('%', u'\u0025')

            if not self.cleaned_data['text_en'] == '':
                languages.append('en')
                (translation, created) = \
                    Translation.objects.get_or_create(language='en',
                        field=self.cleaned_data['text_fr'],
                        value=self.cleaned_data['text_en'])

            if not self.cleaned_data['text_ki'] == '':
                languages.append('ki')
                (translation, created) = \
                    Translation.objects.get_or_create(language='ki',
                        field=self.cleaned_data['text_fr'],
                        value=self.cleaned_data['text_ki'])
            
            #Everyone gets a message in their language. This behavior may not be ideal
            #since one may wish to send out a non translated message to everyone regardless of language
            #TODO: allow sending of non translated message to everyone using a flag   
            total_connections = [] 
            for language in languages:        
                connections = Connection.objects.filter(contact__in=results.filter(language=language)).exclude(pk__in=blacklists).distinct()
                messages = Message.mass_text(gettext_db(field=text_fr, language=language), connections)
                contacts = Contact.objects.filter(pk__in=results)

                total_connections.extend(connections)
            #Bulk wont work because of a ManyToMany relationship to Contact on MassText
            #Django API does not allow bulk_create() to work with relation to multiple tables
            #TODO: Find work around
#            bulk_list = [
#                     MassText(user=request.user),
#                     MassText(text=text_fr),
#                     MassText(contacts=list(contacts))
#                     ]
#            masstext = MassText.objects.bulk_create(bulk_list)
            
            #The bulk_insert manager needs to be updated
            #TODO: investigate changes made in new Django that are not compatible with BulkInsertManager()
#            MassText.bulk.bulk_insert(send_pre_save=False,
#                    user=request.user,
#                    text=text_fr,
#                    contacts=list(contacts))
#            masstexts = MassText.bulk.bulk_insert_commit(send_post_save=False, autoclobber=True)
#            masstext = masstexts[0]
            
            return ('Message successfully sent to %d numbers' % len(total_connections), 'success',)
        else:
            return ("You don't have permission to send messages!", 'error',)
开发者ID:dadas16,项目名称:ureport,代码行数:59,代码来源:forms.py


示例13: test_can_send_mass_text_with_batch_name

    def test_can_send_mass_text_with_batch_name(self):
	messages_sent = Message.mass_text("MassTestTest-MESSAGE", [self.connection_1, self.connection_2],
					  batch_name="FOO")

	message_1 = Message.objects.get(pk=messages_sent[0].pk)
	message_2 = Message.objects.get(pk=messages_sent[1].pk)

	self.assertEqual(message_1.batch.name, "FOO")
	self.assertEqual(message_2.batch.name, "FOO")
开发者ID:Senescyt,项目名称:rapidsms-httprouter,代码行数:9,代码来源:tests.py


示例14: sites_postsave_handler

def sites_postsave_handler(sender, **kwargs):
    if 'django.contrib.sites' in settings.INSTALLED_APPS:
        if ((sender == Contact or sender in Contact.__subclasses__()) and kwargs['created']):
            ContactSite.objects.create(contact=kwargs['instance'], site=Site.objects.get_current())
        elif ((sender == User or sender in User.__subclasses__()) and kwargs['created']):
            UserSite.objects.create(user=kwargs['instance'], site=Site.objects.get_current())
        elif ((sender == Group or sender in Group.__subclasses__()) and kwargs['created']):
            GroupSite.objects.create(group=kwargs['instance'], site=Site.objects.get_current())
#        elif (sender == Connection and kwargs['created']):
#            ConnectionSite.objects.create(connection = kwargs['instance'], site=Site.objects.get_current())
        elif ((sender == Message or sender in Message.__subclasses__()) and kwargs['created']):
            MessageSite.objects.create(message=kwargs['instance'], site=Site.objects.get_current())
开发者ID:unicefuganda,项目名称:rapidsms-authsites,代码行数:12,代码来源:models.py


示例15: testAddBulk

    def testAddBulk(self):
	connection2 = Connection.objects.create(backend=self.backend, identity='8675309')
	connection3 = Connection.objects.create(backend=self.backend, identity='8675310')
	connection4 = Connection.objects.create(backend=self.backend, identity='8675311')

	# test that mass texting works with a single number
	msgs = Message.mass_text('Jenny I got your number', [self.connection])

	self.assertEquals(msgs.count(), 1)
	self.assertEquals(msgs[0].text, 'Jenny I got your number')

	# test no connections are re-created
	self.assertEquals(msgs[0].connection.pk, self.connection.pk)

	msgs = Message.mass_text('Jenny dont change your number',
				 [self.connection, connection2, connection3, connection4], status='L')
	self.assertEquals(str(msgs.values_list('status', flat=True).distinct()[0]), 'L')
	self.assertEquals(msgs.count(), 4)

	# test duplicate connections don't create duplicate messages
	msgs = Message.mass_text('Turbo King is the greatest!', [self.connection, self.connection])
	self.assertEquals(msgs.count(), 1)
开发者ID:Senescyt,项目名称:rapidsms-httprouter,代码行数:22,代码来源:tests.py


示例16: create_poll

def create_poll(name, type, question, default_response, contacts, user,start_immediately=False):
    localized_messages = {}
    bad_conns = Blacklist.objects.values_list('connection__pk', flat=True).distinct()
    contacts=contacts.exclude(connection__in=bad_conns)
    for language in dict(settings.LANGUAGES).keys():
        if language == "en":
            """default to English for contacts with no language preference"""
            localized_contacts = contacts.filter(language__in=["en", ''])
        else:

            localized_contacts = contacts.filter(language=language)
        if localized_contacts.exists():
            if start_immediately:
                messages = Message.mass_text(gettext_db(field=question, language=language), Connection.objects.filter(contact__in=localized_contacts).distinct(), status='Q', batch_status='Q')
            else:
                messages = Message.mass_text(gettext_db(field=question, language=language), Connection.objects.filter(contact__in=localized_contacts).distinct(), status='L', batch_status='L')
            localized_messages[language] = [messages, localized_contacts]
    poll = Poll.objects.create(name=name, type=type, question=question, default_response=default_response, user=user)

        
    # This is the fastest (pretty much only) was to get contacts and messages M2M into the
    # DB fast enough at scale
    cursor = connection.cursor()
    for language in localized_messages.keys():
        raw_sql = "insert into poll_poll_contacts (poll_id, contact_id) values %s" % ','.join(\
            ["(%d, %d)" % (poll.pk, c.pk) for c in localized_messages.get(language)[1].iterator()])
        cursor.execute(raw_sql)

        raw_sql = "insert into poll_poll_messages (poll_id, message_id) values %s" % ','.join(\
            ["(%d, %d)" % (poll.pk, m.pk) for m in localized_messages.get(language)[0].iterator()])
        cursor.execute(raw_sql)

    if 'django.contrib.sites' in settings.INSTALLED_APPS:
        poll.sites.add(Site.objects.get_current())
    if start_immediately:
        poll.start_date = datetime.datetime.now()
        poll.save()
    return poll
开发者ID:unicefzambia,项目名称:rapidsms-ureport,代码行数:38,代码来源:utils.py


示例17: handle

    def handle(self, **options):
        text    = options.get('text') or 'If you want to stop receiving FREE messages from Mother Reminder please reply with STOP.'
        outmsgs = ReminderMessage.as_hash().keys()
        outmsgs.sort()
        try:
            lastweek  = outmsgs[-1]
            query     = Contact.objects.filter(interested = True).exclude(connection  = None)
            if not options.get('all'):
                query.filter(last_menses__lt = (datetime.now() - timedelta(weeks=lastweek)))

            for mother in query:
                last_optout = Message.objects.filter(connection=mother.default_connection).filter(text=text).order_by('-date')
                message     = Message(connection  = mother.default_connection, direction  = 'O', status = 'Q', text = text)
                if not last_optout:
                    message.save()
                else:
                    if last_optout[0].date + timedelta(weeks=8) <= datetime.now():
                        message.save()

                        # msg.save()
                        # application, batch, connection, date, direction, flags, id, in_response_to, poll, poll_responses, priority, responses, status, submissions, text
        except IndexError:
            pass
开发者ID:revence27,项目名称:mother,代码行数:23,代码来源:invite_opt_out.py


示例18: handle

    def handle(self, message):
        # We fall to this app when xform fails to match message
        # Also added here is a special chat group to share messages
        # between members belonging to the same health facility
        groups = []
        mentions = []
        for token in message.text.split():
            if token.startswith("#"):
                groups.append(token[1:])
            if token.startswith("@"):
                mentions.append(token[1:])
        groups = [i.lower() for i in groups]
        mentions = [i.lower() for i in mentions]
        if 'chat' in groups or 'chat' in mentions:
            sender = HealthProvider.objects.filter(connection=message.connection)
            recipients = []
            if sender:
                sender = sender[0]
                facility = sender.facility
                if facility:
                    recipients = HealthProvider.objects.filter(
                        facility=sender.facility).exclude(connection__identity=None)
                    recipients = recipients.exclude(connection=sender.default_connection)
                    text = "{0}: {1}".format(sender.default_connection.identity, message.text)
                    sender_text = "sent to {0} members of {1}".format(
                        len(recipients), sender.facility)
                    conns = Connection.objects.filter(contact__in=recipients)
                    if conns:
                        Message.mass_text(text, conns, status='Q', batch_status='Q')
                        message.respond(sender_text)
                        return True

        if message.connection.contact and not ScriptProgress.objects.filter(connection=message.connection).exists():
            if message.connection.contact.healthproviderbase:
                message.respond("Thank you for your message. We have forwarded to your DHT for follow-up. If this was meant to be a weekly report, please check and resend.")
                return True
        return False
开发者ID:Moverr,项目名称:mtrack,代码行数:37,代码来源:app.py


示例19: create_message_without_batch

 def create_message_without_batch(self, id, backend):
     fake_connection = Connection(identity=str(id))
     fake_connection.backend, created = Backend.objects.get_or_create(name=backend)
     fake_connection.save()
     message = Message(status='Q', direction="O")
     message.text = "this is an important message"
     message.connection = fake_connection
     message.batch = None
     message.save()
     return message
开发者ID:Senescyt,项目名称:rapidsms-httprouter,代码行数:10,代码来源:test_send_messages.py


示例20: send_messages_to_contacts

def send_messages_to_contacts(poll):
    contacts = poll.contacts
    localized_messages = {}
    for language in dict(settings.LANGUAGES).keys():
        if language == "en":
            """default to English for contacts with no language preference"""
            localized_contacts = contacts.filter(language__in=["en", ''])
        else:

            localized_contacts = contacts.filter(language=language)
        if localized_contacts.exists():
            messages = Message.mass_text(gettext_db(field=poll.question, language=language),
                                         Connection.objects.filter(contact__in=localized_contacts).distinct(),
                                         status='Q', batch_status='Q')
            #localized_messages[language] = [messages, localized_contacts]
            poll.messages.add(*messages.values_list('pk', flat=True))
开发者ID:Senescyt,项目名称:rapidsms-polls,代码行数:16,代码来源:models.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python router.get_router函数代码示例发布时间:2022-05-26
下一篇:
Python utils.render_to_response函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap