-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[IMP] estate: created controller of estate to access in website
- Created the controller in estate - Add pagination - Add redirect of property detail view - Covered the controller section
- Loading branch information
Showing
7 changed files
with
184 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
from . import models | ||
from . import controller |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import estate_property_controller |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import math | ||
import logging | ||
from odoo.http import Controller, request, route | ||
|
||
|
||
class PropertyController(Controller): | ||
|
||
@route( | ||
["/properties", "/properties/page/<int:page>"], | ||
auth="public", | ||
type="http", | ||
website=True, | ||
) | ||
def properties_controller(self, page=1, per_page=6, *args, **kwargs): | ||
try: | ||
property_recode = request.env["estate.property"] | ||
page = int(page) | ||
per_page = int(per_page) | ||
offset = (page - 1) * per_page | ||
limit = per_page | ||
domain = [("state", "in", ["offer_recived", "offer_accepted"])] | ||
properties = property_recode.search( | ||
domain, | ||
limit=limit, | ||
offset=offset, | ||
) | ||
total_property = properties.search_count(domain) | ||
total_pages = math.ceil(total_property / per_page) | ||
pager = { | ||
"url": "/properties/page/" + str(page), | ||
"total": total_property, | ||
"page": page, | ||
"total_page": total_pages, | ||
"step": per_page, | ||
} | ||
values = {"properties": properties, "pager": pager} | ||
return request.render("estate.estate_properties_web", values) | ||
except Exception as e: | ||
logging.exception("Error while processing estate_property", e) | ||
|
||
@route( | ||
"/properties/<int:property_id>", | ||
auth="public", | ||
type="http", | ||
website=True, | ||
methods=["GET"], | ||
) | ||
def property_controller(self, property_id, *args, **kwargs): | ||
try: | ||
property_recode = request.env["estate.property"].browse(property_id) | ||
return request.render( | ||
"estate.estate_property_web", ({"property": property_recode}) | ||
) | ||
except Exception as e: | ||
logging.exception("Error while processing estate_property") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
<odoo> | ||
<template id="estate_properties_web" name="Estate Properties"> | ||
<t t-call="website.layout"> | ||
<div id="wrap" class="h-100 d-flex flex-column align-item-center justify-content-between"> | ||
<div class="container mt-4"> | ||
<h1 class="text-center mb-4">Estate Properties</h1> | ||
<div class="row"> | ||
<t t-foreach="properties" t-as="property"> | ||
<div class="col-md-4 mb-4"> | ||
<a t-att-href="'/properties/' + str(property.id)" class="o_action" style="text-decoration:none;"> | ||
<div class="card d-f flex-column align-items-center"> | ||
<img t-if="property.property_image" class="" style="height: 300px; width: 410px; " t-att-src="image_data_uri(property.property_image)"/> | ||
<div class="container p-1" style="width:90%;"> | ||
<div class="grid"> | ||
<t t-foreach="property.tag_ids" t-as="tag"> | ||
<span t-attf-class="badge rounded-pill text-bg-primary "> | ||
<t t-out="tag.name"/> | ||
</span> | ||
</t> | ||
</div> | ||
</div> | ||
<div style="width:90%" class="p-2"> | ||
<h6 class="card-title"> | ||
<t t-esc="property.name"/> | ||
</h6> | ||
</div> | ||
</div> | ||
</a> | ||
</div> | ||
</t> | ||
</div> | ||
</div> | ||
<div class="d-flex flex-row align-items-center justify-content-center" style="width: 100%; height: 30px;"> | ||
<t t-foreach="pager['total_page']" t-as="page"> | ||
<div class="m-1 rounded-circle" style="width: 20px; height: 20px; background-color: #f2f2f2; text-align: center;"> | ||
<a t-att-href="'/properties/page/'+str(page+1)"> | ||
<t t-esc="page+1"/> | ||
</a> | ||
</div> | ||
</t> | ||
</div> | ||
</div> | ||
</t> | ||
</template> | ||
|
||
<template id="estate_property_web" name="Estate Properties"> | ||
<t t-call="website.layout"> | ||
<div class="container"> | ||
<!-- <h1 class="text-center mb-4"> <t t-esc="property.name"/></h1> --> | ||
<div class="row m-5 "> | ||
<div class="card mb-3" style="max-width:90%"> | ||
<div class="row g-0 "> | ||
<t t-if="property.property_image"> | ||
<div class="col-md-6 d-flex align-items-center justify-content-center p-2"> | ||
<img t-if="property.property_image" class="img-fluid rounded-start " style="min-height: 400px; min-width: 400px; object-fit: cover;" t-att-src="image_data_uri(property.property_image)" /> | ||
</div> | ||
</t> | ||
<div class="col-md-5"> | ||
<div class="card-body"> | ||
<h4 class="card-title"> | ||
<t t-esc="property.name"/> | ||
</h4> | ||
<p class="card-text"> State: | ||
<t t-esc="property.state"/> | ||
<br/> | ||
Expected Price: | ||
<t t-esc="property.expected_price"/> | ||
</p> | ||
<p class="card-text"> | ||
<small class="text-body-secondary"> | ||
Selling Price: | ||
<t t-esc="property.selling_price"/> | ||
</small> | ||
<br/> | ||
<small class="text-body-secondary"> | ||
Available Date: | ||
<t t-esc="property.date_availability"/> | ||
</small> | ||
<br/> | ||
<small class="text-body-secondary"> | ||
Bedrooms: | ||
<t t-esc="property.bedrooms"/> | ||
</small> | ||
<br/> | ||
<small class="text-body-secondary"> | ||
Living Area: | ||
<t t-esc="property.living_area"/> | ||
m2 | ||
</small> | ||
<br/> | ||
<small class="text-body-secondary"> | ||
Grage: | ||
<t t-esc="property.garage"/> | ||
</small> | ||
<br/> | ||
<small class="text-body-secondary"> | ||
Salesman: | ||
<t t-esc="property.salesman_id.name"/> | ||
</small> | ||
<br/> | ||
<t t-if="property.property_type_id"> | ||
<small class="text-body-secondary"> | ||
Property Type: | ||
<t t-esc="property.property_type_id.name"/> | ||
</small> | ||
</t> | ||
<br/> | ||
<small class="text-body-secondary"> | ||
Description: | ||
<t t-esc="property.description"/> | ||
</small> | ||
</p> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</t> | ||
</template> | ||
</odoo> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters