Esempio n. 1
0
def crate_ebook():
    if 'username' not in session:
        return render_template('login.html', form=LoginForm())

    ebookform = eBookForm()
    if ebookform.validate_on_submit():
        new_name = ebookform.name.data.strip()
        if ebookform.actors.data.strip() == "":
            new_actors = "Anonymous Writer"
        else:
            new_actors = ebookform.actors.data.strip()
        new_types = combineIntegerToStr(ebookform.types.data)
        new_storage = ebookform.storage.data
        new_path = ebookform.storage_path.data.strip()
        
        op_save_ebook = dbmanager.save_ebook(name=new_name, actors=new_actors, mediatype=new_types, storage=new_storage, file_path=new_path)
        for type_id in ebookform.types.data:
            op_save_e_type = dbmanager.save_ebook_type(op_save_ebook["new_id"], type_id)

        if op_save_ebook["op_status"]:
            logger.info("Save new ebook success, new id is: %d" % op_save_ebook["new_id"])
            return redirect("/ebook/all/1")
        else:
            logger.error("There is some issue for saving new ebook.")
            return render_template("create_ebook.html", pagename="New eBook", search_form=SearchForm(), logon_ueer=session['username'], ebookform=ebookform)
    else:
        return render_template("create_ebook.html", pagename="New eBook", search_form=SearchForm(), logon_ueer=session['username'], ebookform=ebookform)
Esempio n. 2
0
def delete_storge(storage_id):
    if 'username' not in session:
        return render_template('login.html', form=LoginForm())

    storage = dbmanager.find_storage_by_id(storage_id)
    if storage is None:
        logger.error("There is not any storage match id %d." % storage_id)
        return redirect("/storage/all")
    else:
        op_result = dbmanager.delete_storage(storage_id)
        logger.info("Delete the storage with id: %d success." % storage_id)
        return redirect("/storage/all")
Esempio n. 3
0
def delete_mediatype(mediatype_id):
    if 'username' not in session:
        return render_template('login.html', form=LoginForm())

    mediatype = dbmanager.find_mediatype_by_id(mediatype_id)
    if mediatype is None:
        logger.error("There is not any media type match id %d." % mediatype_id)
        return redirect("/mediatype/all")
    else:
        op_result = dbmanager.delete_mediatype(mediatype_id)
        logger.info("Delete the media type with id: %d success." %
                    mediatype_id)
        return redirect("/mediatype/all")
Esempio n. 4
0
def delete_ebook(ebook_id):
    if 'username' not in session:
        return render_template('login.html', form=LoginForm())

    # Clear the mapping
    for e_type in dbmanager.find_ebook_type_by_ebook_id(ebook_id):
        op_delete_e_type = dbmanager.delete_ebook_type(e_type.id)

    op_result = dbmanager.delete_ebook(ebook_id)

    if op_result["op_status"]:
        logger.info("The ebook with id %d has been deleted." % ebook_id)
        return redirect("/ebook/all/1")
    else:
        logger.error("There is some error appeared for deleting ebook with id %d, delete fail." % ebook_id)
        return redirect("/ebook/all/1")
Esempio n. 5
0
def delete_user(user_id):
    if 'username' not in session:
        return render_template('login.html', form=LoginForm())

    op_result = dbmanager.delete_user(user_id)

    if op_result["op_status"]:
        logger.info(op_result["err_msg"])
    else:
        logger.error(op_result["err_msg"])

    user_list = dbmanager.find_all_users()
    if user_list is None:
        return render_template("users.html", pagename="Users", logon_user=session['username'])
    else:
        return render_template("users.html", pagename="Users", logon_user=session['username'], users=user_list)
Esempio n. 6
0
def update_user(user_id):

    usereditform = UserEditForm()
    user = dbmanager.find_user_by_id(user_id)
    if usereditform.validate_on_submit():

        op_result = dbmanager.update_user(user_id, user.username, usereditform.password.data)

        if op_result["op_status"]:
            logger.info(op_result["err_msg"])
        else:
            logger.error(op_result["err_msg"])

        user_list = dbmanager.find_all_users()
        if user_list is None:
            return render_template("users.html", pagename="Users", logon_user=session['username'])
        else:
            return render_template("users.html", pagename="Users", logon_user=session['username'], users=user_list)

    return render_template("/user_edit.html", usereditform=usereditform, user=user, logon_user=session['username'])
