Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
converse.js
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
converse.js
Commits
8d3a859d
Commit
8d3a859d
authored
Jul 17, 2013
by
Michal Čihař
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Automatically add vote to own suggestion (issue #248)
parent
6b9d33f7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
4 deletions
+13
-4
trans/models/unitdata.py
trans/models/unitdata.py
+12
-2
trans/views/edit.py
trans/views/edit.py
+1
-2
No files found.
trans/models/unitdata.py
View file @
8d3a859d
...
...
@@ -49,14 +49,16 @@ class RelatedUnitMixin(object):
class
SuggestionManager
(
models
.
Manager
):
def
add
(
self
,
unit
,
target
,
user
):
def
add
(
self
,
unit
,
target
,
request
):
'''
Creates new suggestion for this unit.
'''
from
accounts.models
import
notify_new_suggestion
if
not
user
.
is_authenticated
():
if
not
request
.
user
.
is_authenticated
():
user
=
None
else
:
user
=
request
.
user
# Create the suggestion
suggestion
=
Suggestion
.
objects
.
create
(
...
...
@@ -75,6 +77,14 @@ class SuggestionManager(models.Manager):
user
=
user
)
# Add unit vote
if
user
is
not
None
and
unit
.
can_vote_suggestions
():
suggestion
.
add_vote
(
unit
.
translation
,
request
,
True
)
# Notify subscribed users
notify_new_suggestion
(
unit
,
suggestion
,
user
)
...
...
trans/views/edit.py
View file @
8d3a859d
...
...
@@ -207,7 +207,6 @@ def handle_translate(obj, request, user_locked, this_unit_url, next_unit_url):
if
'suggest'
in
request
.
POST
:
# Handle suggesion saving
user
=
request
.
user
if
form
.
cleaned_data
[
'target'
][
0
]
==
''
:
messages
.
error
(
request
,
_
(
'Your suggestion is empty!'
))
# Stay on same entry
...
...
@@ -228,7 +227,7 @@ def handle_translate(obj, request, user_locked, this_unit_url, next_unit_url):
Suggestion
.
objects
.
add
(
unit
,
join_plural
(
form
.
cleaned_data
[
'target'
]),
user
,
request
,
)
elif
not
request
.
user
.
is_authenticated
():
# We accept translations only from authenticated
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment