예제 #1
0
def tasks_index(project_id):
    return render_template(
        "tasks/list.html",
        tasks=Task.find_tasks_in_project(project_id),
        workdone=Project.work_done_in_project(project_id),
        workestimated=Project.work_estimated_in_project(project_id),
        project_id=project_id,
        form=TaskForm(),
        userworkdone=Project.work_done_in_project_by_user(project_id),
        userworkestimate=Project.work_estimated_in_project_by_user(project_id))
예제 #2
0
def projects_index():
    ps = Project.query.all()

    for project in ps:
        project.customer_name = Customer.query.filter_by(
            id=project.customer_id).first().name
        project.budget = float(str(project.budget))
        project.costs = Project.get_costs(project.id)
        project.revenues = Project.get_revenues(project.id)

    return render_template("projects/list.html", projects=ps)
예제 #3
0
def create_project():
    form = ProjectForm(request.form)

    if not form.validate():
        return render_template("projects/create.html", form = form)

    t = Project(form.name.data)
    t.user_id = current_user.id

    db.session().add(t)
    db.session().commit()

    return redirect(url_for("projects_index"))
예제 #4
0
def projects_create():
    form = ProjectForm(request.form)

    if not form.validate():
        return render_template("projects/new.html", form=form)

    p = Project(form.name.data, form.budget.data)
    p.customer_id = form.customer.data.id

    db.session().add(p)
    db.session().commit()

    return redirect(url_for("projects_index"))
예제 #5
0
def projects_create():
    form = ProjectForm(request.form)
    if not form.validate():
        return render_template("projects/new.html", form=form)
    new_project = Project(form.name.data)
    new_lead = Lead(new_project.id, current_user.id)
    new_project.leads.append(new_lead)
    new_project.account_id = current_user.id
    current_user.projects.append(new_project)
    db.session().add(new_project)
    db.session().add(current_user)
    db.session().add(new_lead)
    db.session().commit()
    return redirect(url_for("projects_index"))
예제 #6
0
def projects_create():
    form = ProjectForm(request.form)

    if not form.validate():
        return render_template("projects/new.html", form = form)

    p = Project(form.name.data)
    p.done = form.done.data
    p.account_id = current_user.id

    db.session().add(p)
    db.session().commit()
  
    return redirect(url_for("projects_index"))
예제 #7
0
def project(project_id):
    p = Project.query.filter_by(id=project_id).first()

    p.customer_name = Customer.query.filter_by(id=p.customer_id).first().name

    p.budget = float(str(p.budget))
    p.costs = Project.get_costs(project_id)
    p.revenues = Project.get_revenues(project_id)

    cleared_tls = TimeLog.find_cleared_timelogs_by_project(project_id)
    uncleared_tls = TimeLog.find_uncleared_timelogs_by_project(project_id)

    return render_template("projects/view.html",
                           project=p,
                           cleared_timelogs=cleared_tls,
                           uncleared_timelogs=uncleared_tls)
예제 #8
0
def projects_create():
    form = ProjectForm(request.form)

    if not form.validate():
        return render_template("projects/project_form.html", form = form)

    project = Project(
        form.name.data,
        form.start_date.data,
        form.end_date.data
    )

    project.owner_id = current_user.id
    db.session.add(project)
    db.session.commit()

    return redirect(url_for("projects_my"))
예제 #9
0
def create_project():
    form = ProjectForm(request.form)

    if not form.validate():
        return render_template("projects/create.html", form = form)

    p = Project(form.name.data)
    p.user_id = current_user.id
    p.active = True

    db.session().add(p)
    db.session().commit()

    return render_template("projects/tasks.html", form = ProjectForm(),
    tasks = Task.query.filter_by(user_id = current_user.id).filter(Task.project_id == None).filter(Task.archived == False),
    count = Task.query.filter_by(user_id = current_user.id).filter(Task.project_id == None).filter(Task.archived == False).count(),
    project_id = p.id, project_name = p.name)
예제 #10
0
def projects_hourly_report(project_id):
    project = Project.query.get(project_id)
    if current_user.id != project.owner_id:
        return redirect(url_for('projects_index'))

    return render_template(
        "projects/hourly_report.html",
        project=project,
        project_workloads=Project.project_workloads(project_id))
예제 #11
0
def index():
    projects = Project.find_projects_user_is_assigned_to(current_user.id)

    for project in projects:
        project.customer_name = Customer.query.filter_by(
            id=project.customer_id).first().name
        project.budget = float(str(project.budget))
        project.costs = Project.get_costs(project.id)
        project.revenues = Project.get_revenues(project.id)

    timelogs = TimeLog.query.filter_by(account_id=current_user.id).order_by(
        TimeLog.date_created.desc()).limit(5).all()

    for timelog in timelogs:
        timelog.customer_name = Customer.query.filter_by(
            id=Project.query.filter_by(
                id=timelog.project_id).first().customer_id).first().name
        timelog.project_name = Project.query.filter_by(
            id=timelog.project_id).first().name
        timelog.work_type_name = WorkType.query.filter_by(
            id=timelog.work_type_id).first().name

    return render_template("index.html", projects=projects, timelogs=timelogs)
