예제 #1
0
파일: contact.py 프로젝트: hwayne/safehouse
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()))
예제 #2
0
파일: contact.py 프로젝트: hwayne/safehouse
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'))
예제 #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)
예제 #4
0
 def testDefaultsToDjangoTemplates(self):
     t2 = Template.objects.create(name="panic", text="test")
     template = util.get_templater("panic")(self.contact)
     self.assertNotIn("test", template)
예제 #5
0
파일: contact.py 프로젝트: hwayne/safehouse
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'))