Esempio n. 7
0
def create_mediatype():
    if 'username' not in session:
        return render_template('login.html', form=LoginForm())

    mediatypeform = MediaTypeForm()
    if mediatypeform.validate_on_submit():
        mediatype = dbmanager.find_mediatype_by_name(
            mediatypeform.name.data.strip())
        if len(mediatype) == 0:
            logger.info("Saving new media type to db.")
            op_result = dbmanager.save_mediatype(
                mediatypeform.name.data.strip(), mediatypeform.parent.data)
            logger.info("Save new media type complete, status: %s." %
                        op_result["op_status"])
            #return render_template("mediatypes.html", pagename="Media Type", logon_user=session['username'], mediatype_list=mediatype_list)
            return redirect("/mediatype/all")
        else:
            logger.info("Media type is existed.")
            mediatypeform.name.errors.append("Media Type is existed.")
            return render_template("create_mediatype.html",
                                   pagename="Create Media Type",
                                   search_form=SearchForm(),
                                   logon_user=session['username'],
                                   mediatypeform=mediatypeform)

    return render_template("create_mediatype.html",
                           pagename="Create Media Type",
                           search_form=SearchForm(),
                           logon_user=session['username'],
                           mediatypeform=mediatypeform)
Esempio n. 8
0
def update_mediatype(mediatype_id):
    if 'username' not in session:
        return render_template('login.html', form=LoginForm())

    cur_mediatype = dbmanager.find_mediatype_by_id(mediatype_id)
    mediatypeform = MediaTypeForm()
    if mediatypeform.validate_on_submit():
        mediatype = dbmanager.find_mediatype_by_name(
            mediatypeform.name.data.strip())
        if len(mediatype) == 0:
            logger.info("Update new media type to db.")
            op_result = dbmanager.update_mediatype(
                mediatype_id, mediatypeform.name.data.strip(),
                mediatypeform.parent.data)
            logger.info("Update new media type complete, status: %s." %
                        op_result["op_status"])
            return redirect("/mediatype/all")
        else:
            logger.info("Media type is existed.")
            mediatypeform.name.errors.append("Media Type is existed.")
            return render_template("edit_mediatype.html",
                                   pagename="Edit Media Type",
                                   search_form=SearchForm(),
                                   logon_user=session['username'],
                                   mediatypeform=mediatypeform,
                                   cur_mediatype=cur_mediatype)
    else:
        return render_template("edit_mediatype.html",
                               pagename="Edit Media Type",
                               search_form=SearchForm(),
                               logon_user=session['username'],
                               mediatypeform=mediatypeform,
                               cur_mediatype=cur_mediatype)
Esempio n. 9
0
def delete_actor(actor_id):
    if 'username' not in session:
        return render_template('login.html', form=LoginForm())

    cur_actor = dbmanager.find_actor_by_id(actor_id)
    if cur_actor is None:
        logger.error("There is not any actor match id %d." % actor_id)
        return redirect("/actor/all/1")
    else:
        op_photo_delete = dbmanager.delete_photo(cur_actor.thumb)
        if op_photo_delete["op_status"]:
            logger.info("Delete photo with id %d is success." %
                        cur_actor.thumb)
        else:
            logger.error("Delete photo with id %d is fail." % cur_actor.thumb)

        for map_id in dbmanager.find_actor_type_by_actor_id(actor_id):
            op_mapping_delete = dbmanager.delete_actor_type(map_id.id)
            if op_mapping_delete["op_status"]:
                logger.info("Delete mapping with id %d is success." %
                            map_id.id)
            else:
                logger.error("Delete mapping with id %d is fail." % map_id.id)

        op_actor_delete = dbmanager.delete_actor(actor_id)
        if op_actor_delete["op_status"]:
            logger.info("Delete actor with id %d is success." % actor_id)
        else:
            logger.error("Delete actor with id %d fail." % actor_id)
    return redirect("/actor/all/1")
