Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
Coopdevs OCB mirror
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Coopdevs
Odoo
Coopdevs OCB mirror
Commits
fc329b6e
Commit
fc329b6e
authored
10 years ago
by
Jeremy Kersten
Browse files
Options
Downloads
Patches
Plain Diff
[FIX] website_forum: use common method to compute tags for orm
parent
f0c024a6
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
addons/website_forum/controllers/main.py
+4
-22
4 additions, 22 deletions
addons/website_forum/controllers/main.py
addons/website_forum/models/forum.py
+19
-0
19 additions, 0 deletions
addons/website_forum/models/forum.py
with
23 additions
and
22 deletions
addons/website_forum/controllers/main.py
+
4
−
22
View file @
fc329b6e
...
...
@@ -223,12 +223,7 @@ class WebsiteForum(http.Controller):
else
:
question_tag_ids
.
append
((
0
,
0
,
{
'
name
'
:
tag
,
'
forum_id
'
:
forum
.
id
}))
elif
tag_version
==
"
select2
"
:
tags
=
filter
(
None
,
post
.
get
(
'
question_tags
'
,
''
).
split
(
'
,
'
))
for
tag
in
tags
:
if
tag
.
startswith
(
'
_
'
):
# it's a new tag
question_tag_ids
.
append
((
0
,
0
,
{
'
name
'
:
tag
[
1
:],
'
forum_id
'
:
forum
.
id
}))
else
:
question_tag_ids
.
append
((
4
,
int
(
tag
)))
question_tag_ids
=
forum
.
_tag_to_write_vals
(
cr
,
uid
,
post
.
get
(
'
question_tags
'
,
''
),
context
=
context
)
new_question_id
=
request
.
registry
[
'
forum.post
'
].
create
(
request
.
cr
,
request
.
uid
,
{
...
...
@@ -404,7 +399,6 @@ class WebsiteForum(http.Controller):
def
post_save
(
self
,
forum
,
post
,
**
kwargs
):
cr
,
uid
,
context
=
request
.
cr
,
request
.
uid
,
request
.
context
question_tags
=
[]
User
=
request
.
registry
[
'
res.users
'
]
Tag
=
request
.
registry
[
'
forum.tag
'
]
tag_version
=
kwargs
.
get
(
'
tag_type
'
,
'
texttext
'
)
if
tag_version
==
"
texttext
"
:
# old version - retro v8 - #TODO Remove in master
...
...
@@ -417,24 +411,12 @@ class WebsiteForum(http.Controller):
else
:
new_tag
=
Tag
.
create
(
cr
,
uid
,
{
'
name
'
:
tag
,
'
forum_id
'
:
forum
.
id
},
context
=
context
)
question_tags
.
append
(
new_tag
)
tags_val
=
[(
6
,
0
,
question_tags
)]
elif
tag_version
==
"
select2
"
:
# new version
for
tag
in
filter
(
None
,
kwargs
.
get
(
'
question_tag
'
,
''
).
split
(
'
,
'
)):
if
tag
.
startswith
(
'
_
'
):
# it's a new tag
# check if user have Karma needed to create need tag
user
=
User
.
browse
(
cr
,
SUPERUSER_ID
,
uid
,
context
=
context
)
if
user
.
exists
()
and
user
.
karma
>=
forum
.
karma_retag
:
# check that not arleady created meanwhile and maybe excluded by the limit on the search
tag_ids
=
Tag
.
search
(
cr
,
uid
,
[(
'
name
'
,
'
=
'
,
tag
[
1
:])],
context
=
context
)
if
tag_ids
:
new_tag
=
tag_ids
else
:
new_tag
=
Tag
.
create
(
cr
,
uid
,
{
'
name
'
:
tag
[
1
:],
'
forum_id
'
:
forum
.
id
},
context
=
context
)
question_tags
.
append
(
new_tag
)
else
:
question_tags
+=
[
int
(
tag
)]
tags_val
=
forum
.
_tag_to_write_vals
(
cr
,
uid
,
kwargs
.
get
(
'
question_tag
'
,
''
),
context
=
context
)
vals
=
{
'
tag_ids
'
:
[(
6
,
0
,
question_tags
)]
,
'
tag_ids
'
:
tags_val
,
'
name
'
:
kwargs
.
get
(
'
question_name
'
),
'
content
'
:
kwargs
.
get
(
'
content
'
),
}
...
...
This diff is collapsed.
Click to expand it.
addons/website_forum/models/forum.py
+
19
−
0
View file @
fc329b6e
...
...
@@ -119,6 +119,25 @@ class Forum(osv.Model):
create_context
=
dict
(
context
,
mail_create_nolog
=
True
)
return
super
(
Forum
,
self
).
create
(
cr
,
uid
,
values
,
context
=
create_context
)
def
_tag_to_write_vals
(
self
,
cr
,
uid
,
tags
=
''
,
context
=
None
):
User
=
self
.
pool
[
'
res.users
'
]
Tag
=
self
.
pool
[
'
forum.tag
'
]
post_tags
=
[]
for
tag
in
filter
(
None
,
tags
.
split
(
'
,
'
)):
if
tag
.
startswith
(
'
_
'
):
# it's a new tag
# check that not arleady created meanwhile or maybe excluded by the limit on the search
tag_ids
=
Tag
.
search
(
cr
,
uid
,
[(
'
name
'
,
'
=
'
,
tag
[
1
:])],
context
=
context
)
if
tag_ids
:
post_tags
.
append
((
4
,
int
(
tag_ids
[
0
])))
else
:
# check if user have Karma needed to create need tag
user
=
User
.
browse
(
cr
,
uid
,
uid
,
context
=
context
)
if
user
.
exists
()
and
user
.
karma
>=
self
.
karma_retag
:
post_tags
.
append
((
0
,
0
,
{
'
name
'
:
tag
[
1
:],
'
forum_id
'
:
self
.
id
}))
else
:
post_tags
.
append
((
4
,
int
(
tag
)))
return
post_tags
class
Post
(
osv
.
Model
):
_name
=
'
forum.post
'
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment