Exemple #1
0
def update_localisation():

    # handle authetication problems
    handle_authentication(False)

    form = Users.forms.Localisation()
    fields = extract_fields(form)
    if request.method == 'GET':
        # pre fill all fields
        for field in fields:
            k = getattr(form, field)
            k.data = getattr(current_user, field)
    else:
        if form.validate_on_submit():
            # if needed add the town to Town table
            if form.town.data not in Town.list_all():
                form.town.data = form.town.data.capitalize()\
                    .strip().replace("  ", " ").replace("  ", " ")
                db.session.add(Town(town=form.town.data))
            # update User attrs
            for field in fields:
                setattr(current_user, field, getattr(form, field).data)
            return commit_flash_redirect('users.manage_user')
        else:
            flash_all_errors(form)

    return render_template('user/update/update_localisation.html',
                           title="Localisation",
                           form=form,
                           fields=fields,
                           country_list=Country.list_all(),
                           town_list=Town.list_all())
Exemple #2
0
def logout():

    handle_authentication(False)
    logout_user()
    flash("successfuly logged out", 'success')

    return redirect(url_for('main.home'))
Exemple #3
0
def update_user():

    handle_authentication(False)

    form = Users.forms.Update()
    fields = extract_fields(form)
    if request.method == 'GET':
        # prefill the form
        form.username.data = current_user.username
        form.email.data = current_user.email
        form.password.data = ""
        form.confirm_password.data = ""
    else:
        if form.validate_on_submit():
            hashed_password = bcrypt.generate_password_hash(
                form.password.data).decode('utf-8')
            current_user.username = form.username.data
            current_user.email = form.email.data
            current_user.password = hashed_password
            db.session.commit()
            flash('Your account has been modified! Please re-log in',
                  'success')
            logout_user()
            return redirect(url_for('users.login'))
        else:
            flash_all_errors(form)

    return render_template('user/update/update_user.html',
                           title='Compte',
                           fields=fields,
                           form=form)
Exemple #4
0
def visualize_opportunity(opp_id):
    # handle connections problems
    handle_authentication(False)
    opp = Opportunity.query.filter_by(id=opp_id).first()
    # authetication problem
    if current_user.id != opp.user_id:
        flash("sorry this is not your opp, you are not allowed", "danger")
        return redirect(url_for("main.edhunt"))
    opp_id_next = opp_id_past = None
    opps = Opportunity.query.filter_by(search_id=opp.search_id).all()
    # nav
    idx = opps.index(opp)
    if idx > 0 and (len(opps) > 1):
        opp_id_past = opps[idx - 1].id
    if (not (idx + 1 == len(opps))):
        opp_id_next = opps[idx + 1].id
    nav = {
        "opp_id_next": opp_id_next,
        "opp_id_past": opp_id_past,
        "search_id": opp.search_id
    }

    return render_template('opportunity/visualize_opportunity.html',
                           title="Opportunity",
                           opp=opp,
                           nav=nav)
Exemple #5
0
def update_language():

    # handle authetication problems
    handle_authentication(False)

    form = Users.forms.Languages()
    fields = extract_fields(form)
    if request.method == 'GET':
        # prefill all fields
        for field in fields:
            k = getattr(form, field)
            k.data = getattr(current_user, field)
    else:
        if form.validate_on_submit():
            # update user attrs
            for field in fields:
                setattr(current_user, field, getattr(form, field).data)
            return commit_flash_redirect('users.manage_user')
        else:
            flash_all_errors(form)

    return render_template('user/update/update_language.html',
                           title="Langues",
                           form=form,
                           fields=fields)
Exemple #6
0
def test_plateform(plateform):

    plateform_name = plateform
    # handle authetication problems
    handle_authentication(False)
    plateform = getattr(
        Plateforms.tables,
        plateform_name).query.filter_by(user_id=current_user.id).first()

    msg = ""
    if not plateform:
        msg = f"Sorry but you do not have set you plateform info {plateform_name}"
    if (not plateform.email) or (not plateform.password):
        msg = f"Sorry but you do not have set you plateform email/password for {plateform_name}"
    if msg:
        flash(msg, "danger")
        return redirect(
            url_for("plateforms.update_plateform", plateform=plateform_name))

    res, msg, color = WebDriver.test_connexion(plateform)
    flash(msg, color)
    if res:
        plateform.connexion = "On"
    else:
        plateform.connexion = "Off"
    db.session.commit()

    return redirect(url_for("plateforms.manage_plateforms"))
