Beispiel #1
0
def project_update(project_id):
    form = ProjectForm()
    project = Project.query.get_or_404(project_id)
    if form.validate_on_submit():
        if form.image.data:
            delete_picture('project_pics', project.image)
            project.image = save_picture(form.image.data, 'project_pics')
        project.title = form.title.data
        project.description = form.description.data
        project.authors = form.authors.data
        project.url = form.url.data
        project.year = form.year.data
        project.semester = form.semester.data
        for picture in form.pictures.data:
            project_pict = ProjectPicture(image=save_picture(picture, 'project_pics'), project=project)
            db.session.add(project_pict)
        db.session.commit()
        flash('The project has been updated!', 'success')
        return redirect(url_for('project_get_all'))
    elif request.method == 'GET':
        form.title.data = project.title
        form.description.data = project.description
        form.authors.data = project.authors
        form.url.data = project.url
        form.year.data = project.year
        form.semester.data = project.semester
    return render_template("project/new_project.html", title='Update Project', form=form, legend='Update')
Beispiel #2
0
def page_text_delete(page_text_id):
    page_text = PageText.query.get_or_404(page_text_id)
    delete_picture('page_pics', page_text.image)
    db.session.delete(page_text)
    db.session.commit()
    flash('The element has been deleted!', 'danger')
    return redirect(url_for('page_get_one', page_id=page_text.page_id))
Beispiel #3
0
def history_delete(history_id):
    history = History.query.get_or_404(history_id)
    delete_picture('history_pics', history.image)
    db.session.delete(history)
    db.session.commit()
    flash('The history has been deleted!', 'danger')
    return redirect(url_for('history_get_all'))
Beispiel #4
0
def page_text_delete_image(page_text_id):
    page_text = PageText.query.get_or_404(page_text_id)
    delete_picture('page_pics', page_text.image)
    page_text.image = ''
    db.session.commit()
    flash('The image has been deleted!', 'info')
    return redirect(url_for('page_get_one', page_id=page_text.page_id))
Beispiel #5
0
def teacher_delete(teacher_id):
    teacher = Teacher.query.get_or_404(teacher_id)
    delete_picture('teacher_pics', teacher.image)
    db.session.delete(teacher)
    db.session.commit()
    flash('The teacher has been deleted!', 'danger')
    return redirect(url_for('teacher_get_all'))
Beispiel #6
0
def teacher_update(teacher_id):
    teacher = Teacher.query.get_or_404(teacher_id)
    form = TeacherForm()
    if form.validate_on_submit():
        teacher.name = form.name.data
        teacher.position = form.position.data
        teacher.link = form.link.data
        teacher.hobby = form.hobby.data
        teacher.incumbency = form.incumbency.data
        teacher.description = form.description.data
        teacher.interests = form.interests.data
        teacher.scopus_id = form.scopus_id.data
        teacher.scholar_id = form.scholar_id.data
        teacher.research_directions = form.research_directions.data
        if form.image.data:
            delete_picture('teacher_pics', teacher.image)
            teacher.image = save_picture(form.image.data, 'teacher_pics')
        db.session.commit()
        flash('The teacher has been updated!', 'success')
        return redirect(url_for('teacher_get_all'))
    elif request.method == 'GET':
        form.name.data = teacher.name
        form.position.data = teacher.position
        form.link.data = teacher.link
        form.hobby.data = teacher.hobby
        form.incumbency.data = teacher.incumbency
        form.description.data = teacher.description
        form.interests.data = teacher.interests
        form.research_directions.data = teacher.research_directions
        form.scopus_id.data = teacher.scopus_id
        form.scholar_id.data = teacher.scholar_id
    return render_template("teacher/new_teacher.html", title='Update teacher', form=form, legend='Update')
Beispiel #7
0
def news_delete(news_id):
    news = News.query.get_or_404(news_id)
    delete_picture('news_pics', news.image)
    db.session.delete(news)
    db.session.commit()
    flash('The news has been deleted!', 'danger')
    return redirect(url_for('news_get_all'))
Beispiel #8
0
def page_delete(page_id):
    page = Page.query.get_or_404(page_id)
    for one in page.texts:
        delete_picture('page_pics', one.image)
    db.session.delete(page)
    db.session.commit()
    flash('The page has been deleted!', 'danger')
    return redirect(url_for('page_get_all'))
Beispiel #9
0
def project_delete(project_id):
    project = Project.query.get_or_404(project_id)
    delete_picture('project_pics', project.image)
    for picture in project.pictures:
        delete_picture('project_pics', picture.image)
    db.session.delete(project)
    db.session.commit()
    flash('The project has been deleted!', 'danger')
    return redirect(url_for('project_get_all'))
Beispiel #10
0
def news_category_delete(news_category_id, delete_with_news):
    category = NewsCategory.query.get_or_404(news_category_id)
    if delete_with_news == 'True':
        for news in category.news:
            delete_picture('news_pics', news.image)
            db.session.delete(news)
    db.session.delete(category)
    db.session.commit()
    flash('The news category has been deleted!', 'danger')
    return redirect(url_for('news_get_all'))
Beispiel #11
0
def news_update(news_id):
    news = News.query.get_or_404(news_id)
    form = NewsForm()
    if form.validate_on_submit():
        if form.image.data:
            delete_picture('news_pics', news.image)
            news.image = save_picture(form.image.data, 'news_pics')
        news.header = form.header.data
        news.description = form.description.data
        news.text = form.text.data
        news.category = form.category.data
        db.session.commit()
        flash('The news has been updated!', 'success')
        return redirect(url_for('news_get_all'))
    elif request.method == 'GET':
        form.header.data = news.header
        form.description.data = news.description
        form.text.data = news.text
        form.category.data = news.category
    return render_template("news/new_news.html", title='Update News', form=form, legend='Update')
Beispiel #12
0
def history_update(history_id):
    history = History.query.get_or_404(history_id)
    form = HistoryForm()
    if form.validate_on_submit():
        if form.image.data:
            delete_picture('history_pics', history.image)
            history.image = save_picture(form.image.data, "history_pics")
        history.header = form.header.data
        history.description = form.description.data
        history.date = form.date.data
        db.session.commit()
        flash('The history has been updated!', 'success')
        return redirect(url_for('history_get_all'))
    elif request.method == 'GET':
        form.header.data = history.header
        form.description.data = history.description
        form.date.data = history.date
    return render_template("history/new_history.html",
                           title='Update History',
                           form=form,
                           legend='Update')
Beispiel #13
0
def page_text_update(page_text_id):
    page_text = PageText.query.get_or_404(page_text_id)
    form = PageTextForm()
    if form.validate_on_submit():
        page_text.primary_text = form.primary_text.data
        page_text.secondary_text = form.secondary_text.data
        page_text.position = form.position.data
        if form.image.data:
            delete_picture('page_pics', page_text.image)
            page_text.image = save_picture(form.image.data, 'page_pics')
        db.session.commit()
        flash('The element has been updated!', 'success')
        return redirect(url_for('page_get_one', page_id=page_text.page_id))
    elif request.method == 'GET':
        form.primary_text.data = page_text.primary_text
        form.secondary_text.data = page_text.secondary_text
        form.position.data = page_text.position
    return render_template("page/new_page_text.html",
                           title='Update element',
                           form=form,
                           legend='Update')
Beispiel #14
0
def project_delete_picture(picture_id):
    picture = ProjectPicture.query.get_or_404(picture_id)
    delete_picture('project_pics', picture.image)
    db.session.delete(picture)
    db.session.commit()
    return redirect(url_for('project_get_all'))