Beispiel #1
0
def user_reset_password():
    form = PasswordResetForm()
    if request.method == 'POST' and form.validate():
        user = User.objects(id=current_user.id).first()
        user.reset_password(form.password.data).save()
        flash('Account successfully restored!')
        return redirect(url_for('dashboard'))
    return render_template('user_reset_password.html',
                           title='Forgot Password',
                           reset_password_form=form)
def password_reset():
    """
    Route for url: server/password_reset/
    """
    form = PasswordResetForm()
    if request.method == 'GET':
        return render_template('password_reset.html', form = form)

    if request.method == 'POST':
        if form.validate():
            send_password_reset_email(form.email.data)
            return render_template('password_reset_confirmation.html')
        flash('Could not find that email. Please try again.')
        return render_template('password_reset.html', form = form)
Beispiel #3
0
def dashboard():
    title = "Dashboard"

    #__________[ modal validation ]
    reset_form = PasswordResetForm()
    if request.method == 'POST' and reset_form.validate():
        user = User.objects(id=current_user.id).first()
        user.reset_password(form.password.data).save()
        flash('Account successfully restored')
        return redirect(url_for('dashboard'))

    if request.method == 'POST':  # and request.form.get('delete') == 'delete':

        query_values = request.form.get("delete").split(",")
        query_values = [i for i in query_values if i]
        app.logger.debug(query_values)
        name, project, seniority, client, city, age, date, sal, x = query_values

        table = ScheduleInterview.objects(name=str(name),
                                          project=str(project),
                                          seniority=str(seniority),
                                          client=str(client),
                                          city=str(city),
                                          age=str(age),
                                          date=str(date),
                                          salary=str(sal)).first()
        app.logger.debug(table)
        table.delete()

        #app.logger.debug(request.data)
        #app.logger.debug("delete")
        app.logger.debug(query_values)

    #__________________[ vars ]
    schedule_interviews = list(ScheduleInterview.objects().aggregate(
        {"$match": {
            "username": current_user.email
        }},
        {"$group": {
            "_id": {
                "status": "$status"
            },
            "count": {
                "$sum": 1
            }
        }},
    ))
    #app.logger.debug("schedule_interviews: {}".format(schedule_interviews))

    user = User.objects(id=current_user.id).first()
    user_data = {
        "email":
        current_user.email,
        "license":
        current_user.profile,
        "sucessfull":
        sum([
            i["count"] for i in schedule_interviews
            if "done" in i["_id"]["status"]
        ]),
        "pending":
        sum([
            i["count"] for i in schedule_interviews
            if "pending" in i["_id"]["status"]
        ]),
        "overall":
        sum([i["count"] for i in schedule_interviews]),
        "week":
        0,
        "month":
        0,
        "trial":
        user.trial_percent(),
        "avatar":
        user.avatar(133)
    }
    #app.logger.debug("user_data: {}".format(user_data))

    #__________________[ col1_data ]
    #pie chart
    pie_chart = list(ScheduleInterview.objects().aggregate(
        {"$match": {
            "username": current_user.email
        }},
        {"$group": {
            "_id": {
                "field": "$field"
            },
            "count": {
                "$sum": 1
            }
        }},
    ))
    #app.logger.debug("pie_chart: {}".format(pie_chart))

    pie_chart_data = []
    for i in pie_chart:
        pie_chart_data.append({
            "label": i["_id"]["field"],
            "value": i["count"]
        })

    #app.logger.debug('pie_chart_data: {}'.format(pie_chart_data))

    #_________________[ col2_data ]
    table_pending_interviews = ScheduleInterview.objects(
        username=current_user.email, status="pending")

    return render_template(
        "dashboard.html",
        title=title,
        user_data=user_data,
        table_pending_interviews=table_pending_interviews,
        pie_chart_data=pie_chart_data,
        reset_password_form=reset_form,
    )