예제 #1
0
    def parse(cls, api, json):
        idea = cls(api)
        setattr(idea, '_json', json)

        for k, v in json.items():
            if k == 'authorInfo':
                author_model = getattr(api.parser.model_factory,
                                       'author') if api else Author
                author = author_model.parse(api, v)
                setattr(idea, k, author)
            elif k == 'creationDateTime':
                setattr(idea, k, parse_datetime(v))
            elif k == 'editedAt':
                setattr(idea, k, parse_datetime(v))
            elif k == 'statusChangeDate':
                setattr(idea, k, parse_datetime(v))
            elif k == 'tags':
                tags = []
                for tag in v:
                    tags.append(tag)
                setattr(idea, k, tags)
            else:
                setattr(idea, k, v)

        return idea
예제 #2
0
    def parse(cls, api, json):
        vote = cls(api)
        setattr(vote, '_json', json)

        for k, v in json.items():
            if k == 'creationDateTime' or k == 'creationDate':
                setattr(vote, k, parse_datetime(v))
            else:
                setattr(vote, k, v)

        return vote
예제 #3
0
파일: models.py 프로젝트: BIORED/prototipo1
    def parse(cls, api, json):
        vote = cls(api)
        setattr(vote, '_json', json)

        for k, v in json.items():
            if k == 'creationDate':
                setattr(vote, k, parse_datetime(v))
            else:
                setattr(vote, k, v)

        return vote
예제 #4
0
파일: models.py 프로젝트: BIORED/prototipo1
    def parse(cls, api, json):
        idea = cls(api)
        setattr(idea, '_json', json)

        for k, v in json.items():
            if k == 'authorInfo':
                author_model = getattr(api.parser.model_factory, 'author') if api else Author
                author = author_model.parse(api, v)
                setattr(idea, k, author)
            elif k == 'creationDateTime':
                setattr(idea, k, parse_datetime(v))
            elif k == 'editedAt':
                setattr(idea, k, parse_datetime(v))
            elif k == 'statusChangeDate':
                setattr(idea, k, parse_datetime(v))
            elif k == 'tags':
                tags = []
                for tag in v:
                    tags.append(tag)
                setattr(idea, k, tags)
            else:
                setattr(idea, k, v)

        return idea