Пример #1
0
def edit_tag(errors, tag, args={}):
    if not access(["moder"]):
        errors.append("no access")
        return errors, args

    errors, args = edit_tag_body(errors, tag)

    return errors, args
Пример #2
0
def delete_comment(errors, comment):
    if not access(["moder"], comment.author):
        errors.append("no access")
        return errors

    errors = delete_comment_body(errors, comment)

    return errors
Пример #3
0
def edit_post(errors, post, args={}):
    if not access(author=post.author):
        errors.append("no access")

        return errors, args
    errors, args = edit_post_body(errors, post)

    return errors, args
Пример #4
0
def delete_post(errors, post):
    if not access(["moder"]):
        errors.append("no access")
        return errors

    errors = delete_post_body(errors, post)

    return errors
Пример #5
0
def delete_tag(errors, tag):
    if not access(["moder"]):
        errors.append("no access")
        return errors

    errors = delete_tag_body(errors, tag)

    return errors
Пример #6
0
def delete_icon(errors, icon):
    if not access(author=icon.user):
        errors.append("no access")
        return errors

    errors = delete_icon_body(errors, icon)

    return errors
Пример #7
0
def edit_role(errors, role, args={}):
    if not access(["God"]):
        errors.append("no access")
        return errors, args

    errors, args = edit_role_body(errors, role)

    return errors, args
Пример #8
0
def delete_role(errors, role):
    if not access(["admin"], role):
        errors.append("no access")
        return errors

    errors = delete_user_body(errors, role)

    return errors
Пример #9
0
def edit_comment(errors, comment, args={}):
    if not access(author=comment.author):
        errors.append("no access")
        return errors, args

    errors, args = edit_comment_body(errors, comment)

    return errors, args
Пример #10
0
def delete_image(errors, image):
    if not access(["moder"], image.post_parent.author):
        errors.append("no access")
        return errors

    errors = delete_image_body(errors, image)

    return errors
Пример #11
0
def delete_image_after_post(errors, post):
    if not access(["moder"], post.author):
        errors.append("no access")
        return errors

    for image in post.images:
        errors = delete_image_body(errors, image)

    return errors
Пример #12
0
def create_comment(errors, form, args):
    if not access(auth=True):
        errors.append("no access")

        return errors

    errors = create_comment_body(errors, form, args)

    return errors
Пример #13
0
def ban_user(errors, user):
    if not access(["moder"]):
        errors.append("no access")
        return errors

    if not access_bigger(current_user, user):
        errors.append("Your access must be higher than have subject")
        return errors

    errors = ban_user_body(errors, user)

    return errors
Пример #14
0
def delete_user(errors, user):
    if not access_bigger(current_user, user):
        errors.append("Your access must be higher than have subject")
        return errors

    if not access(["admin"], user):
        errors.append("no access")
        return errors

    errors = delete_user_body(errors, user)

    return errors
Пример #15
0
def delete_comments_after_post(errors, post):
    """

    :param errors:
    :param post:
    :return:
    """
    if not access(["moder"], post.author):
        errors.append("no access")
        return errors

    for comment in post.comments:
        errors = delete_comment_body(errors, comment)

    return errors
Пример #16
0
def create_tag(errors, form):
    if not access(["moder"]):
        errors.append("no access")

        return errors

    # SEARCH SUCH TAG
    name_in_db = Tag.query.filter(Tag.name == form.name.data).first()

    if name_in_db:
        errors.append("Tag with that name already added")

        return errors

    errors = create_tag_body(errors, form)

    return errors
Пример #17
0
def create_role(errors, form):
    if not access(["God"]):
        errors.append("no access")

        return errors

    # SEARCH SUCH ROLE
    name_in_db = Role.query.filter(Role.name == form.name.data).first()

    if name_in_db:
        errors.append("Role with that name already added")

        return errors

    errors = create_role_body(errors, form)

    return errors
Пример #18
0
def read_user(user_id):
    errors = []

    # search
    user = User.query.filter(User.id == user_id).first()

    if not user:
        abort(404)

    # FORM

    form = SelectRoleForm()
    form_2 = upload_icon_form()

    #  EDIT ROLES

    if request.method == "POST":

        if not access(["God"]):
            errors.append("no access")

            return render_template("auth/profile.html",
                                   access=access,
                                   user=user,
                                   form=form)
        user.roles = []

        for role in form.roles.data:
            user.roles.append(Role.query.filter(Role.id == int(role)).first())

        if not errors:
            db.session.commit()

    # PUT ROLE IN FORM

    form.roles.data = []

    for role in user.roles:
        form.roles.data.append(str(role.id))

    return render_template("auth/profile.html",
                           access=access,
                           user=user,
                           form=form,
                           form_2=form_2)
Пример #19
0
        results = search(query, movie)  # Search and get results

        if not results:
            print('No results, try again.\n')

    title = inquirer.prompt([
        inquirer.List(
            'title', 'Select movie or TV show', results.keys(), carousel=True)
    ],
                            theme=theme,
                            raise_keyboard_interrupt=True)['title']

    print('Loading data...\n')

    data = load(results[title], movie)  # Get TV show or movie data
    acc = access(data['ID'], movie)  # Get access data

    expiration, token = acc['data']['expires'], acc['data']['accessToken']

    if movie:
        print('Looking for video qualities...\n')

        mst = master(data['ID'], expiration, token, True)
        links = qualities(mst)

        directory = os.path.join(os.getcwd(), title)
        temporary = os.path.join(os.getcwd(), 'temp')

        quality = inquirer.prompt(
            [
                inquirer.List('quality',