Exemple #7
0
def visualize_search(search_id):
    # handle connections problems
    handle_authentication(False)
    search = Search.query.filter_by(id=search_id).first()
    opp_list = Opportunity.query.filter_by(search_id=int(search_id)).all()

    # authetication problem
    if (current_user.id != search.user_id):
        flash("sorry this is not your opp, you are not allowed", "danger")
        return redirect(url_for("main.edhunt"))

    search_id_next = search_id_past = None
    search_s = Search.query.filter_by(user_id=current_user.id).all()
    # nav
    idx = search_s.index(search)
    if idx > 0 and (len(search_s) > 1):
        search_id_past = search_s[idx - 1].id
    if (not (idx + 1 == len(search_s))):
        search_id_next = search_s[idx + 1].id
    nav = {"search_id_next": search_id_next, "search_id_past": search_id_past}

    return render_template('search/visualize_search2.html',
                           title="Opportunity",
                           opp_list=opp_list,
                           user=current_user,
                           search=search,
                           nav=nav)
Exemple #8
0
def update_searched_status(search_id):

    # handle connections problems
    handle_authentication(False)
    search = Search.query.filter_by(id=search_id).first()
    # authetication problem
    if current_user.id != search.user_id:
        flash("sorry this is not your search, you are not allowed", "danger")
        return redirect(url_for("main.edhunt"))

    form = SearchsForms.Status()
    fields = extract_fields(form)
    if request.method == 'GET':
        # prefill all fields
        for field in fields:
            k = getattr(form, field)
            k.data = getattr(search, field)
    else:
        if form.validate_on_submit():
            # update user attrs
            for field in fields:
                d = getattr(form, field).data
                if isinstance(d, list):
                    d = ", ".join(d)
                setattr(search, field, d)
            db.session.commit()
            flash("Search updated", "success")
            return redirect(
                url_for('searchs.manage_search', search_id=search.id))
        else:
            flash_all_errors(form)
    return render_template('search/update/update_searched_status.html',
                           title="Update Statuts",
                           form=form,
                           search_id=search.id)
Exemple #9
0
def search_light(plateform, words, loc):

    plateform_name = plateform
    handle_authentication(False)
    plateform = getattr(
        Plateforms.tables,
        plateform_name).query.filter_by(user_id=current_user.id).first()

    msg = ""
    if not plateform:
        msg = f"Sorry but you do not have set you plateform info {plateform_name}"
    if (not plateform.email) or (not plateform.password):
        msg = f"Sorry but you do not have set you plateform email/password for {plateform_name}"
    if msg:
        flash(msg, "danger")
        return redirect(
            url_for("plateforms.update_plateform", plateform=plateform_name))

    res, msg, color = WebDriver.search_light(plateform_name, plateform, words,
                                             loc)

    # flash(msg, color)
    # if res:
    #     plateform.connexion = "On"
    #     db.session.commit()
    #     return redirect(url_for("plateforms.manage_plateforms"))
    # else:
    #     plateform.connexion = "Off"
    #     db.session.commit()
    #     redirect(url_for("plateforms.update_plateform", plateform=plateform_name))

    return redirect(
        url_for("plateforms.update_plateform", plateform=plateform_name))