Esempio n. 10
0
def create_storage():
    if 'username' not in session:
        return render_template('login.html', form=LoginForm())

    storageform = StorageForm()
    if storageform.validate_on_submit():
        storage = dbmanager.find_storage_by_name(storageform.name.data.strip())
        if len(storage) == 0:
            logger.info("Saving new media type to db.")
            op_result = dbmanager.save_storage(storageform.name.data.strip(),
                                               storageform.mediatype.data,
                                               float(storageform.size.data))
            logger.info("Save new storage complete, status: %s." %
                        op_result["op_status"])
            return redirect("/storage/all")
        else:
            logger.info("The storage with name %s is existed." %
                        storageform.name.data.strip())
            storageform.name.errors.append(
                "Storage with name '%s' is existed." %
                storageform.name.data.strip())
            return render_template("create_storage.html",
                                   pagename="Create Storage",
                                   search_form=SearchForm(),
                                   logon_user=session['username'],
                                   storageform=storageform)

    logger.error("Create new storage fail.")
    return render_template("create_storage.html",
                           pagename="Create Storage",
                           search_form=SearchForm(),
                           logon_user=session['username'],
                           storageform=storageform)
Esempio n. 11
0
def update_storage(storage_id):
    if 'username' not in session:
        return render_template('login.html', form=LoginForm())

    cur_storage = dbmanager.find_storage_by_id(storage_id)
    storageform = StorageForm()
    if storageform.validate_on_submit():
        storages = dbmanager.find_storage_by_name(
            storageform.name.data.strip())
        if len(storages) == 0:
            logger.info("Update new storage to db.")
            op_result = dbmanager.update_storage(storage_id,
                                                 storageform.name.data.strip(),
                                                 storageform.mediatype.data,
                                                 float(storageform.size.data))
            logger.info("Update new storage complete, status: %s." %
                        op_result["op_status"])
            return redirect("/storage/all")
        else:
            logger.info("Storage %s is existed." %
                        storageform.name.data.strip())
            storageform.name.errors.append("Storage is existed.")
            return render_template("edit_storage.html",
                                   pagename="Edit Storage",
                                   search_form=SearchForm(),
                                   logon_user=session['username'],
                                   storageform=storageform,
                                   cur_storage=cur_storage)
    else:
        return render_template("edit_storage.html",
                               pagename="Edit Storage",
                               search_form=SearchForm(),
                               logon_user=session['username'],
                               storageform=storageform,
                               cur_storage=cur_storage)
Esempio n. 12
0
def update_ebook(ebook_id):
    if 'username' not in session:
        return render_template('login.html', form=LoginForm())

    db_ebook = dbmanager.find_ebook_by_id(ebook_id)
    ebookform = eBookForm(name=db_ebook.name, actors=db_ebook.actors, storage_path=db_ebook.file_path)
    ebookform.set_is_not_edit(False)
    if ebookform.validate_on_submit():
        logger.info("Prepare to update info of eBook with id %d to db." % ebook_id)
        if ebookform.name.data.strip() != db_ebook.name:
            new_name = ebookform.name.data.strip()
        else:
            new_name = db_ebook.name

        if ebookform.actors.data.strip() != db_ebook.actors:
            new_actors = ebookform.actors.data.strip()
        else:
            new_actors = db_ebook.actors
            
        if ebookform.storage_path.data.strip() != db_ebook.file_path:
            new_path = ebookform.storage_path.data.strip()
        else:
            new_path = db_ebook.file_path

        new_types = combineIntegerToStr(ebookform.types.data)
        # Clear the ebook type mapping
        for e_type in dbmanager.find_ebook_type_by_ebook_id(ebook_id):
            op_delete_e_type = dbmanager.delete_ebook_type(e_type.id)
        # Save new type
        for new_e_type in ebookform.types.data:
            ob_update_e_type = dbmanager.save_ebook_type(ebook_id, new_e_type)

        new_storage = ebookform.storage.data

        op_ebook_resp = dbmanager.update_ebook(id=ebook_id, name=new_name, actors=new_actors, mediatype=new_types, storage=new_storage, file_path=new_path)
        logger.info("Update ebook with new data complete, status: %s." % op_ebook_resp["op_status"])
        return redirect("/ebook/all/1")
    else:
        return render_template("edit_ebook.html", pagename="Edit eBook", search_form=SearchForm(), logon_user=session['username'], ebookform=ebookform, ebook_id=ebook_id)
