예제 #1
0
파일: Repository.py 프로젝트: Alex-ZL/ljn
def add_test_data():
    from ljn.Model import Category
    s = session_maker()
    if not len(Category.all(s)):
        s.add(Category(u'c1'))
        s.add(Category(u'c2'))

    if not len(Article.all(s)):
        s.add(Article('this is content 1', Category.find_by_name(s, u'c1'), u'title of a1'))
        s.add(Article('this is content 2', Category.find_by_name(s, u'c1'), u'title of a2'))
        s.add(Article('this is content 3', Category.find_by_name(s, u'c2'), u'title of a3'))

    article = Category.find_by_name(s, u'c1').articles[0]
    if not len(article.new_words):
        w = Word('is')
        article.new_words.append(ArticleNewWord(article, w, 'is'))

    s.commit()
예제 #2
0
파일: CategoryList.py 프로젝트: Alex-ZL/ljn
 def update_categories(self):
     self.clear()
     for c in Category.all(get_session()):
         self.addItem(CategoryItem(c))