Пример #1
0
 def default_category(cls):
     category = DBCategory.get_by_url("")
     if not category:
         category = DBCategory.create(url="", name="Home")
         category.save()
         _ = category.stats  # init stats
     return cls(category)
Пример #2
0
 def default_category(cls):
     category = DBCategory.get_by_url("")
     if not category:
         category = DBCategory.create(url="", name="Home")
         category.save()
         _ = category.stats  # init stats
     return cls(category)
Пример #3
0
 def create_category(cls, **settings):
     url = cls.norm_url(settings.pop("url"))
     name = settings.pop("name")
     if cls.check_exist(url=url):
         raise Exception("category %s exist" % url)
     dbcategory = DBCategory.create(url=url, name=name)
     dbcategory.save()
     _ = dbcategory.stats  # init stats
     dbcategory.update(**settings)
     return cls(dbcategory)
Пример #4
0
 def create_category(cls, **settings):
     url = cls.norm_url(settings.pop("url"))
     name = settings.pop("name")
     if cls.check_exist(url=url):
         raise Exception("category %s exist" % url)
     dbcategory = DBCategory.create(url=url, name=name)
     dbcategory.save()
     _ = dbcategory.stats  # init stats
     dbcategory.update(**settings)
     return cls(dbcategory)