Exemple #10
0
def candidate(opp_id):

    handle_authentication(False)
    opp = Opportunity.query.filter_by(id=opp_id).first()
    if not opp:
        raise AttributeError("pb with opp")

    if current_user.id != opp.user_id:
        flash("sorry this is not your search, you are not allowed", "danger")
        return redirect(url_for("main.edhunt"))

    plateform = getattr(
        Plateforms.tables,
        opp.plateform).query.filter_by(user_id=current_user.id).first()

    msg = ""
    if not plateform:
        msg = f"Sorry but you do not have set you plateform info {plateform_name}"
    if (not plateform.email) or (not plateform.password):
        msg = f"Sorry but you do not have set you plateform email/password for {plateform_name}"
    if msg:
        flash(msg, "danger")
        return redirect(
            url_for("plateforms.update_plateform", plateform=plateform_name))

    res, msg, color = WebDriver.candidate(plateform, opp.url)

    flash(msg, "info")
    flash("donne", info)

    return redirect(url_for("main.edhunt"))
Exemple #11
0
def update_expectation():

    # handle authetication problems
    handle_authentication(False)

    form = Users.forms.Expectation()
    fields = extract_fields(form)
    if request.method == 'GET':
        # prefill the form
        form.employed.data = current_user.employed
        form.search.data = current_user.search
        form.order.data = current_user.order
        form.automation.data = current_user.automation
    else:
        if form.validate_on_submit():
            # update user info
            current_user.employed = form.employed.data
            current_user.sub_employed = form.sub_employed.data

            current_user.search = form.search.data
            current_user.order = form.order.data
            current_user.automation = form.automation.data
            return commit_flash_redirect('users.manage_user')
        else:
            flash_all_errors(form)

    return render_template('user/update/update_expectation.html',
                           title="Attentes",
                           fields=fields,
                           form=form)
Exemple #12
0
def update_resume(n):

    # handle authetication problems
    handle_authentication(False)

    form = Users.forms.Resume()
    fields = extract_fields(form)
    if request.method == 'GET':
        # prefill the form
        pass
    else:
        if form.validate_on_submit():
            # update user info
            _resume_doc = save_resume(form.resume_doc.data)
            setattr(current_user, f"resume{n}_doc", _resume_doc)
            if form.resume_name.data:
                setattr(current_user, f"resume{n}_name", form.resume_name.data)
            else:
                setattr(current_user, f"resume{n}_name", f"my_resume_{n}")
            return commit_flash_redirect('users.manage_user')
        else:
            if form.errors:
                flash_all_errors(form)

    return render_template('user/update/update_resume.html',
                           title="CVs",
                           fields=fields,
                           form=form)
Exemple #13
0
def maj_search(search_id):

    # handle connections problems
    handle_authentication(False)
    # form and fields
    form = SearchsForms.Update()
    search = Search.query.filter_by(id=search_id).first()

    # authetication problem
    if current_user.id != search.user_id:
        flash("sorry this is not your search, you are not allowed", "danger")
        return redirect(url_for("main.edhunt"))

    avialable_plateforms = current_user.avialable_plateforms()

    key_words = search.key_words
    loc = search.town

    if "apec" in avialable_plateforms:
        plat = getattr(Plateforms.tables, "apec")\
            .query.filter_by(user_id=current_user.id).first()
        warning(plat)
        opportunities_list, msg, color = Plateforms.WebDriver.search_light(
            plat, key_words, loc)
    else:
        raise ValueError("Apec not connected")

    try:
        opportunities_list
    except Exception as e:
        raise e

    existing_opps = Opportunity.query.filter_by(search_id=search.id).all()
    old_len_existing_opps = len(existing_opps)
    existing_opps = [i.url for i in existing_opps]

    if not opportunities_list:
        flash("error with opportunities_list or opportunities_list url",
              "info")

    for opp_dict in opportunities_list:
        opp = Opportunity(user_id=current_user.id,
                          search_id=search.id,
                          **opp_dict)
        if opp.url not in existing_opps:
            db.session.add(opp)
            db.session.commit()

    existing_opps = Opportunity.query.filter_by(search_id=search.id).all()
    new_len_existing_opps = len(existing_opps)
    new_opps = new_len_existing_opps - old_len_existing_opps
    flash(f"{new_opps} new opps added", "info")

    return redirect(url_for("searchs.visualize_search", search_id=search.id))
