コード例 #1
0
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")
コード例 #2
0
ファイル: slides.py プロジェクト: addonis1990/slides-moztn
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!'
    )
コード例 #3
0
ファイル: first_run.py プロジェクト: addonis1990/slides-moztn
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")
コード例 #4
0
ファイル: slides.py プロジェクト: moztn/slides-moztn
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 ! ")
コード例 #5
0
ファイル: slides.py プロジェクト: addonis1990/slides-moztn
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'
    )
コード例 #6
0
ファイル: slides.py プロジェクト: mermi/slides-moztn
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 ! ")