Skip to content

Commit d052826

Browse files
committed
[ADD] real_estate : access groups, categories, privileges + finish 7 JS task
- Implemented user groups and access control - Added category and privilege concepts - Completed all 7 JavaScript exercises
1 parent c9b8123 commit d052826

29 files changed

Lines changed: 339 additions & 62 deletions

awesome_owl/__manifest__.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
# any module necessary for this one to work correctly
2323
'depends': ['base', 'web'],
2424
'application': True,
25-
'installable': True,
2625
'data': [
2726
'views/templates.xml',
2827
],
@@ -35,9 +34,12 @@
3534
'web/static/lib/bootstrap/scss/_maps.scss',
3635
('include', 'web._assets_bootstrap'),
3736
('include', 'web._assets_core'),
38-
'web/static/src/libs/fontawesome/css/font-awesome.css',
39-
'awesome_owl/static/src/**/*',
37+
# 'web/static/src/libs/fontawesome/css/font-awesome.css',
38+
# 'awesome_owl/static/src/**/*',
39+
'awesome_owl/static/src/**/*.js',
40+
'awesome_owl/static/src/**/*.xml',
4041
],
4142
},
43+
"installable": True,
4244
'license': 'AGPL-3'
4345
}

awesome_owl/controllers/controllers.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22
from odoo.http import request, route
33

44
class OwlPlayground(http.Controller):
5-
@http.route(['/awesome_owl'], type='http', auth='public')
5+
@http.route(['/awesome_owl'], type='http', auth='public', website=True)
66
def show_playground(self):
7-
"""
8-
Renders the owl playground page
9-
"""
107
return request.render('awesome_owl.playground')
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/** @odoo-module **/
2+
import { Component , useState } from "@odoo/owl";
3+
4+
export class Card extends Component {
5+
static template = "awesome_owl.Card";
6+
static props = {
7+
title: { type: String },
8+
content: { type: String, optional: true },
9+
content: String,
10+
};
11+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<templates xml:space="preserve">
3+
<t t-name="awesome_owl.Card">
4+
<div class="card d-inline-block m-2" style="width: 18rem;">
5+
<div class="card-body">
6+
<h5 class="card-title">
7+
<t t-esc="props.title"/>
8+
</h5>
9+
<p class="card-text">
10+
<t t-out="props.content"/>
11+
</p>
12+
</div>
13+
</div>
14+
</t>
15+
</templates>
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/** @odoo-module **/
2+
import { Component, useState} from "@odoo/owl";
3+
4+
5+
export class Counter extends Component {
6+
static template = "awesome_owl.Counter";
7+
static props = {
8+
onChange: { type: Function, optional: true },
9+
};
10+
setup() {
11+
this.state = useState({ counter: 0 });
12+
}
13+
14+
increment() {
15+
this.state.counter += 1;
16+
if (this.props.onChange) {
17+
this.props.onChange(this.state.counter);
18+
}
19+
}
20+
}
21+
//Counter.template = "awesome_owl.Counter";
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<templates xml:space="preserve">
3+
<t t-name="awesome_owl.Counter">
4+
<!-- <div class="o_counter">-->
5+
<!-- <h2>Counter Example</h2>-->
6+
<!-- <p>Current value: <t t-esc="state.counter"/></p>-->
7+
<!-- <button t-on-click="increment" class="btn btn-primary">Increment</button>-->
8+
9+
<div class="o_counter">
10+
<div class="card d-inline-block m-2" style="width: 18rem;">
11+
<div class="card-body d-flex justify-content-between align-items-center">
12+
<span class="fw-bold">
13+
Counter: <t t-esc="state.counter"/>
14+
</span>
15+
<button t-on-click="increment" class="btn btn-primary btn-sm">
16+
Increment
17+
</button>
18+
</div>
19+
</div>
20+
</div>
21+
</t>
22+
</templates>

awesome_owl/static/src/main.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/** @odoo-module **/
12
import { whenReady } from "@odoo/owl";
23
import { mountComponent } from "@web/env";
34
import { Playground } from "./playground";
@@ -7,6 +8,4 @@ const config = {
78
name: "Owl Tutorial"
89
};
910

10-
// Mount the Playground component when the document.body is ready
1111
whenReady(() => mountComponent(Playground, document.body, config));
12-
Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,38 @@
1-
import { Component } from "@odoo/owl";
1+
/** @odoo-module **/
2+
import { Component, useState, markup } from "@odoo/owl";
3+
import { Counter } from "./counter/counter";
4+
import { Card } from "./card/card";
5+
import { TodoList } from "./todo/todo_list";
26

37
export class Playground extends Component {
4-
static template = "awesome_owl.playground";
8+
static template = "awesome_owl.Playground";
9+
static props = {};
10+
static components = { Counter, Card, TodoList };
11+
setup() {
12+
this.safeHtml = markup("<b>Bold HTML</b> with <i>markup()</i>");
13+
this.unsafeHtml = "<b>This will NOT be bold</b>";
14+
this.state = useState({ sum: 0 });
15+
this.c1 = 0;
16+
this.c2 = 0;
17+
}
18+
19+
onCounter1Change(val) {
20+
this.c1 = val;
21+
this.state.sum = this.c1 + this.c2;
22+
}
23+
24+
onCounter2Change(val) {
25+
this.c2 = val;
26+
this.state.sum = this.c1 + this.c2;
27+
}
28+
29+
// setup() {
30+
// this.state = useState({ counter: 0 });
31+
// }
32+
//
33+
// increment() {
34+
// this.state.counter += 1;
35+
// }
36+
537
}
38+
//Playground.template = "awesome_owl.Playground";
Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,28 @@
1-
<?xml version="1.0" encoding="UTF-8" ?>
1+
<?xml version="1.0" encoding="UTF-8"?>
22
<templates xml:space="preserve">
3+
<t t-name="awesome_owl.Playground">
4+
<!-- <div class="o_playground">-->
5+
<div class="o_playground p-3">
36

4-
<t t-name="awesome_owl.playground">
5-
<div class="p-3">
6-
hello world
7-
</div>
8-
</t>
7+
<div class="d-flex">
8+
<Counter onChange.bind="onCounter1Change"/>
9+
<Counter onChange.bind="onCounter2Change"/>
10+
</div>
911

12+
<p class="mt-2 fw-bold">
13+
The sum is: <t t-esc="state.sum"/>
14+
</p>
15+
16+
17+
<Card title="'First Card'" content="safeHtml"/>
18+
<Card title="'Second Card'" content="unsafeHtml"/>
19+
<Card title="'Third card'" content="'Reusable components are powerful!'"/>
20+
21+
<!-- <h2>Counter Example</h2>-->
22+
<!-- <p>Current value: <t t-esc="state.counter"/></p>-->
23+
<!-- <button t-on-click="increment">Increment</button>-->
24+
25+
<TodoList/>
26+
</div>
27+
</t>
1028
</templates>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/** @odoo-module **/
2+
import { Component } from "@odoo/owl";
3+
import { types } from "@odoo/owl";
4+
5+
export class TodoItem extends Component {
6+
7+
static template = "awesome_owl.TodoItem";
8+
static props = {
9+
todo: { type: Object, required: true },
10+
};
11+
}
12+

0 commit comments

Comments
 (0)