当前位置: 首页>>代码示例>>Python>>正文


Python Category.select方法代码示例

本文整理汇总了Python中models.Category.select方法的典型用法代码示例。如果您正苦于以下问题:Python Category.select方法的具体用法?Python Category.select怎么用?Python Category.select使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在models.Category的用法示例。


在下文中一共展示了Category.select方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get_update_post

# 需要导入模块: from models import Category [as 别名]
# 或者: from models.Category import select [as 别名]
def get_update_post(id):
    category = Category.select()
    try:
        post = Post.get(id=id)
    except Post.DoesNotExist:
        abort(404)
    return template("admin/update.html", post=post, category=category)
开发者ID:iTriumph,项目名称:MiniAkio,代码行数:9,代码来源:blog.py

示例2: __init__

# 需要导入模块: from models import Category [as 别名]
# 或者: from models.Category import select [as 别名]
    def __init__(self, table_p, parent, product=None, *args, **kwargs):
        QDialog.__init__(self, parent, *args, **kwargs)

        self.table_p = table_p
        self.prod = product
        self.parent = parent
        self.filename = "Parcourire ..."
        self.path_filename = None

        if self.prod:
            self.title = u"Modification de l'article {}".format(self.prod.name)
            self.succes_msg = u"L'article <b>%s</b> a été mise à jour" % self.prod.name
            try:
                self.filename = self.prod.file_join.file_name
            except:
                pass
        else:
            self.succes_msg = u"L'article a été bien enregistré"
            self.title = u"Ajout de nouvel article"
            self.prod = Product()

        self.setWindowTitle(self.title)

        # self.code = LineEdit(self.prod.code)
        self.name_field = LineEdit(self.prod.name)
        try:
            self.category_name = Category.select().where(
                Category.name == self.prod.category.name).get().name
        except:
            self.category_name = ""
        self.category_field = LineEdit(self.category_name)

        self.number_parts_box_field = IntLineEdit(
            str(self.prod.number_parts_box))
        self.number_parts_box_field.setValidator(QIntValidator())

        completion_values = [catg.name for catg in Category.all()]
        completer = QCompleter(completion_values, parent=self)
        completer.setCaseSensitivity(Qt.CaseInsensitive)
        completer.setCompletionMode(QCompleter.UnfilteredPopupCompletion)
        self.category_field.setCompleter(completer)

        vbox = QVBoxLayout()
        formbox = QFormLayout()
        formbox.addRow(FLabel(u"Nom"), self.name_field)
        formbox.addRow(FLabel(u"Categorie"), self.category_field)
        # formbox.addRow(
        #     FLabel(u"Quantité (carton)"), self.number_parts_box_field)
        self.butt_parco = QPushButton(
            QIcon.fromTheme('document-open', QIcon('')), self.filename)
        self.butt_parco.clicked.connect(self.import_image)
        butt_cancel = Warning_btt(u"Annuler")
        butt_cancel.clicked.connect(self.cancel)
        # formbox.addRow(FLabel(u"Image"), self.butt_parco)
        butt = Button_save(u"&Enregistrer")
        butt.clicked.connect(self.add_or_edit_prod)
        formbox.addRow(butt_cancel, butt)

        vbox.addLayout(formbox)
        self.setLayout(vbox)
开发者ID:Ciwara,项目名称:gcommon,代码行数:62,代码来源:product_edit_or_add.py

示例3: get

# 需要导入模块: from models import Category [as 别名]
# 或者: from models.Category import select [as 别名]
    def get(self, postid):
        try:
            post = Post.get(id=postid)
        except Post.DoesNotExist:
            raise tornado.web.HTTPError(404)

        category = Category.select()
        self.render('admin/post/update.html', post=post, category=category)
开发者ID:dengmin,项目名称:logpress-tornado,代码行数:10,代码来源:admin.py

示例4: categories

# 需要导入模块: from models import Category [as 别名]
# 或者: from models.Category import select [as 别名]
def categories():
    """Returns a list of tuples from the category table. Index 0 is ID & index 1 is the description.
    This was implemented for WTF.SelectField in specific, but can be used if needed.
    """
    category = Category.select()
    category_list = []
    for cat in category:
        category_list.append((cat.category_id, cat.description))
    return category_list
开发者ID:dsantosp12,项目名称:NapAdmin,代码行数:11,代码来源:forms.py

示例5: test_create_category

# 需要导入模块: from models import Category [as 别名]
# 或者: from models.Category import select [as 别名]
 def test_create_category(self):
     """Create a category."""
     create_category(category_id="001", description="testing category")
     c = Category.select().where(Category.category_id == "001")
     Category.get(Category.category_id == "001").delete_instance()
     self.assertEqual(
         c,
         "<class 'models.Category'> SELECT `t1`.`id`, "
         "`t1`.`category_id`, `t1`.`description` "
         "FROM `category` AS t1 WHERE (`t1`.`category_id` = %s) ['001']",
     )
开发者ID:dsantosp12,项目名称:NapAdmin,代码行数:13,代码来源:tests.py

示例6: post

