예제 #1
0
 def test_get(self):
     model = KMBlogCategory.get(None)
     # id = Noneの場合は新規モデルが取得できること
     eq_(model.id, None)
     model = KMBlogCategory.get(1)
     # id = 1の場合は登録済みのモデルが取得できること
     eq_(model.id, 1)
예제 #2
0
 def blog_page(self, blog_url, id):
     info = KMBlogInfo.find(url=blog_url)[0]
     article = KMBlogArticle.get(id)
     category = KMBlogCategory.get(article.category_id)
     article.comments = KMBlogComment.find(article_id=article.id)
     values = {'info': info, 'article': article, 'category': category}
     return self.render('kokemomo/plugins/blog/view/template/' + SETTINGS.BLOG_TEMPLATE + '/page', url=self.get_url, values=values, blog_url=blog_url)
예제 #3
0
 def blog_admin_category(self):
     '''
     blog admin page
     :return: template
     '''
     id = self.data.get_request_parameter('id', default=None)
     self.result['info'] = KMBlogInfo.all()
     self.result['category'] = KMBlogCategory.get(id=id)
     self.result['type'] = 'category'
     self.result['menu_list'] = get_menu_list()
예제 #4
0
 def blog_admin_category(self):
     '''
     blog admin page
     :return: template
     '''
     id = self.data.get_request_parameter('id', default=None)
     self.result['info'] = KMBlogInfo.all()
     self.result['category'] = KMBlogCategory.get(id=id)
     self.result['type'] = 'category'
     self.result['menu_list'] = get_menu_list()
예제 #5
0
    def test_save_data(self):

        model = KMBlogCategory.get(1)
        eq_(model.id, 1)
        eq_(model.name, '')
        eq_(model.info_id, None)
        data = self.mocker.CreateMock(KMData)
        data.get_request_parameter('name', default='', decode=True).AndReturn(self.test_name)
        data.get_request_parameter('info_id', default=None).AndReturn(self.test_info_id)
        self.mocker.ReplayAll()
        model = KMBlogCategory.save_data(1, data)
        # 既存データのidが指定された場合は値が上書きされること
        eq_(model.error.size(), 0)
        eq_(model.id, 1)
        eq_(model.name, self.test_name)
        eq_(model.info_id, self.test_info_id)
        self.mocker.VerifyAll()