コード例 #1
0
def create_movie():
    if request.method == 'POST':
        title = request.form['title']
        director = request.form['director']
        producer = request.form['producer']
        cast = request.form['cast']
        duration = request.form['duration']
        synopsis = request.form['synopsis']
        rating = request.form['rating']
        category = request.form['category']
        video = request.form['video']
        picture = request.form['picture']

        # validate all data, everything must be correct
        error = None

        db = get_db()
        if db.execute(
            'SELECT * FROM movie WHERE title = ? ',
            (title,)
        ).fetchone() is not None:
            error = "Movie already exists"
        elif not validate_name(title):
            error = "Movie title is too short or too long"
        elif not validate_name(director):
            error = "Director name is too short or too long"
        elif not validate_name(producer):
            error = "Producer name is too short or too long"
        elif not validate_name(cast):
            error = "Cast name is too short or too long"
        elif not validate_duration(duration):
            error = "Duration must be a whole number"
        elif not validate_text(synopsis):
            error = "Synopsis is too long"
        elif not validate_rating(rating):
            error = "Invalid rating"
        elif not validate_category(category):
            error = "Invalid category"
        elif video.isspace():
            error = "Video link is required"
        elif picture.isspace():
            error = "Picture link is required"

        if error is None:
            # if error is None, create a movie
            new_movie = Movie()
            new_movie.create(title=title, director=director,
                             producer=producer, cast=cast,
                             synopsis=synopsis, picture=picture,
                             video=video,
                             duration_as_minutes=int(duration),
                             rating=rating, category=category)

            # then return to add movie
            return redirect(url_for('AdminMoviesController.manage_movies'))

        flash(error)

    return render_template('make_movie.html')
コード例 #2
0
def is_active_user(email: str) -> bool:
    db = get_db()
    status = db.execute('SELECT status FROM customer WHERE email = ?',
                        (email, )).fetchone()

    if status is not None:
        return True if status['status'] == 'active' else False
    return False
コード例 #3
0
 def __init__(self):
     self.__db = get_db()
コード例 #4
0
def is_unique_username(username: str):
    db = get_db()
    return (db.execute('SELECT customer_id FROM customer WHERE username = ?',
                       (username, )).fetchone() is None
            and db.execute('SELECT admin_id FROM admin WHERE username = ?',
                           (username, )).fetchone() is None)
コード例 #5
0
def booking_has_promo(promo_id: int):
    db = get_db()
    return (db.execute('SELECT * FROM booking WHERE promo_id = ?',
                       (promo_id, )).fetchone is None)
コード例 #6
0
def is_unique_promo(code: str):
    db = get_db()
    return (db.execute('SELECT promo_id FROM promo WHERE code = ?',
                       (code, )).fetchone() is None)
コード例 #7
0
def is_new_email(email: str):
    db = get_db()
    return (db.execute('SELECT customer_id FROM customer WHERE email = ?',
                       (email, )).fetchone() is None)
コード例 #8
0
ファイル: SearchData.py プロジェクト: ztech963/ECinemaBooking
 def __init__(self):
     self.__db = get_db()
     self.__select = 'SELECT movie.movie_id, title, category, picture, video, rating, status, time, available_seats FROM movie NATURAL JOIN showtime WHERE '
     self.__coming_select = 'SELECT movie_id, title, category, picture, video, rating, status FROM movie WHERE status = "inactive" AND '