def init(): init_db() print("Createing the a test category..") category_controller.create(name="Test") category_controller.create(name="Uncategorised") print("Creating a test slide..") slide_controller.create( title="test title", screenshot="img/badge-reserved.jpg", description="test desc", url="https://github.com/moztn/firefoxOSAppDay-Slides", category=1 ) print("Fixtures created successfully")
def add_category(): # categories = category_controller.list() # category = CategoryModel(request.form['name']) category_controller.create( name=request.form['name'] ) status = True return render_template( 'admin.html', status=status, action='added', operation='categories', categories=category_controller.list(), message='This category already exists in DB!' )
def init(): if not os.path.exists('db'): os.makedirs('db') init_db() print("Createing the a test category..") category_controller.create(name="Test") print("Creating a test slide..") slide_controller.create( title="test title", screenshot="img/badge-reserved.jpg", description="test desc", url="https://github.com/moztn/firefoxOSAppDay-Slides", category=1 ) print("Fixtures created successfully")
def add_category(): # categories = category_controller.list() # category = CategoryModel(request.form['name']) try: category_controller.create(name=request.form['name']) status = True return render_template('admin.html', status=status, action='added', operation='categories', categories=category_controller.list()) except IntegrityError as e: db_session.rollback() return render_template('admin.html', status=False, categories=category_controller.list(), message="This Categorie already exists ! ")
def delete_category(): """ Deletes a category. """ category_id = request.form['id'] c = CategoryModel.query.get(category_id) uc = CategoryModel.query.filter(CategoryModel.name=="Uncategorised").first() if uc is None: category_controller.create( name="Uncategorised" ) if c.name == "Uncategorised": return render_template( 'admin.html', categories=category_controller.list(), status=False, action='deleted', operation='categories', message="You can't delete this category" ) slides = get_slides_by_cotegory(c) for s in slides: s.category = uc.id db_session.add(s) category_controller.delete(category_id) db_session.commit() return render_template( 'admin.html', categories=category_controller.list(), status=True, action='deleted', operation='categories' )
def add_category(): # categories = category_controller.list() # category = CategoryModel(request.form['name']) try: category_controller.create( name=request.form['name'] ) status = True return render_template( 'admin.html', status=status, action='added', operation='categories', categories=category_controller.list() ) except IntegrityError as e: db_session.rollback() return render_template( 'admin.html', status = False, categories = category_controller.list(), message ="This Categorie already exists ! ")