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
539d1f3e
Commit
539d1f3e
authored
Jul 17, 2013
by
Michal Čihař
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Suggestions are now manipulated using POST
Fixes #291
parent
86926d9c
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
18 additions
and
16 deletions
+18
-16
trans/tests/views.py
trans/tests/views.py
+2
-2
trans/views/edit.py
trans/views/edit.py
+13
-11
weblate/html/translate.html
weblate/html/translate.html
+2
-2
weblate/media/style.css
weblate/media/style.css
+1
-1
No files found.
trans/tests/views.py
View file @
539d1f3e
...
@@ -348,7 +348,7 @@ class EditTest(ViewTestCase):
...
@@ -348,7 +348,7 @@ class EditTest(ViewTestCase):
suggestions
=
[
sug
.
pk
for
sug
in
unit
.
suggestions
()]
suggestions
=
[
sug
.
pk
for
sug
in
unit
.
suggestions
()]
# Delete one of suggestions
# Delete one of suggestions
self
.
client
.
ge
t
(
self
.
client
.
pos
t
(
self
.
translate_url
,
self
.
translate_url
,
{
'delete'
:
suggestions
[
0
]},
{
'delete'
:
suggestions
[
0
]},
)
)
...
@@ -368,7 +368,7 @@ class EditTest(ViewTestCase):
...
@@ -368,7 +368,7 @@ class EditTest(ViewTestCase):
self
.
assertFalse
(
unit
.
fuzzy
)
self
.
assertFalse
(
unit
.
fuzzy
)
# Accept one of suggestions
# Accept one of suggestions
self
.
client
.
ge
t
(
self
.
client
.
pos
t
(
self
.
translate_url
,
self
.
translate_url
,
{
'accept'
:
suggestions
[
1
]},
{
'accept'
:
suggestions
[
1
]},
)
)
...
...
trans/views/edit.py
View file @
539d1f3e
...
@@ -387,14 +387,14 @@ def handle_suggestions(obj, request, this_unit_url):
...
@@ -387,14 +387,14 @@ def handle_suggestions(obj, request, this_unit_url):
return
HttpResponseRedirect
(
this_unit_url
)
return
HttpResponseRedirect
(
this_unit_url
)
# Parse suggestion ID
# Parse suggestion ID
if
'accept'
in
request
.
GE
T
:
if
'accept'
in
request
.
POS
T
:
if
not
request
.
user
.
has_perm
(
'trans.accept_suggestion'
):
if
not
request
.
user
.
has_perm
(
'trans.accept_suggestion'
):
messages
.
error
(
messages
.
error
(
request
,
request
,
_
(
'You do not have privilege to accept suggestions!'
)
_
(
'You do not have privilege to accept suggestions!'
)
)
)
return
HttpResponseRedirect
(
this_unit_url
)
return
HttpResponseRedirect
(
this_unit_url
)
sugid
=
request
.
GE
T
[
'accept'
]
sugid
=
request
.
POS
T
[
'accept'
]
else
:
else
:
if
not
request
.
user
.
has_perm
(
'trans.delete_suggestion'
):
if
not
request
.
user
.
has_perm
(
'trans.delete_suggestion'
):
messages
.
error
(
messages
.
error
(
...
@@ -402,7 +402,7 @@ def handle_suggestions(obj, request, this_unit_url):
...
@@ -402,7 +402,7 @@ def handle_suggestions(obj, request, this_unit_url):
_
(
'You do not have privilege to delete suggestions!'
)
_
(
'You do not have privilege to delete suggestions!'
)
)
)
return
HttpResponseRedirect
(
this_unit_url
)
return
HttpResponseRedirect
(
this_unit_url
)
sugid
=
request
.
GE
T
[
'delete'
]
sugid
=
request
.
POS
T
[
'delete'
]
try
:
try
:
sugid
=
int
(
sugid
)
sugid
=
int
(
sugid
)
suggestion
=
Suggestion
.
objects
.
get
(
pk
=
sugid
)
suggestion
=
Suggestion
.
objects
.
get
(
pk
=
sugid
)
...
@@ -410,7 +410,7 @@ def handle_suggestions(obj, request, this_unit_url):
...
@@ -410,7 +410,7 @@ def handle_suggestions(obj, request, this_unit_url):
suggestion
=
None
suggestion
=
None
if
suggestion
is
not
None
:
if
suggestion
is
not
None
:
if
'accept'
in
request
.
GE
T
:
if
'accept'
in
request
.
POS
T
:
# Accept suggesion
# Accept suggesion
suggestion
.
accept
(
obj
,
request
)
suggestion
.
accept
(
obj
,
request
)
else
:
else
:
...
@@ -469,9 +469,15 @@ def translate(request, project, subproject, lang):
...
@@ -469,9 +469,15 @@ def translate(request, project, subproject, lang):
# Any form submitted?
# Any form submitted?
if
request
.
method
==
'POST'
and
not
project_locked
:
if
request
.
method
==
'POST'
and
not
project_locked
:
response
=
handle_translate
(
obj
,
request
,
user_locked
,
this_unit_url
,
next_unit_url
# Handle accepting/deleting suggestions
)
if
'accept'
in
request
.
POST
or
'delete'
in
request
.
POST
:
if
not
locked
:
response
=
handle_suggestions
(
obj
,
request
,
this_unit_url
)
else
:
response
=
handle_translate
(
obj
,
request
,
user_locked
,
this_unit_url
,
next_unit_url
)
# Handle translation merging
# Handle translation merging
elif
'merge'
in
request
.
GET
and
not
locked
:
elif
'merge'
in
request
.
GET
and
not
locked
:
...
@@ -481,10 +487,6 @@ def translate(request, project, subproject, lang):
...
@@ -481,10 +487,6 @@ def translate(request, project, subproject, lang):
elif
'revert'
in
request
.
GET
and
not
locked
:
elif
'revert'
in
request
.
GET
and
not
locked
:
response
=
handle_revert
(
obj
,
request
,
this_unit_url
)
response
=
handle_revert
(
obj
,
request
,
this_unit_url
)
# Handle accepting/deleting suggestions
elif
not
locked
and
(
'accept'
in
request
.
GET
or
'delete'
in
request
.
GET
):
response
=
handle_suggestions
(
obj
,
request
,
this_unit_url
)
# Pass possible redirect further
# Pass possible redirect further
if
response
is
not
None
:
if
response
is
not
None
:
return
response
return
response
...
...
weblate/html/translate.html
View file @
539d1f3e
...
@@ -121,10 +121,10 @@
...
@@ -121,10 +121,10 @@
{% if perms.trans.accept_suggestion or perms.trans.delete_suggestion %}
{% if perms.trans.accept_suggestion or perms.trans.delete_suggestion %}
<div
class=
"menu-float action-buttons"
>
<div
class=
"menu-float action-buttons"
>
{% if perms.trans.accept_suggestion %}
{% if perms.trans.accept_suggestion %}
<
a
href=
"{{ this_unit_url }}&accept={{ suggestion.id }}"
class=
"sug-accept"
>
{% trans "Accept" %}
</a
>
<
button
type=
"submit"
class=
"sug-accept"
name=
"accept"
value=
"{{ suggestion.id }}"
>
{% trans "Accept" %}
</button
>
{% endif %}
{% endif %}
{% if perms.trans.delete_suggestion %}
{% if perms.trans.delete_suggestion %}
<
a
href=
"{{ this_unit_url }}&delete={{ suggestion.id }}"
class=
"sug-delete"
>
{% trans "Delete" %}
</a
>
<
button
type=
"submit"
class=
"sug-delete"
name=
"delete"
value=
"{{ suggestion.id }}"
>
{% trans "Delete" %}
</button
>
{% endif %}
{% endif %}
</div>
</div>
{% endif %}
{% endif %}
...
...
weblate/media/style.css
View file @
539d1f3e
...
@@ -75,7 +75,7 @@ nav li {
...
@@ -75,7 +75,7 @@ nav li {
width
:
4em
;
width
:
4em
;
text-align
:
center
;
text-align
:
center
;
}
}
.action-buttons
a
{
.action-buttons
button
{
width
:
20px
;
width
:
20px
;
height
:
20px
;
height
:
20px
;
}
}
...
...
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