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
c3ffc8bb
Commit
c3ffc8bb
authored
Apr 08, 2013
by
Michal Čihař
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move suggestion notifications to suggestion adding code
parent
9e967a50
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
15 deletions
+25
-15
trans/models/unit.py
trans/models/unit.py
+23
-2
trans/views/edit.py
trans/views/edit.py
+2
-13
No files found.
trans/models/unit.py
View file @
c3ffc8bb
...
...
@@ -879,20 +879,22 @@ class Unit(models.Model):
position__lte
=
self
.
position
+
appsettings
.
NEARBY_MESSAGES
,
)
def
add_suggestion
(
self
,
target
,
user
):
def
add_suggestion
(
self
,
target
,
user
,
profile
):
'''
Creates new suggestion for this unit.
'''
from
trans.models.unitdata
import
Suggestion
,
Change
from
accounts.models
import
Profile
# Create the suggestion
Suggestion
.
objects
.
create
(
suggestion
=
Suggestion
.
objects
.
create
(
target
=
target
,
checksum
=
self
.
checksum
,
language
=
self
.
translation
.
language
,
project
=
self
.
translation
.
subproject
.
project
,
user
=
user
)
# Record in change
Change
.
objects
.
create
(
unit
=
self
,
...
...
@@ -900,6 +902,25 @@ class Unit(models.Model):
translation
=
self
.
translation
,
user
=
user
)
# Update suggestion count
self
.
translation
.
have_suggestion
+=
1
self
.
translation
.
save
()
# Notify subscribed users
subscriptions
=
Profile
.
objects
.
subscribed_new_suggestion
(
self
.
translation
.
subproject
.
project
,
self
.
translation
.
language
,
user
)
for
subscription
in
subscriptions
:
subscription
.
notify_new_suggestion
(
self
.
translation
,
suggestion
,
self
)
# Update suggestion stats
if
profile
is
not
None
:
profile
.
suggested
+=
1
profile
.
save
()
trans/views/edit.py
View file @
c3ffc8bb
...
...
@@ -111,7 +111,8 @@ def translate(request, project, subproject, lang):
# Create the suggestion
unit
.
add_suggestion
(
join_plural
(
form
.
cleaned_data
[
'target'
]),
user
user
,
profile
)
# Invite user to become translator if there is nobody else
recent_changes
=
Change
.
objects
.
content
().
filter
(
...
...
@@ -124,18 +125,6 @@ def translate(request, project, subproject, lang):
request
,
_
(
'There is currently no active translator for this translation, please consider becoming a translator as your suggestion might otherwise remain unreviewed.'
)
)
# Notify subscribed users
subscriptions
=
Profile
.
objects
.
subscribed_new_suggestion
(
obj
.
subproject
.
project
,
obj
.
language
,
request
.
user
)
for
subscription
in
subscriptions
:
subscription
.
notify_new_suggestion
(
obj
,
sug
,
unit
)
# Update suggestion stats
if
profile
is
not
None
:
profile
.
suggested
+=
1
profile
.
save
()
elif
not
request
.
user
.
is_authenticated
():
# We accept translations only from authenticated
messages
.
error
(
...
...
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