Beispiel #1
0
def say(template="talk", count=DEFAULT_MESSAGE_COUNT):
    """ Arbitrary template finder and messager.

    Takes a template name, count, outputs dict. """

    contacts_to_say = Contact.objects.sample(count)
    return build_message_dict(contacts_to_say, get_templater(template.lower()))
Beispiel #2
0
def panic(count=DEFAULT_MESSAGE_COUNT):
    """ Tell people I'm not okay.

    Differs from say panic in that this is a hard panic, ie if the safehouse
    is in 'save messages' mode it will cancel that to ensure people can
    reach you. """

    model.config('tag', None)
    contacts_to_panic = Contact.objects.sample(count)
    return build_message_dict(contacts_to_panic, get_templater('panic'))
Beispiel #3
0
 def testThenTriesModelTemplates(self):
     t2 = Template.objects.create(name="test", text="a test")
     template = util.get_templater("test")(self.contact)
     self.assertIn("a test", template)
Beispiel #4
0
 def testDefaultsToDjangoTemplates(self):
     t2 = Template.objects.create(name="panic", text="test")
     template = util.get_templater("panic")(self.contact)
     self.assertNotIn("test", template)
Beispiel #5
0
def inform(*args):
    """ Set uninformed contacts to informed and return messages for them. """
    contacts_to_inform = Contact.objects.inform_all()  # Has side effects
    return build_message_dict(contacts_to_inform, get_templater('inform'))