Exemplo n.º 1
0
    def deals():
        result = []
        d_deals = Deal.filter()
        for d in d_deals:
            photos = []
            d_photos = d.photos
            for p in d_photos:
                o_photo = {"url": p.filename}
                photos.append(o_photo)
            o_deal = {
                "title": d.title,
                "description": d.description,
                "created_by": {
                    "id": str(d.created_by),
                    "name": d.created_by.name + " " + d.created_by.surname
                },
                "created": d.created,
                "sourcing_fee": d.sourcing_fee,
                "roi": d.roi,
                "deal_type_id": d.deal_type_id,
                "document": "",
                "county": d.county,
                "city": d.city,
                "address_line_1": d.address_line_1,
                "address_line_2": d.address_line_2,
                "postcode": d.postcode,
                "show_address": d.show_address,
                "bedrooms": d.bedrooms,
                "photos": photos
            }
            result.append(o_deal)

        return jsonify(result)
Exemplo n.º 2
0
    def find_deal():
        deal_type_id = request.args.get("deal_type_id")
        filter_city = request.args.get("city")
        filter_county = request.args.get("county")
        filter_bedrooms = request.args.get("bedrooms")

        pagenr =0 if request.args.get("page") is None else  int(request.args.get("page"))
        pagesize = 100 if request.args.get("pagesize") is None else int(request.args.get("pagesize"))
        rows = Deal.filter(deal_type_id=deal_type_id, filter_city=filter_city, filter_county=filter_county)
        data = rows.paginate(pagenr, pagesize)
        deal_types = DealType.select()
        return render_template("find_deal.html",
                               data=data,
                               deal_types=deal_types,
                               cities=Deal.available_cities(),
                               counties=Deal.available_counties(),
                               records=rows.count(),
                               pagesize=pagesize,
                               bedrooms=Bedrooms.select())
Exemplo n.º 3
0
 def on_save(self, id):
     dt = Deal.get(Deal.uuid == str(id))
     dt.title = self.title.value
     dt.description = self.description.value
     dt.sourcing_fee = self.sourcing_fee.value
     dt.roi = self.roi.value
     dt.address_line_1 = self.address_line_1.value
     dt.address_line_2 = self.address_line_2.value
     dt.county = self.county.value
     dt.city = self.city.value
     dt.postcode = self.postcode.value
     dt.show_address = self.show_address.value
     dt.bedrooms = self.bedrooms.value
     dt.save()
     return redirect("/" + self.endpoint_name + "/list")
Exemplo n.º 4
0
 def update_deal():
     deal = Deal.get_by_id(request.form["id"])
     deal.title = request.form['title']
     deal.description = request.form["description"]
     deal.sourcing_fee = float(request.form["sourcing_fee"])
     deal.roi = float(request.form["roi"])
     deal.county = request.form['county']
     deal.city = request.form['city']
     deal.address_line_1 = request.form['address_line_1']
     deal.address_line_2 = request.form['address_line_2']
     deal.postcode = request.form['postcode']
     deal.show_address_details = bool(request.form['show_address_details'])
     if request.form["deal_type"] is not None and request.form["deal_type"] != "":
         deal.deal_type = DealType.get_by_id(request.form["deal_type"])
     deal.save()
     return redirect("/find_deal")
Exemplo n.º 5
0
def load_successfull_entries():
    rows = BatchCSVData.select().where(BatchCSVData.Is_Error==False, BatchCSVData.Processed == False)
    for row in rows:
        dt = DealType.get(DealType.uuid == row.DealTypeObj_id)
        dl1 = Deal.create(description=row.Description,
                          title=row.Title,
                          created=datetime.datetime.now(),
                          created_by=row.Batch.Uploaded_By,
                          deal_type=dt,
                          sourcing_fee=row.Sourcing_Fee,
                          roi=row.ROI,
                          document=None,
                          uuid=uuid.uuid4(),
                          county=row.County,
                          city=row.City,
                          address_line_1=row.Address_1,
                          address_line_2=row.Address_2,
                          postcode=row.Postcode,
                         show_address=row.Show_Address)
        row.Processed = True;
        row.Date_Processed = datetime.datetime.now()
        row.save()
Exemplo n.º 6
0
 def on_insert(self):
     self.get_field_values_from_request()
     saved_docs = self.document.save_file()
     dl = Deal.create(
         title = self.title.value,
         description = self.description.value,
         created_by = current_user.uuid,
         created = datetime.datetime.now(),
         sourcing_fee = self.sourcing_fee.value,
         roi = self.roi.value,
         deal_type_id = self.deal_type.value,
         document = saved_docs[0] if len(saved_docs)>0 else None,
         county = self.county.value,
         city = self.city.value,
         address_line_1 = self.address_line_1.value,
         address_line_2 = self.address_line_2.value,
         postcode = self.postcode.value,
         show_address = self.show_address.get_value(),
         bedrooms = self.bedrooms.value
     )
     saved_pics = self.photos.save_file()
     for pic in saved_pics:
         ph = DealPhoto.create(filename=pic, deal=dl.uuid)
Exemplo n.º 7
0
 def delete_deal(id):
     Deal.delete_by_id(id)
     return redirect("/find_deal")
Exemplo n.º 8
0
 def edit_deal(id):
     return render_template("edit_deal.html",
                            data=Deal.get_by_uuid(id),
                            deal_types=DealType.get_all())
Exemplo n.º 9
0
 def view_deal(id):
     data = Deal.get_by_uuid(id)
     photos = DealPhoto.get_photos_by_deal_id(id)
     return render_template("view_deal.html",
                            data=data,
                            photos=photos)
Exemplo n.º 10
0
 def deals_by_owner(id):
     return render_template("deals_by_owner.html",
                            data=Deal.get_deals_created_by_user(id)
                            )
Exemplo n.º 11
0
 def on_delete(self, id):
     query = Deal.delete().where(Deal.uuid == str(id))
     query.execute()
     return redirect("/"+self.endpoint_name+"/list")
Exemplo n.º 12
0
 def on_edit(self, id):
     return Deal.get(Deal.uuid == str(id))
Exemplo n.º 13
0
 def on_get_list(self):
     return Deal.select().where((Deal.deleted == False), (Deal.created_by_id == current_user.uuid))
Exemplo n.º 14
0
def setup_test_data():
    dt1 = DealType.create(deal_type="HMO")
    dt2 = DealType.create(deal_type="Land Development")
    dt3 = DealType.create(deal_type="R2R - HMO")
    dt4 = DealType.create(deal_type="R2R - SA")
    dt5 = DealType.create(deal_type="Buy to let")
    dt6 = DealType.create(deal_type="Commercial to Residentual")
    dt7 = DealType.create(deal_type="Lease Option")
    dt8 = DealType.create(deal_type="Other")
    dt9 = DealType.create(deal_type="Apartment Block")

    faq1 = FAQ.create(question="Question A", answer="Answer AA" )
    faq2 = FAQ.create(question="Question B", answer="Answer BB" )
    faq3 = FAQ.create(question="Question C", answer="Answer CC" )


    bedroom_not_applicable = Bedrooms.create(description="Not Applicable" )
    bedroomstudio = Bedrooms.create(description="Studio" )
    bedroom1 = Bedrooms.create(description="1 Bed" )
    bedroom2 = Bedrooms.create(description="2 Bed" )
    bedroom3 = Bedrooms.create(description="3 Bed" )
    bedroom4 = Bedrooms.create(description="4 Bed" )
    bedroom5 = Bedrooms.create(description="5 Bed" )
    bedroom6 = Bedrooms.create(description="6 Bed" )
    bedroom7 = Bedrooms.create(description="7 Bed" )
    bedroom8 = Bedrooms.create(description="8 Bed" )
    bedrooom_other = Bedrooms.create(description="More than 8" )

    desc = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean sed metus bibendum enim semper tempor vitae et neque. Integer lobortis lacus tortor. Fusce finibus hendrerit nunc sed vehicula. Sed dapibus lectus nec imperdiet faucibus. Mauris aliquet arcu nec quam aliquam, quis pharetra ipsum dapibus. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Etiam imperdiet ornare purus, vitae suscipit risus cursus ac. Etiam scelerisque imperdiet nibh, non condimentum nisl aliquam non. Donec quis nunc in diam convallis vulputate sed in purus. Aliquam venenatis ultrices imperdiet. Suspendisse consectetur leo id nisl consequat, in vestibulum tortor vehicula. Vestibulum eget elit condimentum, bibendum sem luctus, venenatis mi. Nam pellentesque molestie urna ut congue."

    inv1 = User.create(name="Richard", surname="Smit", telephone="07540388001", email="*****@*****.**" ,
                       password="******", activated=True, is_admin=True, disabled=False)
    inv2 = User.create(name="John", surname="Haagensen", telephone="07540388001", email="*****@*****.**" ,
                       password="******", activated=True, disabled=True)

    dl1 = Deal.create(description=desc, title='Cheap SA', created=datetime.datetime(2018, 6, 13, 00, 00),
                      created_by=inv1, deal_type=dt1, sourcing_fee=2000, roi=10,
                      document="026d9108-6ec1-48b5-b7a4-ae02e2ff92e2.jpg" , county="Surrey", city="Shepperton",
                      address_line_1="304 Laleham Road", address_line_2="laleham road", postcode='tw17 0jq',
                      comparables = "xxxx",
                      key_features = "Feature 1, Feature 2, Feature 3",
                      show_address=True)
    dl2 = Deal.create(description=desc, title='2 Year D2V', created=datetime.datetime.now(),
                      created_by=inv1, deal_type=dt2 , county="Berkshire", city="Reading")
    dl3 = Deal.create(description=desc, title='HMO D2V', created=datetime.datetime.now(),
                      created_by=inv2, deal_type=dt2 , county="Berkshire", city="London")

    dq1 = DealQuestion.create(question="Is this D2V?", deal=dl1.uuid , asked_by=inv1.uuid)
    dqa1 = DealQuestionAnswer.create(answer="Yes it is", deal_question=dq1.uuid , answered_by=inv2.uuid)

    dq2 = DealQuestion.create(question="Can we view the property?", deal=dl1.uuid , asked_by=inv1.uuid)
    dqa2 = DealQuestionAnswer.create(answer="No", deal_question=dq2.uuid , answered_by=inv2.uuid)

    msg = Message.create(message_from=inv2, message_to=inv1, message="hello there" )

    df = DealPhoto.create(filename="026d9108-6ec1-48b5-b7a4-ae02e2ff92e2.jpg", deal=dl1.uuid )
    df2 = DealPhoto.create(filename="026d9108-6ec1-48b5-b7a4-ae02e2ff92e2.jpg", deal=dl1.uuid )
    df3 = DealPhoto.create(filename="026d9108-6ec1-48b5-b7a4-ae02e2ff92e2.jpg", deal=dl1.uuid )
    df4 = DealPhoto.create(filename="026d9108-6ec1-48b5-b7a4-ae02e2ff92e2.jpg", deal=dl1.uuid )

    fav = Favourites.create(deal=dl1.uuid , user=inv1.uuid)
    rev1 = Reviews.create(stars=3,
                          comment="test" ,
                          user=inv1.uuid)
    rev2 = Reviews.create(stars=5,
                          comment="test",
                          user=inv1.uuid)

    batch = BatchCSV.create(Filename="96249887-e751-4a1f-9b3d-05d5a24ecc46.csv" , Uploaded_By=inv1)