Beispiel #1
0
def view_bids():
    company = get_company_information()
    if company:
        tenders = db.engine.execute(f"SELECT * FROM bidTender JOIN Bid ON bidTender.bid_id=Bid.id JOIN Tenders "
                                    f"ON bidTender.tender_id=Tenders.id WHERE company={company.id}")
        return render_template('buyer/bids.html', company_name=company.company_name, tenders=tenders)
    return render_template('buyer/bids.html')
Beispiel #2
0
def get_report():
    tender_dict = dict()
    company = get_company_information()
    if company:
        return render_template('buyer/report.html', company_name=company.company_name, company_id=company.id)
    else:
        return render_template('buyer/report.html')
Beispiel #3
0
def load_tender(tender_id):
    form = UpdateTenderForm()
    firm = get_company_information()
    company = get_company_id()
    tenders = Tenders.query.filter_by(company=company, is_delete=False, status="open") \
        .order_by(Tenders.date_published, Tenders.date_closed).all()
    editable_tenders = Tenders.query.filter_by(id=tender_id).first()
    tender = Tenders.query.get(tender_id)
    if request.method == "GET":
        return render_template('buyer/edit_tender.html', editable_tenders=editable_tenders, form=form,
                               company_name=firm.company_name, tenders=tenders)

    else:
        if form.validate_on_submit():
            tender.entity_name = form.entity_name.data
            tender.entity_type = form.entity_type.data
            tender.title = form.title.data
            tender.status = form.status.data
            tender.date_published = form.date_published.data
            tender.date_closed = form.date_closed.data
            tender.tender_document = save_tender_document(form.tender_document.data, "tender")
            db.session.commit()
            return redirect(url_for('edit_tender'))
    return render_template('buyer/edit_tender.html', editable_tenders=editable_tenders, form=form,
                           company_name=firm.company_name, tenders=tenders)
Beispiel #4
0
def my_bids():
    company = get_company_information()
    if company:
        bids = db.engine.execute(
            f"SELECT * FROM bidTender JOIN Bid ON bidTender.bid_id=Bid.id JOIN Tenders "
            f"On bidTender.tender_id=Tenders.id WHERE bid_poster={company.id}")
        return render_template('supplier/myBids.html', bids=bids)
    return render_template('supplier/myBids.html')
Beispiel #5
0
def bidder_info(bidder_id):
    bidder = Company.query.get(1)
    company = get_company_information()
    if company:
        tenders = db.engine.execute(f"SELECT * FROM bidTender JOIN Bid ON bidTender.bid_id=Bid.id JOIN Tenders "
                                    f"ON bidTender.tender_id=Tenders.id WHERE company={company.id}")
        return render_template('buyer/bids.html', company_name=company.company_name, tenders=tenders, bidder=bidder)

    return render_template('buyer/bids.html')
Beispiel #6
0
def edit_tender():
    firm = get_company_information()
    form = TenderForm()
    company = get_company_id()
    tenders = Tenders.query.filter_by(company=company, is_delete=False, status="open") \
        .order_by(Tenders.date_published, Tenders.date_closed).all()
    if company:
        return render_template('buyer/edit_tender.html', tenders=tenders, form=form, company_name=firm.company_name)
    return render_template('buyer/edit_tender.html', tenders=tenders, form=form)
Beispiel #7
0
def supplier_home():
    page = request.args.get("page", 1, type=int)
    tenders = Tenders.query.filter_by(is_delete=False,
                                      status="open").paginate(page=page,
                                                              per_page=10)
    company = get_company_information()
    if company:
        return render_template('supplier/home.html',
                               tenders=tenders,
                               company_name=company.company_name)
    return render_template('supplier/home.html', tenders=tenders)
Beispiel #8
0
def delete_tender(tender_id):
    firm = get_company_information()
    tender = Tenders.query.get(tender_id)
    form = TenderForm()
    company = get_company_id()
    tenders = Tenders.query.filter_by(company=company, is_delete=False, status="open") \
        .order_by(Tenders.date_published, Tenders.date_closed).all()
    if tender:
        if request.method == "GET":
            tender.is_delete = 1
            db.session.commit()
            return redirect(url_for('edit_tender'))
    return render_template('buyer/edit_tender.html', tenders=tenders, form=form, company_name=firm.company_name)
Beispiel #9
0
def update_company_information():
    form = UpdateCompanyForm()
    company = get_company_information()
    if request.method == "GET":
        return render_template("errors/404.html")
    else:
        if form.validate_on_submit():
            company.company_name = form.company_name.data
            company.company_type = form.company_type.data
            company.phone_number = form.phone_number.data
            company.address = form.address.data
            db.session.commit()
            flash("your information was updated successfully", "success")
            return redirect(url_for('company_information'))
    return render_template('company_info.html',
                           company=company,
                           update_form=form)