Esempio n. 13
0
def delete_movie(movie_id):
    if 'username' not in session:
        return render_template('login.html', form=LoginForm())

    cur_movie = dbmanager.find_movie_by_id(movie_id)
    if cur_movie is None:
        logger.error("There is not any movie match id %d." % movie_id)
        return redirect("/movie/all/1")
    else:
        op_cover_delete = dbmanager.delete_photo(cur_movie.cover)
        if op_cover_delete["op_status"]:
            logger.info("Delete cover with id %d is success." %
                        cur_movie.cover)
        else:
            logger.error("Delete cover with id %d is fail." % cur_movie.cover)

        # snapshot_list = splitStrIdToInteger(cur_movie.snapshots)
        snapshot_list = dbmanager.find_movie_photo_by_movie_id(movie_id)
        for sid in snapshot_list:
            op_snapshots_delete = dbmanager.delete_photo(sid.photo_id)
            if op_snapshots_delete["op_status"]:
                logger.info("Delete snapshot with id %d is success." %
                            sid.photo_id)
            else:
                logger.error("Delete snapshot with id %d is fail." %
                             sid.photo_id)

        # Clear the mapping between movie and actor
        for m_a_map in dbmanager.find_movie_actor_by_movie_id(movie_id):
            op_m_a_result = dbmanager.delete_movie_actor(m_a_map.id)

        # Clear the mapping between movie and type
        for m_t_map in dbmanager.find_movie_type_by_movie_id(movie_id):
            op_m_t_result = dbmanager.delete_movie_type(m_t_map.id)

        # Clear the mapping between movie and photo
        for m_p_map in dbmanager.find_movie_photo_by_movie_id(movie_id):
            op_m_p_result = dbmanager.delete_movie_photo(m_p_map.id)

        op_movie_delete = dbmanager.delete_movie(movie_id)
        if op_movie_delete["op_status"]:
            logger.info("Delete movie with id %d is success." % movie_id)
        else:
            logger.error("Delete movie with id %d fail." % movie_id)
    return redirect("/movie/all/1")
Esempio n. 14
0
def create_movie(movie_type):
    if 'username' not in session:
        return render_template('login.html', form=LoginForm())

    if movie_type == "regular":
        movieform = MovieRegularForm()

    if movie_type == "adult":
        movieform = MovieAdultForm()

    if movieform.validate_on_submit():
        cur_movie = dbmanager.find_movie_by_name(movieform.name.data.strip())
        if len(cur_movie) == 0:
            logger.info("Saving new movie to db.")
            new_name = movieform.name.data.strip()

            if movieform.provider.data.strip() == "":
                new_provider = "Default Provider"
            else:
                new_provider = movieform.provider.data.strip()

            new_actor_list = combineIntegerToStr(movieform.actors.data)
            new_storage = movieform.storage.data
            new_filepath = movieform.storage_path.data.strip()
            # Save the cover file
            if movieform.cover.data.filename == '':
                op_cover_save = dbmanager.save_photo_with_string(
                    "nopic", ".jpg", PHOTO_TYPE["COVER"], "")
            else:
                cover_file = movieform.cover.data.filename
                logger.info("Upload file %s" % cover_file)
                upload_filename = os.path.splitext(cover_file)[0]
                upload_suffix = os.path.splitext(cover_file)[1]
                save_filename = str(
                    uuid.uuid3(uuid.NAMESPACE_URL,
                               upload_filename.encode('utf-8')))
                save_fullfilename = save_filename + upload_suffix
                save_path = MEDIA_LOCAL_PATH + save_fullfilename
                logger.info("Save path is %s" % save_path)
                movieform.cover.data.save(save_path)
                op_cover_save = dbmanager.save_photo_with_string(
                    save_filename, upload_suffix, PHOTO_TYPE["COVER"],
                    MEDIA_URL + save_fullfilename)
            # end of saving cover file
            # Save snapshot files
            snapshot_list = request.files.getlist('snapshots')
            op_snapshots = []
            for snapshot in snapshot_list:
                # Save the snapshot file
                snapshot_file = snapshot.filename
                logger.info("Upload file %s" % snapshot_file)
                snapshot_filename = os.path.splitext(snapshot_file)[0]
                snapshot_suffix = os.path.splitext(snapshot_file)[1]
                snapshot_filename = str(
                    uuid.uuid3(uuid.NAMESPACE_URL,
                               snapshot_filename.encode('utf-8')))
                snapshot_fullfilename = snapshot_filename + snapshot_suffix
                snapshot_path = MEDIA_LOCAL_PATH + snapshot_fullfilename
                logger.info("Save path is %s" % snapshot_path)
                snapshot.save(snapshot_path)
                op_snapshot_save = dbmanager.save_photo_with_string(
                    snapshot_filename, snapshot_suffix, PHOTO_TYPE["SNAPSHOT"],
                    MEDIA_URL + snapshot_fullfilename)
                op_snapshots.append(op_snapshot_save["new_id"])
                # end of saving cover file
            op_movie_save = dbmanager.save_movie(
                name=new_name,
                actors=new_actor_list,
                snapshots=combineIntegerToStr(op_snapshots),
                cover=op_cover_save["new_id"],
                types=MOVIE_TYPE[movie_type.upper()],
                provider=new_provider,
                storage=new_storage,
                file_path=new_filepath)

            # Save the mapping between Movie and snapshots
            for s_id in op_snapshots:
                ob_map_m_s = dbmanager.save_movie_photo(
                    op_movie_save["new_id"], s_id)

            # Save the mapping between Movie and actors
            for a_id in movieform.actors.data:
                ob_map_m_a = dbmanager.save_movie_actor(
                    op_movie_save["new_id"], a_id)

            # Save the mapping between Movie and type
            op_map_m_t = dbmanager.save_movie_type(
                op_movie_save["new_id"], MOVIE_TYPE[movie_type.upper()])

            return redirect("/movie/all/1")
        else:
            logger.info("The movie with name %s seems existed." %
                        movieform.name.data.strip())
            return render_template("create_movie.html",
                                   pagename="New Movie",
                                   search_form=SearchForm(),
                                   loggon_user=session['username'],
                                   movieform=movieform,
                                   movie_type=movie_type)
    else:
        return render_template("create_movie.html",
                               pagename="New Movie",
                               search_form=SearchForm(),
                               logon_ueer=session['username'],
                               movieform=movieform,
                               movie_type=movie_type)