Exemple #14
0
def create_search():

    # handle connections problems
    handle_authentication(False)
    # form and fields
    form = SearchsForms.Create()
    # fields = extract_fields(form)
    if request.method == 'GET':
        pass
    else:
        if form.validate_on_submit():
            # if needed add the town to Town table
            for i in (1, 2, 3, 4, 5):
                town = getattr(form, f"town_{i}").data
                if town not in Town.list_all():
                    town = town.capitalize()\
                        .strip().replace("  ", " ").replace("  ", " ")
                    db.session.add(Town(town=town))

            search = Search(user_id=current_user.id)
            # upadte user attrs
            search.name = form.name.data
            search.mob = form.mob.data
            for feat in ["country", "departement", "region", "town"]:
                _data = [
                    getattr(form, f"{feat}_{i}").data for i in [1, 2, 3, 4, 5]
                ]
                setattr(search, feat, ", ".join([i for i in _data if i]))
            form.key_words.data = form.key_words.data.strip().upper()\
                .replace("-", " ").replace("  ", " ").replace("  ", " ")
            if form.key_words.data:
                kwords = form.key_words.data
                kwords = kwords.lower().strip()\
                    .replace("-", " ").replace("  ", " ").replace("  ", " ")
                kwords = ", ".join([i.strip() for i in kwords.split(",")])
                form.key_words.data = kwords
            search.key_words = form.key_words.data
            db.session.add(search)
            db.session.commit()
            flash("search updated", "success")
            return redirect(
                url_for("searchs.manage_search", search_id=search.id))
        else:
            flash_all_errors(form)

    form.submit.label.text = "Create"
    return render_template('search/create_search.html',
                           title="Create Search",
                           mode="Create",
                           form=form,
                           country_list=Country.list_all(),
                           town_list=Town.list_all(),
                           departement_list=Departement.list_all(),
                           region_list=Region.list_all())
Exemple #15
0
def view_resume(filename, n):

    # handle authetication problems
    handle_authentication(False)
    img = create_image(filename)
    img = url_for('static', filename="resumes/" + img)

    return render_template('user/view_resume.html',
                           title="CV",
                           filename=filename,
                           img=img,
                           n=n)
Exemple #16
0
def manage_search(search_id):

    # handle connections problems
    handle_authentication(False)
    search = Search.query.filter_by(id=search_id).first()
    # authetication problem
    if current_user.id != search.user_id:
        flash("sorry this is not your search, you are not allowed", "danger")
        return redirect(url_for("main.edhunt"))

    return render_template('search/manage_search2.html',
                           title="Search",
                           search=search)
Exemple #17
0
def visualize_opportunities():
    # handle connections problems
    handle_authentication(False)
    opp_list = Opportunity.query.filter_by(user_id=int(current_user.id)).all()

    # # authetication problem
    # if current_user.id != int(user_id):
    #   flash("sorry this is not your opp, you are not allowed", "danger")
    #   return redirect(url_for("main.edhunt"))

    return render_template('opportunity/visualize_opportunities.html',
                           title="Opportunities",
                           opp_list=opp_list,
                           user=current_user)
Exemple #18
0
def _register_user(token):

    if Params.FORCE_QUESTIONNAIRE:
        q = Questionnaire.query.filter_by(token=token).first()
        if not q:
            flash("Hummmm, petite futée, tu t'es crue la plus maline?")
            return redirect(url_for('main.questionnaire_1'))

    if Params.DISABLE_REGISTER:
        try:
            logout_user()
        except:
            pass
        return redirect(url_for('main.connection', token=token))

    handle_authentication(True)
    form = Users.forms.Register()
    fields = extract_fields(form)
    if form.validate_on_submit():
        hashed_password = bcrypt.generate_password_hash(
            form.password.data).decode('utf-8')
        user = Users.table(username=form.username.data,
                           email=form.email.data,
                           password=hashed_password)
        previous_fields = [
            "search", "employed", "contract", "diploma_type", "xp_at_work",
            "status", "diploma_year", "search", "sector", "zip_code",
            "function", "position", "management", "rem", "diploma_level"
        ]

        for field in previous_fields:
            setattr(user, field, getattr(q, field))
        db.session.add(user)
        db.session.commit()

        # CREATE PLATEFORMS
        for p in Plateforms.list_all:
            Plate = getattr(Plateforms.tables, p)
            db.session.add(Plate(user_id=user.id))
        db.session.commit()

        flash('Your account has been created! You are now able to log in',
              'success')
        return redirect(url_for('users.login'))

    return render_template('user/register_user.html',
                           title='Inscription',
                           fields=fields,
                           form=form)
