Example #1
0
def create_category():
    """
    Create a category. Must be an admin.
    """
    form = CategoryForm()
    if not form.validate_on_submit():
        return api_error(form.errors)

    name = form.name.data
    description = form.description.data

    category = Category(name=name, description=description)
    category.save()
    return '', 201
Example #2
0
def create_category():
    """
    Create a category. Must be an admin.
    """
    form = CategoryForm()
    if not form.validate_on_submit():
        return api_error(form.errors)

    name = form.name.data
    description = form.description.data

    category = Category(name=name, description=description)
    category.save()
    return '', 201
Example #3
0
def seed_services():
    """Seed some categories and services."""

    food = Category.get_by_name("Food")
    if not food:
        food = Category()
        food.name = "Food"
        food.description = ""
        food.save()
    food_delivery = Service.get_by_name("Delivery")
    if not food_delivery:
        food_delivery = Service()
        food_delivery.name = "Delivery"
        food_delivery.description = "Quick for those hungry children"
        food_delivery.category = food
        food_delivery.save()

    shelter = Category.get_by_name("Shelter")
    if not shelter:
        shelter = Category()
        shelter.name = "Shelter"
        shelter.description = "Housing for a limited time."
        shelter.save()
    shelter_one_night = Service.get_by_name("One night")
    if not shelter_one_night:
        shelter_one_night = Service()
        shelter_one_night.name = "One night"
        shelter_one_night.description = "A bed for the night"
        shelter_one_night.category = shelter
        shelter_one_night.save()

    clothing = Category.get_by_name("Clothing")
    if not clothing:
        clothing = Category()
        clothing.name = "Clothing"
        clothing.description = "Shirts, shoes, and all things."
        clothing.save()
    clothing_young = Service.get_by_name("0-5 clothing")
    if not clothing_young:
        clothing_young = Service()
        clothing_young.name = "0-5 clothing"
        clothing_young.description = "Clothing for chidren ages 0 to 5"
        clothing_young.category = clothing
        clothing_young.save()

    return (food_delivery, shelter_one_night, clothing_young)
Example #4
0
def seed_services():
    """Seed some categories and services."""

    food = Category.get_by_name("Food")
    if not food:
        food = Category()
        food.name = "Food"
        food.description = ""
        food.save()
    food_delivery = Service.get_by_name("Delivery")
    if not food_delivery:
        food_delivery = Service()
        food_delivery.name = "Delivery"
        food_delivery.description = "Quick for those hungry children"
        food_delivery.category = food
        food_delivery.save()

    shelter = Category.get_by_name("Shelter")
    if not shelter:
        shelter = Category()
        shelter.name = "Shelter"
        shelter.description = "Housing for a limited time."
        shelter.save()
    shelter_one_night = Service.get_by_name("One night")
    if not shelter_one_night:
        shelter_one_night = Service()
        shelter_one_night.name = "One night"
        shelter_one_night.description = "A bed for the night"
        shelter_one_night.category = shelter
        shelter_one_night.save()

    clothing = Category.get_by_name("Clothing")
    if not clothing:
        clothing = Category()
        clothing.name = "Clothing",
        clothing.description = "Shirts, shoes, and all things."
        clothing.save()
    clothing_young = Service.get_by_name("0-5 clothing")
    if not clothing_young:
        clothing_young = Service()
        clothing_young.name = "0-5 clothing"
        clothing_young.description = "Clothing for chidren ages 0 to 5"
        clothing_young.category = clothing
        clothing_young.save()

    return (food_delivery, shelter_one_night, clothing_young)