Esempio n. 15
0
def update_actor(actor_id):
    if 'username' not in session:
        return render_template('login.html', form=LoginForm())

    cur_actor = dbmanager.find_actor_by_id(actor_id)
    actorform = ActorForm(name=cur_actor.name)
    actorform.set_is_not_edit(False)
    if actorform.validate_on_submit():
        logger.info("Prepare to update info of actor with id %d to db." %
                    actor_id)
        if actorform.country.data.strip() != cur_actor.country:
            new_country = actorform.country.data.strip()
        else:
            new_country = cur_actor.country

        if actorform.sex.data != cur_actor.sex:
            new_sex = actorform.sex
        else:
            new_sex = cur_actor.sex

        if actorform.description.data.strip() != cur_actor.description:
            new_description = actorform.description.data.strip()
        else:
            new_description = cur_actor.description

        new_type_list = combineIntegerToStr(actorform.types.data)
        # Clear the original mapping
        for origin_map in dbmanager.find_actor_type_by_actor_id(actor_id):
            op_origin_map_result = dbmanager.delete_actor_type(origin_map.id)
        # Save mapping with new one
        for new_type_id in actorform.types.data:
            op_new_map_result = dbmanager.save_actor_type(
                actor_id, new_type_id)

        # Process the photo update.
        if actorform.thumb.data.filename.strip() == "":
            new_thumb = cur_actor.thumb
        else:
            if MEDIA_SAVE_TO_DB:
                pass
            else:
                upload_file = actorform.thumb.data.filename
                logger.info("Upload file %s" % upload_file)
                upload_filename = os.path.splitext(upload_file)[0]
                upload_suffix = os.path.splitext(upload_file)[1]
                save_filename = str(
                    uuid.uuid3(uuid.NAMESPACE_URL,
                               upload_filename.encode('utf-8')))
                save_fullfilename = save_filename + upload_suffix
                save_path = MEDIA_LOCAL_PATH + save_fullfilename
                print(MEDIA_LOCAL_PATH, save_fullfilename)
                logger.info("Save path is %s" % save_path)
                actorform.thumb.data.save(save_path)
                op_photo_result = dbmanager.save_photo_with_string(
                    save_filename, upload_suffix, PHOTO_TYPE["NORMAL"])
                new_thumb = op_photo_result["new_id"]

        if new_thumb == cur_actor.thumb and actorform.thumb_path.data.strip(
        ) != "":
            thumb_url = actorform.thumb_path.data.strip()
            logger.info("Upload file path is %s" % thumb_url)
            thumb_url_name = os.path.splitext(thumb_url.split("/")[-1])[0]
            thumb_url_suffix = os.path.splitext(thumb_url.split("/")[-1])[1]
            op_photo_result = dbmanager.save_photo_with_string(
                thumb_url_name, thumb_url_suffix, PHOTO_TYPE["NORMAL"],
                thumb_url)
            new_thumb = op_photo_result["new_id"]

        op_result = dbmanager.update_actor(id=actor_id,
                                           name=cur_actor.name,
                                           country=new_country,
                                           sex=new_sex,
                                           types=new_type_list,
                                           description=new_description,
                                           thumb=new_thumb)
        logger.info("Update actor with new data complete, status: %s." %
                    op_result["op_status"])
        return redirect("/actor/all/1")
    else:
        return render_template("edit_actor.html",
                               pagename="Edit Actor",
                               search_form=SearchForm(),
                               logon_user=session['username'],
                               actorform=actorform,
                               actor_id=actor_id)
