Esempio n. 1
0
 def send_hello_sms(self):
     if not self.phone_number:
         raise ValueError('User has to have a phone number'
                          'to send a sms message.')
     hello = self.HelloSMSMessage(
         username=self.username,
         phone_number=self.phone_number,
     )
     Msg.new(hello, dispatch_now=True)
Esempio n. 2
0
def social_notify(request):
    from common.im.twitter import Twitter
    from common.im.blip import Blip
    from django.contrib.auth.models import User
    from msg.models import Msg

    if request.POST.has_key('msg'):
        msg = request.POST['msg'].strip()
        if request.POST.has_key('to_blip'):
            b = Blip()
            b.send(msg)
        if request.POST.has_key('to_twitter'):
            t = Twitter()
            t.send(msg)
        if request.POST.has_key('to_users_pl') or request.POST.has_key('to_users_en'):
            if request.POST.has_key('to_users_pl'):
                users = UserProfile.objects.filter(pref_lang='pl')
            else:
                users = UserProfile.objects.filter(pref_lang='en')

            for user in users:
                m = Msg()
                m.sender = request.user
                m.receiver = user.user
                m.content = msg
                m.is_public = False
                m.is_gang = False
                m.save()
            request.user.message_set.create(message="PM x%d" % len(users))

    request.user.message_set.create(message="Wysłano wiadomości")
    return HttpResponseRedirect('/intranet/')
Esempio n. 3
0
def send_email(sender, instance, created, **kwargs):
    if not created:
        return

    Msg.new(instance, dispatch_now=True)
Esempio n. 4
0
    def test_email_not_sent_until_dispatched(self):
        self._create_test_handler()
        Msg.new(None, dispatch_now=False)

        self.assertEqual(len(mail.outbox), 0)
Esempio n. 5
0
 def test_email_handler_not_found(self):
     with self.assertRaises(MissingHandlerException):
         Msg.new(None, dispatch_now=True)
Esempio n. 6
0
 def test_email_handler(self):
     self._create_test_handler()
     Msg.new(None, dispatch_now=True)
     self.assertEqual(len(mail.outbox), 1)
Esempio n. 7
0
 def test_msg_status_is_done(self):
     self._create_handler()
     msg = Msg.new(None, dispatch_now=True)
     self.assertEqual(msg.status, Msg.Status.DONE.value)