-
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: Implemented Controller
after this commit: Implemented controller
- Loading branch information
Showing
6 changed files
with
150 additions
and
1 deletion.
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,2 +1,3 @@ | ||
from . import models | ||
from . import wizard | ||
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,30 @@ | ||
from odoo import http | ||
from odoo.http import request | ||
|
||
|
||
class EstatePropertyController(http.Controller): | ||
|
||
@http.route(['/properties', '/properties/page/<int:page>'], type='http', auth='public', website=True) | ||
def property_list(self, page=1, **searches): | ||
Property = request.env['estate.property'] | ||
domain = [('state', 'in', ['new', 'offer Received', 'offer Accepted'])] | ||
|
||
properties_count = Property.search_count(domain) | ||
pager = request.website.pager( | ||
url='/properties', | ||
total=properties_count, | ||
page=page, | ||
step=6, | ||
) | ||
|
||
properties = Property.search(domain, limit=6, offset=pager['offset']) | ||
return request.render('estate.property_listing', { | ||
'properties': properties, | ||
'pager': pager, | ||
}) | ||
|
||
@http.route('/property/<model("estate.property"):estate_property>', type='http', auth='public', website=True) | ||
def property_detail(self, estate_property, **kwargs): | ||
return request.render('estate.property_detail', { | ||
'property': 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<odoo> | ||
<data noupdate="1"> | ||
<record id="menu_estate_property" model="website.menu"> | ||
<field name="name">Available Properties</field> | ||
<field name="url">/properties</field> | ||
<field name="parent_id" ref="website.main_menu" /> | ||
</record> | ||
</data> | ||
|
||
<data noupdate="1"> | ||
<record id="menu_estate_property1" model="website.menu"> | ||
<field name="name">Properties</field> | ||
<field name="url">/properties</field> | ||
<field name="parent_id" ref="website.main_menu" /> | ||
</record> | ||
</data> | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<odoo> | ||
<template id="property_listing" name="Property Listing"> | ||
<t t-call="website.layout"> | ||
<div class="container mt-5"> | ||
<h1 class="text-center"> | ||
Available Properties | ||
</h1> | ||
<div class="row"> | ||
<t t-foreach="properties" t-as="property"> | ||
<div class="col-md-4 mb-4"> | ||
<div class="card h-100"> | ||
<div class="card-body"> | ||
<h5 class="card-title"> | ||
<t t-esc="property.name" /> | ||
</h5> | ||
<p class="card-text"> | ||
<t t-esc="property.description" /> | ||
</p> | ||
<a t-att-href="'/property/%s' % property.id" | ||
class="btn btn-primary"> | ||
View Property | ||
</a> | ||
</div> | ||
<div class="card-footer"> | ||
<small class="text-muted"> Price: <t | ||
t-esc="property.expected_price" /> | ||
</small> | ||
</div> | ||
</div> | ||
</div> | ||
</t> | ||
</div> | ||
<t t-call="website.pager" t-set="pager" /> | ||
</div> | ||
</t> | ||
</template> | ||
<template id="property_detail" name="Property Detail"> | ||
<t t-call="website.layout"> | ||
<!-- <t t-set="title">Modern Apartment</t> --> | ||
<t t-set="head"> | ||
<link rel="stylesheet" | ||
href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" /> | ||
</t> | ||
<div class="container mt-5"> | ||
<div class="row"> | ||
<div class="col-md-12 text-center"> | ||
<h1 class="display-4"> | ||
<t t-esc="property.name" /> | ||
</h1> | ||
</div> | ||
</div> | ||
<div class="row"> | ||
<!-- <div class="col-md-6"> | ||
<t t-if="property.image"> | ||
<img t-att-src="'data:image/png;base64,%s' % property.image.decode()" | ||
class="img-fluid rounded shadow" alt="Property Image" /> | ||
</t> | ||
</div> --> | ||
<div class="col-md-6"> | ||
<div class="card"> | ||
<div class="card-body"> | ||
<h5 class="card-title">Property Details</h5> | ||
<p class="card-text"> | ||
<strong>Description: </strong> | ||
<t t-esc="property.description" /> | ||
</p> | ||
<p class="card-text"> | ||
<strong>Price: </strong> | ||
<t t-esc="property.expected_price" /> | ||
</p> | ||
<p class="card-text"> | ||
<strong>Bedrooms: </strong> | ||
<t t-esc="property.bedrooms" /> | ||
</p> | ||
<p class="card-text"> | ||
<strong>Living Area: </strong> | ||
<t t-esc="property.living_area" /> | ||
sqm </p> | ||
<t t-if="property.garden"> | ||
<p class="card-text"> | ||
<strong>Garden Area: </strong> | ||
<t | ||
t-esc="property.garden_area" />sqm </p> | ||
<p class="card-text"> | ||
<strong>Garden Orientation: </strong> | ||
<t t-esc="property.garden_orientation" /> | ||
</p> | ||
</t> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</t> | ||
</template> | ||
</odoo> |