Ejemplo n.º 1
0
    def save_article(self, num, content):
        '''
        :param content: a list get from screen
        '''
        chinese_keyword = {
            'board': '看板',
        }

        author_line = content[0].encode('utf-8').split()
        if not chinese_keyword['board'] in author_line:
            return
        _i = author_line.index(chinese_keyword['board'])
        author = ' '.join(author_line[1:_i])

        title_line = content[1].encode('utf-8').split()[1:]
        title = ' '.join(title_line)

        time_line = content[2].encode('utf-8').split()[1:]
        time = ' '.join(time_line)
        if not time.find('(') == -1:
            time = time[time.find('(') + 1:time.find(')')]
        time = time.split()
        time.pop(1)
        time = ' '.join(time)
        print time


        article = '\n'.join(content[3:]).encode('utf-8')

        try:
            post = Teacher.get(bbs_id=num)
            post.content = article
            post.save()
            logger.info('Update: {id}'.format(id=num))
        except Teacher.DoesNotExist:
            post = Teacher.create(author=author,
                title=title,
                pub_time=time,
                content=article,
                bbs_id=num
            )
            logger.info('Insert: {id}'.format(id=num))
Ejemplo n.º 2
0
def query_test():
    t1 = Teacher.get(name='t1')
    print t1
    print t1.students.count()
    for one in t1.students:
        print one.name
Ejemplo n.º 3
0
def query_test():
    t1 = Teacher.get(name='t1')
    print t1
    print t1.students.count()
    for one in t1.students:
        print one.name