Exemple #19
0
def update_plateform(plateform):

    plateform_name = plateform
    # handle authetication problems
    handle_authentication(False)

    form = Plateforms.forms.Update()
    fields = extract_fields(form)
    plateform = getattr(
        Plateforms.tables,
        plateform_name).query.filter_by(user_id=current_user.id).first()
    if request.method == 'GET':
        if plateform:
            for field in fields:
                getattr(form, field).data = getattr(plateform, field)
    else:
        if form.validate_on_submit():

            if not plateform:
                plateform = getattr(Plateforms.tables,
                                    plateform_name)(user_id=current_user.id)
                db.session.add(plateform)
                db.session.commit()
            if form.account.data == "Oui":
                form.sub_account.data = "Oui"
            plateform = getattr(Plateforms.tables,
                                plateform_name).query.filter_by(
                                    user_id=current_user.id).first()
            for field in fields:
                setattr(plateform, field, getattr(form, field).data)
                db.session.commit()
            # if form.connection.data != "On":
            #     flash(f"Sorry  did not allow to login to {plateform}",
            #           "danger")
            #     return redirect(url_for("users.manage_user"))
            for i in ["autorisation", "good_user", "edhunt_integrity"]:
                if getattr(form, i).data != "Oui":
                    flash(
                        f"Sorry you must accept credentials to login to {plateform_name}",
                        "danger")
                    return redirect(url_for("plateforms.manage_plateforms"))
            return commit_flash_redirect('plateforms.manage_plateforms')
        else:
            flash_all_errors(form)

    return render_template('plateform/update_plateform.html',
                           title=plateform_name,
                           form=form,
                           fields=fields)
Exemple #20
0
def manage_user(opt):

    handle_authentication(False)

    resume_list = [(f"{n}", getattr(current_user, f"resume{n}_name"),
                    getattr(current_user, f"resume{n}_doc"))
                   for n in range(1, 4)]

    nav = {"opt": opt}

    return render_template('user/manage_user2.html',
                           title='Profil',
                           text=Users.text.manage_user(),
                           resume_list=resume_list,
                           nav=nav)
Exemple #21
0
def update_work_experience():

    # handle authetication problems
    handle_authentication(False)

    form = Users.forms.WorkExperience()
    fields = extract_fields(form)

    if request.method == 'GET':
        # pre fill all fields
        for field in fields:
            k = getattr(form, field)
            k.data = getattr(current_user, field)
    else:
        if form.validate_on_submit():
            # if needed add the comapny and job to relative tables
            if form.company.data not in Company.list_all():
                form.company.data = form.company.data.upper().strip()\
                    .replace("-", " ").replace("  ", " ").replace("  ", " ")
                db.session.add(Company(company=form.company.data))
                db.session.commit()
            if form.job.data not in Job.list_all():
                form.job.data = form.job.data.capitalize().strip()\
                    .replace("-", " ").replace("  ", " ").replace("  ", " ")
                db.session.add(Job(job=form.job.data))
                db.session.commit()
            if form.key_words.data:
                kwords = form.key_words.data
                kwords = kwords.lower().strip()\
                    .replace("-", " ").replace("  ", " ").replace("  ", " ")
                kwords = ", ".join([i.strip() for i in kwords.split(",")])
                form.key_words.data = kwords
            # update User attrs
            for field in fields:
                setattr(current_user, field, getattr(form, field).data)
                db.session.commit()
            return commit_flash_redirect('users.manage_user')
        else:
            flash_all_errors(form)

    return render_template('user/update/update_work_experience.html',
                           title="Experience professionnelle",
                           form=form,
                           fields=fields,
                           company_list=Company.list_all(),
                           job_list=Job.list_all())