Beispiel #10
0
def tender_document(tender_id):
    form = UploadBidForm()
    company = get_company_information()
    tender = Tenders.query.get(tender_id)
    closing_date = tender.date_closed
    today = datetime.today()
    if request.method == "GET":
        if company:
            return render_template('supplier/tender_document.html',
                                   form=form,
                                   tender=tender,
                                   company_name=company.company_name)
        else:
            render_template('supplier/tender_document.html',
                            form=form,
                            tender=tender)
    else:
        if form.validate_on_submit():
            if company:
                if today < closing_date:
                    bid_document = save_tender_document(
                        form.bid_document.data, "bid")
                    bid = Bid(bid_document=bid_document, bid_poster=company.id)
                    db.session.add(bid)
                    db.session.commit()
                    bid.tenders.append(tender)
                    db.session.commit()
                    return redirect(url_for('supplier_home'))
                else:
                    flash("sorry!!!!!!!! The tender has already been closed. ",
                          "warning")
                    return render_template('supplier/tender_document.html',
                                           form=form,
                                           tender=tender)
            else:
                flash(
                    "you have to register as company before you place any bid. ",
                    "warning")
                return render_template('supplier/tender_document.html',
                                       form=form,
                                       tender=tender)
    return render_template('supplier/tender_document.html',
                           form=form,
                           tender=tender)
Beispiel #11
0
def company_information():
    form = CompanyForm()
    update_form = UpdateCompanyForm()
    company = get_company_information()
    if request.method == "GET":
        if company:
            update_form.company_name.data = company.company_name
            update_form.company_type.data = company.company_type
            update_form.phone_number.data = company.phone_number
            update_form.address.data = company.address
            return render_template('company_info.html',
                                   company=company,
                                   update_form=update_form)
        else:
            return render_template('company_info.html', form=form)
    else:
        if form.validate_on_submit():
            company_name = form.company_name.data
            company_type = form.company_type.data
            phone = form.phone_number.data
            address = form.address.data

            check_company = check_duplicates(Company, company_name)

            if check_company:
                company = Company(company_name=company_name,
                                  company_type=company_type,
                                  phone_number=phone,
                                  address=address,
                                  user=current_user.id)
                db.session.add(company)
                db.session.commit()
                flash(
                    f"welcome {company_name}. we are glad to have you here. ")
                return redirect(url_for('company_information'))
    return render_template('company_info.html',
                           form=form,
                           company_name=company.company_name)
Beispiel #12
0
def publish_tender():
    form = TenderForm()
    firm = get_company_information()
    if request.method == "GET":
        if firm:
            return render_template('buyer/tenders.html', form=form, company_name=firm.company_name)
        else:
            return render_template('buyer/tenders.html', form=form)
    else:
        if form.validate_on_submit():
            entity_name = form.entity_name.data
            entity_type = form.entity_type.data
            title = form.title.data
            status = form.status.data
            date_published = form.date_published.data
            date_closed = form.date_closed.data
            tender_documents = form.tender_document.data
            company = get_company_id()

            if company:
                if date_published < date_closed:
                    document_name = save_tender_document(tender_documents, "tender")

                    tender = Tenders(entity_name=entity_name, entity_type=entity_type, title=title,
                                     status=status, date_published=date_published, date_closed=date_closed,
                                     tender_document=document_name, company=company)
                    db.session.add(tender)
                    db.session.commit()
                    flash(f"Your tender has been successfully posted. ", "success")
                    return redirect(url_for('publish_tender'))
                else:
                    flash("you can not put a closing date that is previous the opening date", "danger")
                    return render_template('buyer/tenders.html', form=form, company_name=firm.company_name)
            else:
                flash("you can not post a tender without registering your company. ", "warning")
                return render_template('buyer/tenders.html', form=form)
    return render_template('buyer/tenders.html', form=form)
Beispiel #13
0
def buyer_home():
    closed_tender = request.args.get('closed_tender', 1, type=int)
    open_tender = request.args.get('open_tender', 1, type=int)
    company = get_company_information()

    closed_tenders = Tenders.query.filter_by(company=0, is_delete=False, status="closed") \
        .paginate(page=closed_tender, per_page=5)
    open_tenders = Tenders.query.filter_by(company=0, is_delete=False, status="open") \
        .paginate(page=open_tender, per_page=6)
    bids = Bid.query.filter_by(id=0)

    if company:
        closed_tenders = Tenders.query.filter_by(company=company.id, is_delete=False, status="closed") \
            .paginate(page=closed_tender, per_page=5)
        open_tenders = Tenders.query.filter_by(company=company.id, is_delete=False, status="open") \
            .paginate(page=open_tender, per_page=6)
        bids = db.engine.execute(f"SELECT * FROM bidTender JOIN Bid ON bidTender.bid_id=Bid.id JOIN Tenders "
                                 f"ON bidTender.tender_id=Tenders.id WHERE company={company.id}")

        if request.method == "GET":
            return render_template('buyer/home.html', company_name=company.company_name
                                   , closed_tenders=closed_tenders, open_tenders=open_tenders, bids=bids)
    else:
        return render_template('buyer/home.html', closed_tenders=closed_tenders, open_tenders=open_tenders, bids=bids)