def create_workhistory():
    user = load_user(current_user.get_id())

    if not user:
        return abort(401, description="Unauthorised to view this page")

    form = CreateWorkHistory()
    print(form.job_title)
    print(form.city)
    print(form.validate_on_submit())
    if form.validate_on_submit():
        new_workhistory = WorkHistory()
        new_workhistory.username = user.username
        new_workhistory.job_title = form.job_title.data
        new_workhistory.company = form.company.data
        new_workhistory.city = form.city.data
        new_workhistory.country = form.country.data
        new_workhistory.date_start = form.date_start.data
        new_workhistory.date_end = form.date_end.data

        db.session.add(new_workhistory)
        db.session.commit()
        flash("workhistory added!")
        return redirect(url_for("web_workhistory.show_workhistories"))

    return render_template("create_workhistory.html", form=form)
def update_workhistory(id):
    user = load_user(current_user.get_id())
    workhistory = WorkHistory.query.filter_by(id=id, username=user.username)

    if workhistory.count() != 1:
        flash("Can't find workhistory")
        return redirect(url_for("web_workhistory.show_workhistories"))

    form = UpdateWorkHistory(obj=workhistory.first())
    if form.validate_on_submit():
        data = {
            "job_title": form.job_title.data,
            "company": form.company.data,
            "city": form.city.data,
            "country": form.country.data,
            "date_start": form.date_start.data,
            "date_end": form.date_end.data,
        }
        fields = work_history_schema.load(data, partial=True)
        workhistory.update(fields)
        db.session.commit()
        flash("workhistory updated!")
        return redirect(url_for("web_workhistory.show_workhistories"))

    return render_template("update_workhistory.html", form=form, id=id)
示例#3
0
def delete_profile(id):
    form = DeleteButton()
    if form.submit.data:
        user = load_user(current_user.get_id())
        profile = Profile.query.filter_by(
            profile_id=id, user_id=user.user_id).first()

        if not profile:
            flash("No profile found")
            return redirect(url_for("web_profiles.show_profiles"))

        while len(profile.unrecommend) > 0:
            for item in profile.unrecommend:
                profile.unrecommend.remove(item)
            db.session.commit()

        groups = GroupMembers.query.filter_by(profile_id=profile.profile_id)
        for group in groups:
            db.session.delete(group)
            db.session.commit()

        db.session.delete(profile)
        db.session.commit()

        flash("Profile deleted")
        return redirect(url_for("web_profiles.show_profiles"))
示例#4
0
def show_profiles():
    user = load_user(current_user.get_id())
    profiles = Profile.query.filter_by(
        user_id=user.user_id).order_by(Profile.profile_id)

    form = DeleteButton()
    return render_template("profiles.html", profiles=profiles, form=form)
def show_workhistories():
    user = load_user(current_user.get_id())
    workhistories = WorkHistory.query.filter_by(username=user.username)

    form = DeleteButton()
    return render_template("workhistory.html",
                           workhistories=workhistories,
                           form=form)
def show_studyhistories():
    user = load_user(current_user.get_id())
    studyhistories = StudyHistory.query.filter_by(username=user.username)

    form = DeleteButton()
    return render_template("studyhistory.html",
                           studyhistories=studyhistories,
                           form=form)
def delete_workhistory(id):
    form = DeleteButton()
    if form.submit.data:
        user = load_user(current_user.get_id())
        workhistory = WorkHistory.query.filter_by(id=id).first()

        if not workhistory:
            flash("No workhistory found")
            return redirect(url_for("web_workhistory.show_workhistories"))

        db.session.delete(workhistory)
        db.session.commit()

        flash("workhistory deleted")
        return redirect(url_for("web_workhistory.show_workhistories"))
def view_workhistory(id):
    user = load_user(current_user.get_id())

    workhistory = WorkHistory.query.filter_by(id=id).first()

    if not workhistory:
        flash("workhistory not found")
        return redirect(
            url_for("web_workhistory.view_workhistory", id=workhistory.id))

    form1 = UnrecommendButton()
    form2 = RemoveButton()

    return render_template("view_workhistory.html",
                           workhistory=workhistory,
                           form1=form1,
                           form2=form2)
示例#9
0
def create_profile():
    user = load_user(current_user.get_id())

    if not user:
        return abort(401, description="Unauthorised to view this page")

    form = CreateProfile()
    if form.validate_on_submit():
        new_profile = Profile(
            name=form.name.data,
            restrictions=form.restriction.data
        )
        user.profiles.append(new_profile)
        db.session.commit()
        flash("Profile added!")
        return redirect(url_for("web_profiles.show_profiles"))

    return render_template("create_profile.html", form=form)
示例#10
0
def view_profile(id):
    user = load_user(current_user.get_id())

    profile = Profile.query.filter_by(
        profile_id=id, user_id=user.user_id).first()

    if not profile:
        flash("Profile not found")
        return redirect(
            url_for("web_profiles.view_profile", id=profile.profile_id))

    contents = Content.query.all()

    form1 = UnrecommendButton()
    form2 = RemoveButton()

    return render_template(
        "view_profile.html", contents=contents,
        profile=profile, form1=form1, form2=form2)
示例#11
0
def update_profile(id):
    user = load_user(current_user.get_id())
    profile = Profile.query.filter_by(profile_id=id, user_id=user.user_id)

    if profile.count() != 1:
        flash("Can't find profile")
        return redirect(url_for("web_profiles.show_profiles"))

    form = UpdateProfile(obj=profile.first())
    if form.validate_on_submit():
        data = {
            "name": form.name.data,
            "restrictions": form.restriction.data
        }
        fields = profile_schema.load(data, partial=True)
        profile.update(fields)
        db.session.commit()
        flash("Profile updated!")
        return redirect(url_for("web_profiles.show_profiles"))

    return render_template("update_profile.html", form=form, id=id)
def create_studyhistory():
    user = load_user(current_user.get_id())

    if not user:
        return abort(401, description="Unauthorised to view this page")

    form = CreateStudyHistory()

    if form.validate_on_submit():
        new_studyhistory = StudyHistory()
        new_studyhistory.username = user.username
        new_studyhistory.qualification_title = form.qualification_title.data
        new_studyhistory.institution = form.institution.data
        new_studyhistory.city = form.city.data
        new_studyhistory.country = form.country.data
        new_studyhistory.date_start = form.date_start.data
        new_studyhistory.date_end = form.date_end.data

        db.session.add(new_studyhistory)
        db.session.commit()
        flash("studyhistory added!")
        return redirect(url_for("web_studyhistory.show_studyhistories"))

    return render_template("create_studyhistory.html", form=form)