예제 #1
0
    def add_new_category(self, cat_name):
        """Category add new.
        Will check if the cat_name is unique, otherwise will return an error.

        Args:
            cat_name: string category name.

        Return:
            None
        """
        cat_name = SiteHelpers().secure_filename(cat_name)

        try:
            category = Category(name=cat_name)
            return category.save()
        except NotUniqueError:
            return "category name not unique"
예제 #2
0
    def add_new_category(self, cat_name):
        """Category add new.
        Will check if the cat_name is unique, otherwise will return an error.

        Args:
            cat_name: string category name.

        Return:
            None
        """
        cat_name = SiteHelpers().secure_filename(cat_name)

        try:
            category = Category(name=cat_name)
            return category.save()
        except NotUniqueError:
            return 'category name not unique'