Exemple #22
0
def delete_user():

    handle_authentication(False)

    form = Users.forms.Delete()
    fields = extract_fields(form)
    if form.validate_on_submit():
        user_id = current_user.id
        logout_user()
        user = Users.table.query.filter_by(id=user_id).first()
        db.session.delete(user)
        db.session.commit()
        flash("User deleted", "success")
        return redirect(url_for('main.home'))

    return render_template('user/delete_user.html',
                           title="Suppression du compte",
                           fields=fields,
                           text=Users.text.delete_user,
                           form=form)
Exemple #23
0
def login():

    handle_authentication(True)
    form = Users.forms.Login()
    fields = extract_fields(form)

    if Params.DISABLE_LOGIN:
        try:
            logout_user()
        except:
            pass
        return redirect(url_for('main.connection', token="error"))

    if form.validate_on_submit():
        user = Users.table.query.filter_by(email=form.email.data).first()
        if not user:
            flash('Login Unsuccessful. Please check email', 'danger')
            return redirect(url_for('users.login'))

        good_passwd = bcrypt.check_password_hash(user.password,
                                                 form.password.data)

        if not good_passwd:
            flash('Login Unsuccessful. Please check password', 'danger')
            return redirect(url_for('users.login'))
        if user and good_passwd:
            login_user(user, remember=form.remember.data)
            next_page = request.args.get('next')
            flash('You have been logged in!', 'success')

            return redirect(next_page) if next_page else redirect(
                url_for('users.manage_user'))
        else:
            raise AttributeError("something went wrong with login")

    return render_template(
        'user/login_user.html',
        title='Connexion',
        form=form,
        fields=fields,
    )
Exemple #24
0
def update_searched_language(search_id):

    # handle connections problems
    handle_authentication(False)
    search = Search.query.filter_by(id=search_id).first()

    # authetication problem
    if current_user.id != search.user_id:
        flash("sorry this is not your search, you are not allowed", "danger")
        return redirect(url_for("main.edhunt"))

    form = SearchsForms.Languages()
    fields = extract_fields(form)

    if request.method == 'GET':
        # prefill all fields
        form.other_languages.data = search.other_languages
    else:
        if form.validate_on_submit():
            # update user attrs
            if form.other_languages.data:
                langs = form.other_languages.data
                langs = langs.capitalize().strip()\
                    .replace("-", " ").replace("  ", " ").replace("  ", " ")
                langs = ", ".join([i.strip() for i in langs.split(",")])
                form.other_languages.data = langs
            for field in fields:
                d = getattr(form, field).data
                if isinstance(d, list):
                    d = ", ".join(d)
                setattr(search, field, d)
            db.session.commit()
            flash("Search updated", "success")
            return redirect(
                url_for('searchs.manage_search', search_id=search.id))
        else:
            flash_all_errors(form)
    return render_template('search/update/update_searched_language.html',
                           title="Update Languages",
                           form=form,
                           search_id=search.id)
Exemple #25
0
def edhunt():

    # handle connections problems
    handle_authentication(False)

    # for funct, plat in [(current_user.filed_info, "profile filling"),
    #                     (current_user.filed_joboard, "plateform connection")]:
    #     if int(funct()) > 80:
    #         _flash = "success"
    #     elif int(funct()) < 40:
    #         _flash = "danger"
    #     else:
    #         _flash = "warning"
    #     flash(f"Your {plat} is scored to {funct()}%", _flash)

    search_list = Search.query.filter_by(user_id=current_user.id).all()

    opp_list = Opportunity.query.filter_by(user_id=current_user.id).all()

    plate_list = list()
    for p in Plateforms.list_all:
        plate_list.append(
            getattr(Plateforms.tables,
                    p).query.filter_by(user_id=current_user.id).first())

    plate_list = [i for i in plate_list if i]
    [
        setattr(opp, "search_name",
                Search.query.filter_by(id=opp.search_id).first().name)
        for opp in opp_list
    ]
    db.session.commit()

    return render_template('main/edhunt2.html',
                           title="edhunt",
                           search_list=search_list,
                           opp_list=opp_list,
                           plate_list=plate_list)
