Пример #1
0
    def create_village(self, msg, arg=None):
        self.debug("SMSFORUM:CREATEVILLAGE")        
        if arg is None or len(arg)<1:
            self.__reply(msg, "create-village-fail_no-village-name")
            return True
        else:
            village = arg

        if len(Village.objects.filter(name=village)) != 0:
            self.__reply(msg, "create-village-fail_village-already-exists %(village)s", {'village':village})
            return True
        try:
            # TODO: add administrator authentication
            if len(village) > MAX_VILLAGE_NAME_LEN:
                self.__reply(msg, "create-village-fail_name-too-long %(village)s %(max_char)d", \
                             {'village':village, 'max_char':MAX_VILLAGE_NAME_LEN} )
                return True
            ville = Village(name=village)
            ville.save()
            # self.village_matcher.add_target((village,ville))
            self.__reply(msg, "create-village-success %(village)s", {'village':village} )
        except:
            self.debug( traceback.format_exc() )
            traceback.print_exc()
            self.__reply(msg, "internal-error")

        return True
Пример #2
0
 def setUp(self):
     TestScript.setUp(self)
     ville = Village(name='nonexistant1')
     ville.save()
     ville = Village(name='nonexistant2')
     ville.save()
Пример #3
0
 def testAliases(self):
     v = Village(name="original")
     v.save()
     v2 = CommunityAlias(community=v.community, alias="alias")
     v2.save()
     test_outgoing_message_log = """