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
37b6793f
Commit
37b6793f
authored
Apr 08, 2013
by
Michal Čihař
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move suggestion adding to unit class
parent
c7e010de
Changes
2
Hide 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
-0
trans/views/edit.py
trans/views/edit.py
+2
-15
No files found.
trans/models/unit.py
View file @
37b6793f
...
...
@@ -878,3 +878,26 @@ class Unit(models.Model):
position__gte
=
self
.
position
-
appsettings
.
NEARBY_MESSAGES
,
position__lte
=
self
.
position
+
appsettings
.
NEARBY_MESSAGES
,
)
def
add_suggestion
(
self
,
target
):
'''
Creates new suggestion for this unit.
'''
# Create the 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
=
unit
,
action
=
Change
.
ACTION_SUGGESTION
,
translation
=
unit
.
translation
,
user
=
user
)
# Update suggestion count
self
.
translation
.
have_suggestion
+=
1
self
.
translation
.
save
()
trans/views/edit.py
View file @
37b6793f
...
...
@@ -109,22 +109,9 @@ def translate(request, project, subproject, lang):
)
)
# Create the suggestion
sug
=
Suggestion
.
objects
.
create
(
target
=
join_plural
(
form
.
cleaned_data
[
'target'
]),
checksum
=
unit
.
checksum
,
language
=
unit
.
translation
.
language
,
project
=
unit
.
translation
.
subproject
.
project
,
user
=
user
unit
.
add_suggestion
(
join_plural
(
form
.
cleaned_data
[
'target'
])
)
# Record in change
Change
.
objects
.
create
(
unit
=
unit
,
action
=
Change
.
ACTION_SUGGESTION
,
translation
=
unit
.
translation
,
user
=
user
)
# Invalidate counts cache
unit
.
translation
.
invalidate_cache
(
'suggestions'
)
# Invite user to become translator if there is nobody else
recent_changes
=
Change
.
objects
.
content
().
filter
(
translation
=
unit
.
translation
,
...
...
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