Esempio n. 16
0
def create_actor():
    if 'username' not in session:
        return render_template('login.html', form=LoginForm())

    actorform = ActorForm()
    if actorform.validate_on_submit():
        actors = dbmanager.find_actor_by_name(actorform.name.data.strip())
        if len(actors) == 0:
            logger.info("Saving new actor to db.")
            if actorform.thumb.data.filename.strip() != "":
                if MEDIA_SAVE_TO_DB:
                    pass
                else:
                    upload_file = actorform.thumb.data.filename
                    logger.info("Upload file %s" % upload_file)
                    upload_filename = os.path.splitext(upload_file)[0]
                    upload_suffix = os.path.splitext(upload_file)[1]
                    save_filename = str(
                        uuid.uuid3(uuid.NAMESPACE_URL,
                                   upload_filename.encode('utf-8')))
                    save_fullfilename = save_filename + upload_suffix
                    save_path = MEDIA_LOCAL_PATH + save_fullfilename
                    logger.info("Save path is %s" % save_path)
                    actorform.thumb.data.save(save_path)
                    op_photo_result = dbmanager.save_photo_with_string(
                        save_filename, upload_suffix, PHOTO_TYPE["NORMAL"],
                        MEDIA_URL + save_fullfilename)
                    type_list = combineIntegerToStr(actorform.types.data)
                    op_result = dbmanager.save_actor(
                        actorform.name.data.strip(), actorform.sex.data,
                        actorform.country.data.strip(),
                        actorform.description.data.strip(),
                        op_photo_result["new_id"], type_list)
                    # save mapping of actor and mediatype
                    for type_id in actorform.types.data:
                        op_a_type_result = dbmanager.save_actor_type(
                            op_result["new_id"], type_id)

                    logger.info("Save new actor complete, status: %s." %
                                op_result["op_status"])
                    return redirect("/actor/all/1")
            else:
                thumb_url = actorform.thumb_path.data.strip()
                logger.info("Upload file path is %s" % thumb_url)
                thumb_url_name = os.path.splitext(thumb_url.split("/")[-1])[0]
                thumb_url_suffix = os.path.splitext(
                    thumb_url.split("/")[-1])[1]
                op_photo_result = dbmanager.save_photo_with_string(
                    thumb_url_name, thumb_url_suffix, PHOTO_TYPE["NORMAL"],
                    thumb_url)
                type_list = combineIntegerToStr(actorform.types.data)
                op_result = dbmanager.save_actor(
                    actorform.name.data.strip(), actorform.sex.data,
                    actorform.country.data.strip(),
                    actorform.description.data.strip(),
                    op_photo_result["new_id"], type_list)

                # save mapping of actor and mediatype
                for type_id in actorform.types.data:
                    op_a_type_result = dbmanager.save_actor_type(
                        op_result["new_id"], type_id)

                logger.info(
                    "Save new actor with url thumb complete, status is %s: " %
                    op_result["op_status"])
                return redirect("/actor/all/1")
        else:
            logger.info("The actor with name %s is existed." %
                        actorform.name.data.strip())
            actorform.name.errors.append("Actor with name '%s' is existed." %
                                         actorform.name.data.strip())
            return render_template("create_actor.html",
                                   pagename="Create Actor",
                                   search_form=SearchForm(),
                                   logon_user=session['username'],
                                   actorform=actorform)

    logger.error("Create new actor fail.")
    return render_template("create_actor.html",
                           pagename="Create Actor",
                           search_form=SearchForm(),
                           logon_user=session['username'],
                           actorform=actorform)