# 需要导入模块: from models import Category [as 别名]
# 或者: from models.Category import select [as 别名]
 def post(self):
     name = self.get_argument('name', None)
     slug = self.get_argument('slug', None)
     q = Category.select().where(Category.name == name)
     if q.count() > 0:
         self.flash('cateegory exists!')
         self.render('admin/category/add.html')
         return
     else:
         Category.create(name=name, slug=slug)
         self.redirect('/admin/category')
开发者ID:dengmin,项目名称:logpress-tornado,代码行数:13,代码来源:admin.py

示例7: admin_index

# 需要导入模块: from models import Category [as 别名]
# 或者: from models.Category import select [as 别名]
def admin_index():
    post_count = Post.select().count()
    comm_count = Comment.select().count()
    tag_count = Tag.select().count()
    cate_count = Category.select().count()
    author = Author.get(id=1)
    posts = Post.select().paginate(1, 5)
    comments = Comment.select().order_by(('published', 'desc')).paginate(1, 5)
    return template('admin/index.html', posts=posts, comments=comments,
                    post_count=post_count, comm_count=comm_count,
                    tag_count=tag_count, cate_count=cate_count, author=author)
开发者ID:iTriumph,项目名称:MiniAkio,代码行数:13,代码来源:admin.py

示例8: index

# 需要导入模块: from models import Category [as 别名]
# 或者: from models.Category import select [as 别名]
 def index(self):
 	menu = Menu.select()
     g_m = GeneralMeta.get_or_create(id=1)
     form = MetaDataForm(obj=g_m)
 	categories = Category.select()
     return self.render(
         'admin/index.html',
         categories=categories,
         menu=menu,
         meta_form = form
     )
开发者ID:lpfan,项目名称:Wing-M.S.,代码行数:13,代码来源:index.py

示例9: loadTree

# 需要导入模块: from models import Category [as 别名]
# 或者: from models.Category import select [as 别名]
def loadTree():

    # Declare empty dict of feeds (emulate sparse list)
    feeds = {}

    # Get categories, number of posts by category
    categories = Category.select(Category, fn.Count(Post.id).alias('count')).join(Feed).join(Post).group_by(Category)

    # Loop over categories
    for c in categories:
        # Get feeds by category
        f = Feed.select().where(Feed.category == c.id).annotate(Post)
        feeds[c.id] = f

    return (categories, feeds)
开发者ID:KyubiSystems,项目名称:Wisewolf,代码行数:17,代码来源:views.py

示例10: loadJsonTree

# 需要导入模块: from models import Category [as 别名]
# 或者: from models.Category import select [as 别名]
def loadJsonTree():

    # Use collection to build nested list for tree
    feeds = defaultdict(list)

    # Get categories, number of posts by category
    categories = Category.select(Category, fn.Count(Post.id).alias('count')).join(Feed).join(Post).group_by(Category)

    # Loop over categories
    all_feeds = []
    for c in categories:

        feeds[c.id] = {'name': c.name, 'id' : c.id, 'count': c.count, 'children' : []}
        # Get feeds by category
        category_feeds = Feed.select().where(Feed.category == c.id).annotate(Post)
        for f in category_feeds:
            feeds[c.id]['children'].append({'id': f.id, 'name': f.name, 'count' : f.count, 'url': f.url})

        all_feeds.append(feeds[c.id])
   
    return Response(json.dumps(all_feeds), mimetype='application/json')
开发者ID:KyubiSystems,项目名称:Wisewolf,代码行数:23,代码来源:views.py

示例11: open

# 需要导入模块: from models import Category [as 别名]
# 或者: from models.Category import select [as 别名]
# coding:utf-8
import csv

# 读取岗位族群分类信息
from models import Category

with open('04.csv', 'r') as csvfile:
    reader = csv.DictReader(csvfile)
    rows = [row for row in reader]

# 抓取数据时是深度优先
for row in rows:
    if not row['parent_code']:
        c = Category.create(name=row['name'], code=row['code'])
    else:
        parent = Category.select().where(Category.code == row['parent_code']).get()
        Category.create(name=row['name'], code=row['code'], parent=parent)
开发者ID:ak64th,项目名称:courses.myctu.cn,代码行数:19,代码来源:category_import_2.py

示例12: get_category

# 需要导入模块: from models import Category [as 别名]
# 或者: from models.Category import select [as 别名]
	def get_category(self):
		return Category.select()
开发者ID:940825,项目名称:logpress-tornado,代码行数:4,代码来源:blog.py

示例13: get

# 需要导入模块: from models import Category [as 别名]
# 或者: from models.Category import select [as 别名]
 def get(self):
   categories = Category.select().order_by(Category.name).iterator()
   categoryList = [{'id': category.id, 'name': category.name} for category in categories]
   self.write(json_encode(categoryList))
   self.set_header("Content-Type", "application/json")
开发者ID:haoericliu,项目名称:haoliu,代码行数:7,代码来源:categoryhandler.py

示例14: get_new_post

# 需要导入模块: from models import Category [as 别名]
# 或者: from models.Category import select [as 别名]
def get_new_post():
    category = Category.select()
    return template("admin/newpost.html", category=category)
开发者ID:iTriumph,项目名称:MiniAkio,代码行数:5,代码来源:blog.py


注:本文中的models.Category.select方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。