Exemple #1
0
def userJobsAll():
    """ Feladatok, kapcsolatok lekérése a charthoz / User nézet
    
    Returns:
        [json] -- Feladatok és linkek serializálva
    """
    jobsAll = User.getProjectJobListCategories(current_user.id)
    jobs = jobsAll['pendingJobs']
    if jobsAll['activeJob'] is not None:
        jobs.append(jobsAll['activeJob'])

    links = ProjectJobLink.query.all()

    return jsonify(data=[i.serialize for i in jobs],
                   links=[j.serialize for j in links])
Exemple #2
0
def userData(userId):
    """ Felhasználó adatlap megtekintése
    
    Arguments:
        userId {int} -- Felhasználó azonosító
    
    Returns:
        response
    """    
    user = User.query.get_or_404(userId)    
    jobs = User.getProjectJobListCategories(userId)
    data = {
        'user' : user,
        'projectCount' : len(user.projects),
        'pendingJobCount' : len(jobs['pendingJobs']),
        'doneJobCount' : len(jobs['doneJobs']),
        'activeLink' : 'users',
    }
    return render_template('User/userData.html', **data)
Exemple #3
0
def account():
    """ Adataim menüpont
    
    Returns:
        response
    """
    form = ModifyAccountBaseDataForm()
    user = User.query.get_or_404(current_user.id)
    jobs = User.getProjectJobListCategories(current_user.id)
    data = {
        'user' : user,       
        'projectCount' : len(user.projects),
        'pendingJobCount' : len(jobs['pendingJobs']),
        'doneJobCount' : len(jobs['doneJobs']),
        'activeLink' : 'account',
    }

    if form.validate_on_submit():
        email = form.email.data
        userName =  remove_tags(form.userName.data)
        oldUser = User.query.filter(
            or_(User.userName == userName, User.email == email), 
            and_(User.id != current_user.id)
        ).first()
        if oldUser is None or oldUser.id == current_user.id:
            user.userName = userName
            user.email = email
            db.session.commit()
            flash(f'Sikeres módosítás', 'success')
            return redirect(url_for('account'))
        else:
            flash(f'Adott felhasználónév vagy email foglalt!', 'danger')
            data['form'] = form
            return render_template('User/account.html', **data)
    else:
        if not form.is_submitted():
            form.userName.default = user.userName
            form.email.default = user.email
            form.process()
    
        data['form'] = form
        return render_template('User/account.html', **data)
Exemple #4
0
def index():
    """ Dashboard megjelenítése
    
    Returns:
        response
    """
    jobs = User.getProjectJobListCategories(current_user.id)
    pendingJobs = []
    for job in jobs['pendingJobs']:
        job.hasSubJob = ProjectJob.hasSubJob(job)
        job.canCreateSubJob = ProjectJob.canCreateSubJob(job, current_user.id)
        pendingJobs.append(job)

    data = {
        'activeLink' : 'home',
        'activeJob' : jobs['activeJob'],
        'pendingJobs' : pendingJobs,
        'doneJobs' : jobs['doneJobs'],
        'form' : AddProjectWorkTimeForm(),
    }
    return render_template('Index/home.html', **data)