예제 #12
0
def projects_create():
    form = ProjectForm(request.form)

    if not form.validate():
        return render_template("projects/new.html", form=form)

    new_project = Project(form.name.data, form.deadline.data, current_user.id)

    db.session().add(new_project)
    db.session().commit()

    current_user.add_project(new_project.id)

    return redirect(url_for("projects_list"))
예제 #13
0
def edit_project(project_id):
    if request.method == "GET":
        return render_template("projects/edit.html", form = ProjectForm(),
        tasks = Task.query.filter_by(user_id = current_user.id).filter(Task.project_id == None).filter(Task.archived == False),
        count = Task.query.filter_by(user_id = current_user.id).filter(Task.project_id == None).filter(Task.archived == False).count(),
        project = Project.query.get(project_id),
        project_tasks = Project.project_tasks(project_id),
        tasks_count = len(Project.project_tasks(project_id)))

    form = ProjectForm(request.form)

    if not form.validate():
        return render_template("projects/edit.html", form = form,
        tasks = Task.query.filter_by(user_id = current_user.id).filter(Task.project_id == None).filter(Task.archived == False),
        count = Task.query.filter_by(user_id = current_user.id).filter(Task.project_id == None).filter(Task.archived == False).count(),
        project = Project.query.get(project_id),
        project_tasks = Project.project_tasks(project_id),
        tasks_count = len(Project.project_tasks(project_id)))

    p = Project.query.get(project_id) 

    p.name = form.name.data
    db.session().commit()

    project_task_ids = request.form.getlist('remove_check')
    for p_task in project_task_ids:
        t = Task.query.get(p_task)
        t.project_id = None
        db.session().commit()

    task_ids = request.form.getlist('add_check')
    for task in task_ids:
        t = Task.query.get(task)
        t.project_id = p.id
        db.session().commit()

    return redirect(url_for("open_project", project_id=p.id))
예제 #14
0
파일: views.py 프로젝트: ounai/Projectus
def index():
    if current_user.is_authenticated:
        today_date = date.today()

        projects_due_today = Project.query.filter_by(creator=current_user.id,
                                                     complete=False,
                                                     deadline=today_date)
        projects_with_tasks_due_today = Project.find_projects_by_user_with_tasks_due_on(
            current_user.id, today_date)

        return render_template(
            "index.html",
            projects_due_today=projects_due_today,
            projects_with_tasks_due_today=projects_with_tasks_due_today)
    else:
        return render_template("index.html")
예제 #15
0
def accounts_get():
    skill_name = request.args.get("skill")

    if skill_name:
        accounts = Account.query.join(Account.skills)\
            .filter(Skill.name.like(skill_name))
    else:
        accounts = Account.query.all()

    projects = Project.find_project_names_by_owner(current_user.id)

    return render_template("accounts/accounts.html",
        accounts = accounts,
        projects = projects,
        search_term = skill_name
    )
예제 #16
0
def projects_create():
    form = ProjectForm(request.form)

    if not form.validate():
        return render_template('projects/new.html', form=form)

    if not form.validate_dates():
        form.end_date.errors.append("Päättyy ennen alkamista")
        return render_template('projects/new.html', form=form)

    new_project = Project(form.name.data, form.description.data,
                          form.start_date.data, form.end_date.data,
                          form.running.data, current_user.id)

    db.session().add(new_project)
    db.session().commit()

    return redirect(url_for('projects_index'))
예제 #17
0
def tasks_create():
    form = TaskForm(request.form)
    project_id = request.args.get('project_id')

    if not form.validate():
        return render_template(
            "tasks/list.html",
            tasks=Task.find_tasks_in_project(project_id),
            workdone=Project.work_done_in_project(project_id),
            project_id=project_id,
            form=form)

    t = Task(form.tasktype.data)
    t.description = form.description.data
    t.time = form.time.data
    t.taskstatus = form.taskstatus.data
    t.project_id = project_id
    t.account_id = current_user.id

    db.session().add(t)
    db.session().commit()

    return redirect(url_for('tasks_index', project_id=project_id))
예제 #18
0
def open_project(project_id):
    return render_template("projects/project.html", project = Project.query.get(project_id),
    tasks = Project.project_tasks(project_id))
예제 #19
0
def projects_my():
    return render_template("projects/projects.html",
        projects = Project.find_projects_by_owner(current_user.id)
    )
예제 #20
0
def project_choices():
    return Project.find_projects_user_is_assigned_to(current_user.id)
예제 #21
0
def projects_index():
    return render_template("projects/list.html", projects = Project.query.all(), work_done_in_projects = Project.projects_list_workdone())