Exemple #1
0
def content_data_handler(page):
    if not check_admin():
        abort(403)
    from app.models import Content
    request_form = request.form
    title = request_form.getlist('content_title')[0]
    text = request_form.getlist('content_text')[0]
    content = Content.query.filter_by(key=page).first()
    content = Content.query.get(content.id)
    content.title = title
    content.content = text

    img_url = ''
    if request.method == 'POST':
        # check if the post request has the file part
        if 'file' not in request.files:
            img_url = ''
        file = request.files['file']
        # if user does not select file, browser also submits
        # an empty part without filename
        if file.filename == '':
            img_url = ''
        from werkzeug.utils import secure_filename
        from app.utils.upload import allowed_file
        if file and allowed_file(file.filename):
            filename = secure_filename(file.filename)
            file.save(os.path.join(app.config['UPLOAD_FOLDER'],
                                   filename))
            img_url = file.filename

    if img_url != '':
        content.image_url = 'img/uploads/' + img_url

    db.session.commit()
    return redirect(url_for(page, page_content=content))
Exemple #2
0
def banner_data_handler():
    if not check_admin():
        abort(403)

    from app.models import Banners
    img_url = ''
    if request.method == 'POST':
        # check if the post request has the file part
        if 'file' not in request.files:
            img_url = ''
        file = request.files['file']
        # if user does not select file, browser also submits
        # an empty part without filename
        if file.filename == '':
            img_url = ''
        from werkzeug.utils import secure_filename
        from app.utils.upload import allowed_file
        if file and allowed_file(file.filename):
            filename = secure_filename(file.filename)
            file.save(os.path.join(app.config['UPLOAD_FOLDER'],
                                   filename))
            img_url = url_for('static', filename='img/uploads/' + file.filename)

    if img_url != '':
        banner = Banners(img_url)
        db.session.add(banner)
        db.session.commit()
    return redirect(url_for('index'))
Exemple #3
0
def committee_editor(role):
    if not check_admin():
        abort(403)
    from app.models import Committee
    committee_member = Committee.query.filter_by(role=role).first()
    committee_member = Committee.query.get(committee_member.id)
    return render_template('editors/committee_deets.html',
                           role=committee_member)
Exemple #4
0
def universal_html_data():
    dictionary = dict()

    dictionary['is_admin'] = check_admin()

    from app.models import Banners
    from app.utils.convert import banners_objectlist_to_urllist
    banners = Banners.query.all()
    dictionary['banners_list'] = banners_objectlist_to_urllist(banners)

    from app.models import Quotes
    from app.utils.convert import quotes_objectlist_to_quotelist
    quotes = Quotes.query.all()
    dictionary['quotes_list'] = quotes_objectlist_to_quotelist(quotes)
    return dictionary
Exemple #5
0
def committee_data_handler(role):
    if not check_admin():
        abort(403)
    from app.models import Committee
    request_form = request.form
    role = role
    name = request_form.getlist('name')[0]
    text = request_form.getlist('text')[0]
    committee_member = Committee.query.filter_by(role=role).first()
    committee_member = Committee.query.get(committee_member.id)
    committee_member.name = name
    committee_member.text = text

    img_url = None
    while True:
        if request.method == 'POST':
            # check if the post request has the file part
            if 'file' not in request.files:
                break
            file = request.files['file']
            # if user does not select file, browser also submits
            # an empty part without filename
            if file.filename == '':
                break
            from werkzeug.utils import secure_filename
            from app.utils.upload import allowed_file
            if file and allowed_file(file.filename):
                filename = secure_filename(file.filename)
                file.save(os.path.join(app.config['UPLOAD_FOLDER'],
                                       filename))
                img_url = file.filename
            break

    if img_url is not None:
        committee_member.photo = 'img/uploads/' + img_url

    db.session.commit()
    return redirect(url_for('committee'))
Exemple #6
0
def add_banner():
    if not check_admin():
        abort(403)
    return render_template('editors/add_banner.html')
Exemple #7
0
def content_editor(page):
    if not check_admin():
        abort(403)
    from app.models import Content
    content = Content.query.filter_by(key=page).first()
    return render_template('editors/content.html', page=page, page_content=content)
Exemple #8
0
 def is_accessible(self):
     from app.utils.profiles.login import check_admin
     if check_admin() is True:
         return True
     abort(403)