當前位置: 首頁>>代碼示例>>Python>>正文


Python Category.delete方法代碼示例

本文整理匯總了Python中models.Category.delete方法的典型用法代碼示例。如果您正苦於以下問題:Python Category.delete方法的具體用法?Python Category.delete怎麽用?Python Category.delete使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在models.Category的用法示例。


在下文中一共展示了Category.delete方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: runTest

# 需要導入模塊: from models import Category [as 別名]
# 或者: from models.Category import delete [as 別名]
 def runTest(self):
     period = Period(lower=datetime.datetime(1996,10,1), upper=datetime.datetime(1997,1,1))
     i = Category(cat=120033, valid_time=period)
     i.save()
     
     for bad in [5, 2.0, 'foo', (10, 20)]:
         try:
             i.valid_time = bad
         except TypeError:
             pass
         else:
             self.fail('Should throw a TypeError')
     
     newstr = '[1996-01-01 00:00:00.000000+0000,1996-06-01 00:00:00.000000+0000)'
     new = Period(newstr)
     
     for good in (new, newstr):
         i.valid_time = good
     
     self.assertEqual(i.valid_time, new)
     i.save()
     self.assertNotEqual(i.pk, None)
     self.assertEqual(new, Category.objects.get(pk=i.pk).valid_time)
     
     i.delete()
開發者ID:zejn,項目名稱:django_temporal,代碼行數:27,代碼來源:tests.py

示例2: test_model_category

# 需要導入模塊: from models import Category [as 別名]
# 或者: from models.Category import delete [as 別名]
 def test_model_category(self):
     """Test category model"""
     obj = Category(name='test')
     obj.save()
     self.assertEquals('test', obj.name)
     self.assertNotEquals(obj.id, None)
     obj.delete()
開發者ID:tovmeod,項目名稱:anaf,代碼行數:9,代碼來源:tests.py

示例3: admin_delete_category

# 需要導入模塊: from models import Category [as 別名]
# 或者: from models.Category import delete [as 別名]
def admin_delete_category(cat_id):
    Category.delete(cat_id)
    posts = Post.query.filter_by(category_id=cat_id).all()
    if posts is not None:
        for p in posts:
            Post.update_category_id(p.post_id, 0)
    categories = Category.query.all()
    return render_template('admin_categories.html', title='Admin', user=current_user, categories=categories)
開發者ID:FengNongtheWindCoder,項目名稱:flaskblog,代碼行數:10,代碼來源:views.py

示例4: delete_category

# 需要導入模塊: from models import Category [as 別名]
# 或者: from models.Category import delete [as 別名]
def delete_category(id):
    # Delete category #id
    # Reassign all feeds in category to 'unsorted' id 0?
    query = Feed.update(category_id=0).where(Category.id == id) 
    query.execute()

    query = Category.delete().where(Category.id == id)
    query.execute()

    # return JSON status OK
    return jsonify(**STATUS_OK)
開發者ID:KyubiSystems,項目名稱:Wisewolf,代碼行數:13,代碼來源:views.py

示例5: test_create_stock_no_duplicate

# 需要導入模塊: from models import Category [as 別名]
# 或者: from models.Category import delete [as 別名]
 def test_create_stock_no_duplicate(self):
     """Makes sure stock don't have the same stock_id when creating."""
     Category.create(category_id='001', description='Testing Stock')
     create_stock('001', 'Testing stock', 1, '001', 9.99)
     from peewee import IntegrityError
     with self.assertRaises(IntegrityError):
         create_stock('001', 'Testing stock', 1, '001', 9.99)
     q = Stock.delete().where(Stock.stock_id == '001')
     q.execute()
     t = Category.delete().where(Category.category_id == '001')
     t.execute()
開發者ID:dsantosp12,項目名稱:NapAdmin,代碼行數:13,代碼來源:tests.py

示例6: delete

# 需要導入模塊: from models import Category [as 別名]
# 或者: from models.Category import delete [as 別名]
    def delete(self, id):
        category = Category.get_by_id(id)
        if category is None:
            flash(gettext('The category was not found'), 'error')
            return redirect(url_for('CategoriesView:index'))
        if not category.can_edit():
            abort(401)

        try:
            if not Category.transfer_posts(category):
                return util.redirect_json_or_html(url_for('CategoriesView:index'),
                    'category',
                    gettext('Sorry, the last category can not be removed'))

            name = category.name
            Category.delete(category.id)
            flash(gettext('The category "%(name)s" was removed', name=name))
        except:
            return util.redirect_json_or_html(url_for('CategoriesView:index'),
                'category',
                gettext('Error while removing the category'))

        return util.redirect_json_or_html(url_for('CategoriesView:index'), 'category')
開發者ID:Tibodef,項目名稱:PythonBlog,代碼行數:25,代碼來源:views.py

示例7: test_create_stock

# 需要導入模塊: from models import Category [as 別名]
# 或者: from models.Category import delete [as 別名]
 def test_create_stock(self):
     """Make sure it create a stock."""
     Category.create(category_id='001', description='Testing Stock')
     create_stock('001', 'Testing stock', 1, '001', 9.99)
     s = Stock.select().where(Stock.stock_id == '001')
     t = Stock.delete().where(Stock.stock_id == '001')
     t.execute()
     t = Category.delete().where(Category.category_id == '001')
     t.execute()
     self.assertEqual(str(s), ("<class 'models.Stock'> SELECT `t1`.`id`,"
                               " `t1`.`stock_id`, `t1`.`description`,"
                               " `t1`.`quantity`, `t1`.`category_id`,"
                               " `t1`.`price` FROM `stock` AS t1"
                               " WHERE (`t1`.`stock_id` = %s) ['001']"))
開發者ID:dsantosp12,項目名稱:NapAdmin,代碼行數:16,代碼來源:tests.py

示例8: test_create_incoming

# 需要導入模塊: from models import Category [as 別名]
# 或者: from models.Category import delete [as 別名]
    def test_create_incoming(self):
        """Create an incoming record."""
        Category.create(category_id='001', description='Testing Stock')
        create_stock('001', 'Testing stock', 1, '001', 9.99)
        create_incoming_stock(stock="001", date="2015-07-22", quantity=13, price=13.99)
        p = IncomingStock.select().where(IncomingStock.stock == '001')
        q = IncomingStock.delete().where(IncomingStock.stock == '001')
        q.execute()
        s = Stock.select().where(Stock.stock_id == '001')
        t = Stock.delete().where(Stock.stock_id == '001')
        t.execute()
        t = Category.delete().where(Category.category_id == '001')
        t.execute()

        self.assertEqual(str(p), ("<class 'models.IncomingStock'> SELECT `t1`.`id`, `t1`.`stock_id`, "
                                  "`t1`.`date`, `t1`.`price`, `t1`.`cost` FROM `incomingstock` AS t1 WHERE "
                                  "(`t1`.`stock_id` = %s) ['001']"))
開發者ID:dsantosp12,項目名稱:NapAdmin,代碼行數:19,代碼來源:test.py


注:本文中的models.Category.delete方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。