def imc_set_square(self, sqid, title, start_time, end_time, hidden, intro, 
                       logo, category):

        if start_time != None:
            start_time = com.isoptime(start_time)
            if start_time == None:
                return 'Eparameter'

        if end_time != None:
            end_time = com.isoptime(end_time)
            if end_time == None:
                return 'Eparameter'

        if(
            type(sqid) != int or
            type(title) != str or
            (start_time != None and type(start_time) != datetime.datetime) or
            (end_time != None and type(end_time) != datetime.datetime) or
            type(hidden) != bool or
            type(intro) != str or
            type(logo) != str or
            type(category) != list
        ):
            return 'Eparameter'

        for cateid in category:
            if(
                type(cateid) != int
            ):
                return 'Eparameter'

        if len(title) < self.TITLE_LEN_MIN:
            return 'Etitle_too_short'
        elif len(title) > self.TITLE_LEN_MAX:
            return 'Etitle_too_long'
        elif len(intro) < self.INTRO_LEN_MIN:
            return 'Eintro_too_short'
        elif len(intro) > self.INTRO_LEN_MAX:
            return 'Eintro_too_long'
        elif len(logo) < self.INTRO_LEN_MIN:
            return 'Elogo_too_short'
        elif len(logo) > self.INTRO_LEN_MAX:
            return 'Elogo_too_long'
        elif len(category) > self.SQUARE_CATE_NUM_MAX:
            return 'Etoo_many_category'

        if not self.does_sqid_exist(sqid):
            return 'Esqid'

        category = list(set(category))

        for cateid in category:
            if not self.does_cateid_exist(cateid):
                return 'Eno_such_cateid'

        self.set_square(sqid, title, start_time, end_time, intro, logo)
        self._set_square_category(sqid, category)
        self._set_square_hidden(sqid, hidden)

        return 'Success'
Example #2
0
    def set_testdata(self, testid, info, filekey = None, expire = None):
        if expire != None:
            expire = com.isoptime(expire)
            if expire == None:
                return 'Eparameter'

        if(
            type(testid) != int or
            type(info) != str or
            (filekey != None and type(filekey) != str)
        ):
            return 'Eparameter'

        with TOJAuth.change_current_iden(self._idendesc):
            test = mod.TestdataMg.instance._get_testdata(testid)

        if test == None:
            return 'Etestid'

        if test['proid'] != self._proid:
            return 'Eother_proid'

        result = self._set_testdata(testid, info, filekey, expire)

        if result == None:
            return 'Efailed'

        if result == False:
            return 'Eupload'

        return 'Success'
    def add_testdata(self, blobname, expire, proid, info):
        if expire != None:
            expire = com.isoptime(expire)
            if expire == None:
                return 'Eparameter'

        if (type(blobname) != str or (proid != None and type(proid) != int)
                or type(info) != str):
            return 'Eparameter'

        testid = self._add_testdata(blobname, expire, proid, info)

        return testid
    def add_testdata(self, blobname, expire, proid, info):
        if expire != None:
            expire = com.isoptime(expire)
            if expire == None:
                return 'Eparameter'

        if(
            type(blobname) != str or
            (proid != None and type(proid) != int) or
            type(info) != str
        ):
            return 'Eparameter'

        testid = self._add_testdata(blobname, expire, proid, info)

        return testid
    def update_testdata(self, testid, blobname, expire, proid, info):
        if expire != None:
            expire = com.isoptime(expire)
            if expire == None:
                return 'Eparameter'

        if (type(testid) != int or type(blobname) != str
                or (proid != None and type(proid) != int)
                or type(info) != str):
            return 'Eparameter'

        if not self.does_testid_exist(testid):
            return 'Etestid'

        self._update_testdata(testid, blobname, expire, proid, info)

        return 'Success'
Example #6
0
    def create_testdata(self, info, filekey, expire = None):
        if expire != None:
            expire = com.isoptime(expire)
            if expire == None:
                return 'Eparameter'

        if(
            type(info) != str or
            type(filekey) != str
        ):
            return 'Eparameter'

        testid = self._create_testdata(info, filekey, expire)

        if testid == None:
            return 'Eupload'

        return {'testid': testid}
    def update_testdata(self, testid, blobname, expire, proid, info):
        if expire != None:
            expire = com.isoptime(expire)
            if expire == None:
                return 'Eparameter'

        if(
            type(testid) != int or
            type(blobname) != str or
            (proid != None and type(proid) != int) or
            type(info) != str
        ):
            return 'Eparameter'

        if not self.does_testid_exist(testid):
            return 'Etestid'

        self._update_testdata(testid, blobname, expire, proid, info)

        return 'Success'