Exemple #26
0
def register_user():

    if Params.FORCE_QUESTIONNAIRE:
        return redirect(url_for('main.questionnaire_1'))

    if Params.DISABLE_REGISTER:
        try:
            logout_user()
        except:
            pass
        return redirect(url_for('main.connection', token="error"))

    handle_authentication(True)
    form = Users.forms.Register()
    fields = extract_fields(form)
    if form.validate_on_submit():
        # create user
        hashed_password = bcrypt.generate_password_hash(
            form.password.data).decode('utf-8')
        user = Users.table(username=form.username.data,
                           email=form.email.data,
                           password=hashed_password)
        db.session.add(user)
        db.session.commit()

        # CREATE PLATEFORMS
        for p in Plateforms.list_all:
            Plate = getattr(Plateforms.tables, p)
            db.session.add(Plate(user_id=user.id))
        db.session.commit()
        flash('Your account has been created! You are now able to log in',
              'success')
        return redirect(url_for('users.login'))

    return render_template('user/register_user.html',
                           title='Inscription',
                           fields=fields,
                           form=form)
Exemple #27
0
def visualize_searchs(src):
    # handle connections problems
    handle_authentication(False)
    search_list = Search.query.filter_by(user_id=current_user.id).all()
    # opp_list = Opportunity.query.filter_by(search_id=int(search_id)).all()

    # search_id_next = search_id_past = None
    # search_s = Search.query.filter_by(user_id=current_user.id).all()
    # # nav
    # idx = search_s.index(search)
    # if idx > 0 and (len(search_s) > 1):
    #     search_id_past = search_s[idx - 1].id
    # if (not (idx + 1 == len(search_s))):
    #     search_id_next = search_s[idx + 1].id
    # nav = {"search_id_next": search_id_next,
    #        "search_id_past": search_id_past}

    nav = {'src': src}

    return render_template('search/visualize_searchs.html',
                           title="Recherches",
                           search_list=search_list,
                           nav=nav)
Exemple #28
0
def delete_search(search_id):

    # handle connections problems
    handle_authentication(False)
    search = Search.query.filter_by(id=search_id).first()

    # authetication problem
    if current_user.id != search.user_id:
        flash("sorry this is not your search, you are not allowed", "danger")
        return redirect(url_for("main.edhunt"))

    form = SearchsForms.Delete()

    if form.validate_on_submit():
        db.session.delete(search)
        db.session.commit()
        flash("Search deleted", "success")
        return redirect(url_for('main.edhunt'))

    return render_template('search/delete_search.html',
                           title="Supprimer une search",
                           form=form,
                           search_id=search.id)
Exemple #29
0
def manage_plateforms(opt):

    handle_authentication(False)

    plateform_list = Plateforms.list_all
    plateform_list = [
        (plateform,
         getattr(Plateforms.tables,
                 plateform).query.filter_by(user_id=current_user.id).first(),
         url_for('plateforms.update_plateform', plateform=plateform),
         url_for(f'plateforms.test_plateform', plateform=plateform))
        for plateform in plateform_list
    ]

    # plateform_list = [(i, j, k, l) for i, j, k, l in plateform_list]

    nav = {"opt": opt}

    return render_template('plateform/manage_plateforms2.html',
                           title='Plateformes',
                           text=Plateforms.text.manage_plateforms(),
                           plateform_list=plateform_list,
                           nav=nav)
Exemple #30
0
def delete_opportunity(opp_id):

    # handle connections problems
    handle_authentication(False)
    opp = Opportunity.query.filter_by(id=opp_id).first()

    # authetication problem
    if current_user.id != opp.user_id:
        flash("sorry this is not your opp, you are not allowed", "danger")
        return redirect(url_for("main.edhunt"))

    form = OpportunitiesForms.Delete()

    if form.validate_on_submit():
        db.session.delete(opp)
        db.session.commit()
        flash("Opportunité supprimée", "success")
        return redirect(url_for('main.edhunt'))

    return render_template('opportunity/delete_opportunity.html',
                           title="Delete search",
                           form=form,
                           opp_id=opp.id)