Ejemplo n.º 1
0
def init_category():
    for category in category_init:
        print(Category.find_by_category(category['category']))
        if Category.find_by_category(category['category']) == None:
            new_record = Category(category=category['category'],
                                  username_id=current_user.id)
            Category.save_to_db(new_record)
    return render_template('habit.html')
Ejemplo n.º 2
0
def init_activity():
    for each_record in activity_init:
        print(Activity.find_by_name(each_record['name']))
        if Activity.find_by_name(each_record['name']) == None:
            category_id_for_new_record = (Category.find_by_category(
                each_record['category_name']).id)
            new_record = Activity(name=each_record['name'],
                                  category_id=category_id_for_new_record,
                                  username_id=current_user.id)
            Activity.save_to_db(new_record)
    return render_template('habit.html')
Ejemplo n.º 3
0
def myhabit(name):
    allcategory = Category.find_by_category(name)
    myhabits = Habit.find_by_category_id(allcategory.id)
    return render_template('myhabit.html', myhabits=myhabits, category=name)
Ejemplo n.º 4
0
 def get(self, name):
     category = Category.find_by_category(name)
     if category:
         return make_response(render_template('home.html'), 200, category.json())
     return {'message': 'Store not found'}, 404