Ejemplo n.º 1
0
def tenancy():
    tenancies = Tenancy.query()
    return render_template(
        'tenancy/admin/tenancy.html',
        tenancy_active='active',
        tenancies=tenancies
    )
Ejemplo n.º 2
0
def tenancy_add():
    form = TenancyForm()
    url = blobstore.create_upload_url(
        url_for('tenancy.admin.add')
    )
    if request.method == 'POST':
        upload_files = get_uploads(request, 'attach_file')
        file_ = None
        if len(upload_files):
            blob_info = upload_files[0]
        else:
            blob_info = None

        if form.validate_on_submit():
            if blob_info:
                blob_info = blobstore.BlobInfo.get(blob_info.key())
                if blob_info.size:
                    file_ = File.create(
                        blob_key=blob_info.key(),
                        title=form.name.data,
                        description=form.description.data,
                        is_public=form.is_public.data,
                        filename=os.path.basename(blob_info.filename.replace('\\', '/')),
                        size=blob_info.size,
                        content_type=blob_info.content_type)
                    file_.put()
                else:
                    blob_info.delete()

        tenancy = Tenancy()
        form.populate_obj(tenancy)
        if file_:
            tenancy.file = file_.key
        tenancy.put()
        return redirect(url_for('tenancy.admin.tenancy'))

    tenancies = Tenancy.query()
    return render_template(
        'tenancy/admin/add.html',
        add_active='active',
        form=form,
        tenancies=tenancies,
        url=url
    )
Ejemplo n.º 3
0
def tenancy_list():
    regions = Tenancy.query(Tenancy.is_public == True)
    employees = Employee.query(Employee.is_tenancy == True)
    return render_template(
        'tenancy/tenancy_regions.html',
        html_class='services_page',
        active_element="tenancy_regions",
        regions=regions,
        employees=employees
    )
Ejemplo n.º 4
0
def tenancy_edit(key_id):
    tenancy = Tenancy.retrieve_by_id(key_id)
    if not tenancy:
        return redirect(url_for('tenancy.admin.tenancy'))
    if request.method == 'POST' and 'delete_tenancy' in request.form:
        tenancy.key.delete()
        return redirect(url_for('tenancy.admin.tenancy'))
    url = blobstore.create_upload_url(
        url_for('tenancy.admin.edit', key_id=key_id)
    )
    form = TenancyForm(obj=tenancy)
    if request.method == 'POST':
        upload_files = get_uploads(request, 'attach_file')
        file_ = None
        if len(upload_files):
            blob_info = upload_files[0]
        else:
            blob_info = None

        if form.validate_on_submit():
            if blob_info:
                blob_info = blobstore.BlobInfo.get(blob_info.key())
                if blob_info.size:
                    file_ = File.create(
                        blob_key=blob_info.key(),
                        title=form.name.data,
                        description=form.description.data,
                        is_public=form.is_public.data,
                        filename=os.path.basename(blob_info.filename.replace('\\', '/')),
                        size=blob_info.size,
                        content_type=blob_info.content_type)
                    file_.put()
                else:
                    blob_info.delete()

        form.populate_obj(tenancy)
        if file_:
            if tenancy.file:
                tenancy.file.delete()
            tenancy.file = file_.key
        tenancy.put()
        return redirect(url_for('tenancy.admin.tenancy'))

    return render_template(
        'tenancy/admin/tenancy_edit.html',
        tenancy=tenancy,
        form=form,
        url=url
    )
Ejemplo n.º 5
0
def index():
    investment_info = InvestmentInfo.get_master_db()
    investments = Investment.query(Investment.is_public == True).order(Investment.order_id)
    tenancy_info = TenancyInfo.get_master_db()
    tenancies = Tenancy.query(Tenancy.is_public == True).order(Tenancy.order_id)
    employees = Employee.query(Employee.is_investment == True)
    return render_template(
        'investment/index.html',
        html_class='services_page',
        investment_info=investment_info,
        investments=investments,
        tenancy_info=tenancy_info,
        tenancies=tenancies,
        employees=employees,
        active_element='investment'
    )