Ejemplo n.º 1
0
def pdf_contract(id,start_date,end_date):
    c = Contract.query.get(id)
    if c == None:
        flash('contract not found')
        abort(404)

    if g.user.role == ROLE_LANDLORD:
        if g.user.property_id != c.room.property_id:
            abort(401)
    if g.user.role == ROLE_USER:
        if g.user != c.user:
            abort(401)

    start = datetime.strptime(start_date, "%Y-%m-%d")
    end = datetime.strptime(end_date, "%Y-%m-%d")

    values = get_usage_per_month(datastreams=c.room.datastreams,start=start,end=end,property=c.room.property)[0]

    pdf = create_pdf(render_template('pdf_contract.html',contract = c,user=c.user,property=c.room.property,room=c.room,month=values))
    return Response(pdf, mimetype='application/pdf')
Ejemplo n.º 2
0
def contract_detail(id):
    c = Contract.query.get(id)
    if c == None:
        flash('contract not found')
        abort(404)

    if g.user.role == ROLE_LANDLORD:
        if g.user.property_id != c.room.property_id:
            abort(401)
    if g.user.role == ROLE_USER:
        if g.user != c.user:
            abort(401)

    monthly_values = get_usage_per_month(datastreams=c.room.datastreams,start=c.start_date,end=c.end_date,property=c.room.property)

    return render_template('contract_detail.html',
        contract = c,
        user = c.user,
        property = c.room.property,
        room = c.room,
        months = monthly_values
        )