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
991ba12c
Commit
991ba12c
authored
Dec 18, 2012
by
Michal Čihař
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Various coding style improvements
parent
d4d128bf
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
101 additions
and
93 deletions
+101
-93
weblate/trans/views.py
weblate/trans/views.py
+101
-93
No files found.
weblate/trans/views.py
View file @
991ba12c
...
@@ -175,12 +175,12 @@ def show_check_project(request, name, project):
...
@@ -175,12 +175,12 @@ def show_check_project(request, name, project):
).
values_list
(
).
values_list
(
'checksum'
,
flat
=
True
'checksum'
,
flat
=
True
)
)
for
s
p
in
prj
.
subproject_set
.
all
():
for
s
ubproject
in
prj
.
subproject_set
.
all
():
lang
=
s
p
.
translation_set
.
all
()[
0
].
language
lang
=
s
uproject
.
translation_set
.
all
()[
0
].
language
res
=
Unit
.
objects
.
filter
(
res
=
Unit
.
objects
.
filter
(
checksum__in
=
checks
,
checksum__in
=
checks
,
translation__language
=
lang
,
translation__language
=
lang
,
translation__subproject
=
s
p
translation__subproject
=
s
uproject
).
values
(
).
values
(
'translation__subproject__slug'
,
'translation__subproject__slug'
,
'translation__subproject__project__slug'
'translation__subproject__project__slug'
...
@@ -248,7 +248,8 @@ def show_check_subproject(request, name, project, subproject):
...
@@ -248,7 +248,8 @@ def show_check_subproject(request, name, project, subproject):
).
count
()
).
count
()
if
res
>
0
:
if
res
>
0
:
source_checks
.
append
(
res
)
source_checks
.
append
(
res
)
return
render_to_response
(
'check_subproject.html'
,
return
render_to_response
(
'check_subproject.html'
,
RequestContext
(
request
,
{
RequestContext
(
request
,
{
'checks'
:
units
,
'checks'
:
units
,
'source_checks'
:
source_checks
,
'source_checks'
:
source_checks
,
...
@@ -321,7 +322,7 @@ def edit_dictionary(request, project, lang):
...
@@ -321,7 +322,7 @@ def edit_dictionary(request, project, lang):
))
))
else
:
else
:
form
=
WordForm
(
form
=
WordForm
(
initial
=
{
'source'
:
word
.
source
,
'target'
:
word
.
target
}
initial
=
{
'source'
:
word
.
source
,
'target'
:
word
.
target
}
)
)
return
render_to_response
(
'edit_dictionary.html'
,
RequestContext
(
request
,
{
return
render_to_response
(
'edit_dictionary.html'
,
RequestContext
(
request
,
{
...
@@ -393,6 +394,7 @@ def upload_dictionary(request, project, lang):
...
@@ -393,6 +394,7 @@ def upload_dictionary(request, project, lang):
kwargs
=
{
'project'
:
prj
.
slug
,
'lang'
:
lang
.
code
}
kwargs
=
{
'project'
:
prj
.
slug
,
'lang'
:
lang
.
code
}
))
))
def
download_dictionary
(
request
,
project
,
lang
):
def
download_dictionary
(
request
,
project
,
lang
):
'''
'''
Exports dictionary.
Exports dictionary.
...
@@ -433,11 +435,11 @@ def download_dictionary(request, project, lang):
...
@@ -433,11 +435,11 @@ def download_dictionary(request, project, lang):
site
=
Site
.
objects
.
get_current
()
site
=
Site
.
objects
.
get_current
()
store
.
updateheader
(
store
.
updateheader
(
add
=
True
,
add
=
True
,
language
=
lang
.
code
,
language
=
lang
.
code
,
x_generator
=
'Weblate %s'
%
weblate
.
VERSION
,
x_generator
=
'Weblate %s'
%
weblate
.
VERSION
,
project_id_version
=
'%s dictionary for %s'
%
(
lang
.
name
,
prj
.
name
),
project_id_version
=
'%s dictionary for %s'
%
(
lang
.
name
,
prj
.
name
),
language_team
=
'%s <http://%s%s>'
%
(
language_team
=
'%s <http://%s%s>'
%
(
lang
.
name
,
lang
.
name
,
site
.
domain
,
site
.
domain
,
reverse
(
'weblate.trans.views.show_dictionary'
,
kwargs
=
{
'project'
:
prj
.
slug
,
'lang'
:
lang
.
code
}),
reverse
(
'weblate.trans.views.show_dictionary'
,
kwargs
=
{
'project'
:
prj
.
slug
,
'lang'
:
lang
.
code
}),
...
@@ -462,10 +464,10 @@ def show_dictionary(request, project, lang):
...
@@ -462,10 +464,10 @@ def show_dictionary(request, project, lang):
form
=
WordForm
(
request
.
POST
)
form
=
WordForm
(
request
.
POST
)
if
form
.
is_valid
():
if
form
.
is_valid
():
Dictionary
.
objects
.
create
(
Dictionary
.
objects
.
create
(
project
=
prj
,
project
=
prj
,
language
=
lang
,
language
=
lang
,
source
=
form
.
cleaned_data
[
'source'
],
source
=
form
.
cleaned_data
[
'source'
],
target
=
form
.
cleaned_data
[
'target'
]
target
=
form
.
cleaned_data
[
'target'
]
)
)
return
HttpResponseRedirect
(
request
.
get_full_path
())
return
HttpResponseRedirect
(
request
.
get_full_path
())
else
:
else
:
...
@@ -610,9 +612,9 @@ def auto_translation(request, project, subproject, lang):
...
@@ -610,9 +612,9 @@ def auto_translation(request, project, subproject, lang):
# Create signle change object for whole merge
# Create signle change object for whole merge
if
change
is
None
:
if
change
is
None
:
change
=
Change
.
objects
.
create
(
change
=
Change
.
objects
.
create
(
unit
=
unit
,
unit
=
unit
,
translation
=
unit
.
translation
,
translation
=
unit
.
translation
,
user
=
request
.
user
user
=
request
.
user
)
)
# Save unit to backend
# Save unit to backend
unit
.
save_backend
(
request
,
False
,
False
)
unit
.
save_backend
(
request
,
False
,
False
)
...
@@ -970,9 +972,9 @@ def lock_project(request, project):
...
@@ -970,9 +972,9 @@ def lock_project(request, project):
obj
.
commit_pending
()
obj
.
commit_pending
()
for
s
p
in
obj
.
subproject_set
.
all
():
for
s
ubproject
in
obj
.
subproject_set
.
all
():
s
p
.
locked
=
True
s
ubproject
.
locked
=
True
s
p
.
save
()
s
ubproject
.
save
()
messages
.
info
(
messages
.
info
(
request
,
request
,
...
@@ -987,9 +989,9 @@ def lock_project(request, project):
...
@@ -987,9 +989,9 @@ def lock_project(request, project):
def
unlock_project
(
request
,
project
):
def
unlock_project
(
request
,
project
):
obj
=
get_object_or_404
(
Project
,
slug
=
project
)
obj
=
get_object_or_404
(
Project
,
slug
=
project
)
for
s
p
in
obj
.
subproject_set
.
all
():
for
s
ubproject
in
obj
.
subproject_set
.
all
():
s
p
.
locked
=
False
s
ubproject
.
locked
=
False
s
p
.
save
()
s
ubproject
.
save
()
messages
.
info
(
request
,
_
(
'Project is now open for translation updates.'
))
messages
.
info
(
request
,
_
(
'Project is now open for translation updates.'
))
...
@@ -1059,15 +1061,15 @@ def parse_search_url(request):
...
@@ -1059,15 +1061,15 @@ def parse_search_url(request):
# Pre-process search form
# Pre-process search form
if
request
.
method
==
'POST'
:
if
request
.
method
==
'POST'
:
s
=
SearchForm
(
request
.
POST
)
s
earch_form
=
SearchForm
(
request
.
POST
)
else
:
else
:
s
=
SearchForm
(
request
.
GET
)
s
earch_form
=
SearchForm
(
request
.
GET
)
if
s
.
is_valid
():
if
s
earch_form
.
is_valid
():
search_query
=
s
.
cleaned_data
[
'q'
]
search_query
=
s
earch_form
.
cleaned_data
[
'q'
]
search_exact
=
s
.
cleaned_data
[
'exact'
]
search_exact
=
s
earch_form
.
cleaned_data
[
'exact'
]
search_source
=
s
.
cleaned_data
[
'src'
]
search_source
=
s
earch_form
.
cleaned_data
[
'src'
]
search_target
=
s
.
cleaned_data
[
'tgt'
]
search_target
=
s
earch_form
.
cleaned_data
[
'tgt'
]
search_context
=
s
.
cleaned_data
[
'ctx'
]
search_context
=
s
earch_form
.
cleaned_data
[
'ctx'
]
search_url
=
'&q=%s&src=%s&tgt=%s&ctx=%s&exact=%s'
%
(
search_url
=
'&q=%s&src=%s&tgt=%s&ctx=%s&exact=%s'
%
(
search_query
,
search_query
,
bool2str
(
search_source
),
bool2str
(
search_source
),
...
@@ -1098,6 +1100,7 @@ def parse_search_url(request):
...
@@ -1098,6 +1100,7 @@ def parse_search_url(request):
search_url
search_url
)
)
def
get_filter_name
(
rqtype
,
search_query
):
def
get_filter_name
(
rqtype
,
search_query
):
'''
'''
Returns name of current filter.
Returns name of current filter.
...
@@ -1187,17 +1190,17 @@ def translate(request, project, subproject, lang):
...
@@ -1187,17 +1190,17 @@ def translate(request, project, subproject, lang):
))
))
# Create the suggestion
# Create the suggestion
sug
=
Suggestion
.
objects
.
create
(
sug
=
Suggestion
.
objects
.
create
(
target
=
join_plural
(
form
.
cleaned_data
[
'target'
]),
target
=
join_plural
(
form
.
cleaned_data
[
'target'
]),
checksum
=
unit
.
checksum
,
checksum
=
unit
.
checksum
,
language
=
unit
.
translation
.
language
,
language
=
unit
.
translation
.
language
,
project
=
unit
.
translation
.
subproject
.
project
,
project
=
unit
.
translation
.
subproject
.
project
,
user
=
user
)
user
=
user
)
# Record in change
# Record in change
Change
.
objects
.
create
(
Change
.
objects
.
create
(
unit
=
unit
,
unit
=
unit
,
action
=
Change
.
ACTION_SUGGESTION
,
action
=
Change
.
ACTION_SUGGESTION
,
translation
=
unit
.
translation
,
translation
=
unit
.
translation
,
user
=
user
user
=
user
)
)
# Invalidate counts cache
# Invalidate counts cache
unit
.
translation
.
invalidate_cache
(
'suggestions'
)
unit
.
translation
.
invalidate_cache
(
'suggestions'
)
...
@@ -1415,11 +1418,11 @@ def translate(request, project, subproject, lang):
...
@@ -1415,11 +1418,11 @@ def translate(request, project, subproject, lang):
# based on presumption we won't get too many results
# based on presumption we won't get too many results
targets
=
{}
targets
=
{}
res
=
[]
res
=
[]
for
s
in
secondary
:
for
lang
in
secondary
:
if
s
.
target
in
targets
:
if
lang
.
target
in
targets
:
continue
continue
targets
[
s
.
target
]
=
1
targets
[
lang
.
target
]
=
1
res
.
append
(
s
)
res
.
append
(
lang
)
secondary
=
res
secondary
=
res
# Prepare form
# Prepare form
...
@@ -1432,7 +1435,9 @@ def translate(request, project, subproject, lang):
...
@@ -1432,7 +1435,9 @@ def translate(request, project, subproject, lang):
total
=
obj
.
unit_set
.
all
().
count
()
total
=
obj
.
unit_set
.
all
().
count
()
filter_count
=
allunits
.
count
()
filter_count
=
allunits
.
count
()
return
render_to_response
(
'translate.html'
,
RequestContext
(
request
,
{
return
render_to_response
(
'translate.html'
,
RequestContext
(
request
,
{
'object'
:
obj
,
'object'
:
obj
,
'unit'
:
unit
,
'unit'
:
unit
,
'last_changes'
:
unit
.
change_set
.
all
()[:
10
],
'last_changes'
:
unit
.
change_set
.
all
()[:
10
],
...
@@ -1456,7 +1461,8 @@ def translate(request, project, subproject, lang):
...
@@ -1456,7 +1461,8 @@ def translate(request, project, subproject, lang):
'locked'
:
locked
,
'locked'
:
locked
,
'user_locked'
:
user_locked
,
'user_locked'
:
user_locked
,
'project_locked'
:
project_locked
,
'project_locked'
:
project_locked
,
}))
},
))
@
login_required
@
login_required
...
@@ -1473,18 +1479,18 @@ def comment(request, pk):
...
@@ -1473,18 +1479,18 @@ def comment(request, pk):
form
=
CommentForm
(
request
.
POST
)
form
=
CommentForm
(
request
.
POST
)
if
form
.
is_valid
():
if
form
.
is_valid
():
comment
=
Comment
.
objects
.
create
(
new_
comment
=
Comment
.
objects
.
create
(
user
=
request
.
user
,
user
=
request
.
user
,
checksum
=
obj
.
checksum
,
checksum
=
obj
.
checksum
,
project
=
obj
.
translation
.
subproject
.
project
,
project
=
obj
.
translation
.
subproject
.
project
,
comment
=
form
.
cleaned_data
[
'comment'
],
comment
=
form
.
cleaned_data
[
'comment'
],
language
=
lang
language
=
lang
)
)
Change
.
objects
.
create
(
Change
.
objects
.
create
(
unit
=
obj
,
unit
=
obj
,
action
=
Change
.
ACTION_COMMENT
,
action
=
Change
.
ACTION_COMMENT
,
translation
=
obj
.
translation
,
translation
=
obj
.
translation
,
user
=
request
.
user
user
=
request
.
user
)
)
# Invalidate counts cache
# Invalidate counts cache
...
@@ -1496,7 +1502,7 @@ def comment(request, pk):
...
@@ -1496,7 +1502,7 @@ def comment(request, pk):
# Notify subscribed users
# Notify subscribed users
subscriptions
=
Profile
.
objects
.
subscribed_new_comment
(
obj
.
translation
.
subproject
.
project
,
lang
,
request
.
user
)
subscriptions
=
Profile
.
objects
.
subscribed_new_comment
(
obj
.
translation
.
subproject
.
project
,
lang
,
request
.
user
)
for
subscription
in
subscriptions
:
for
subscription
in
subscriptions
:
subscription
.
notify_new_comment
(
obj
,
comment
)
subscription
.
notify_new_comment
(
obj
,
new_
comment
)
# Notify upstream
# Notify upstream
if
lang
is
None
and
obj
.
translation
.
subproject
.
report_source_bugs
!=
''
:
if
lang
is
None
and
obj
.
translation
.
subproject
.
report_source_bugs
!=
''
:
send_notification_email
(
send_notification_email
(
...
@@ -1506,7 +1512,7 @@ def comment(request, pk):
...
@@ -1506,7 +1512,7 @@ def comment(request, pk):
obj
.
translation
,
obj
.
translation
,
{
{
'unit'
:
obj
,
'unit'
:
obj
,
'comment'
:
comment
,
'comment'
:
new_
comment
,
'subproject'
:
obj
.
translation
.
subproject
,
'subproject'
:
obj
.
translation
.
subproject
,
}
}
)
)
...
@@ -1533,17 +1539,17 @@ def get_similar(request, unit_id):
...
@@ -1533,17 +1539,17 @@ def get_similar(request, unit_id):
'''
'''
unit
=
get_object_or_404
(
Unit
,
pk
=
int
(
unit_id
))
unit
=
get_object_or_404
(
Unit
,
pk
=
int
(
unit_id
))
similar
=
Unit
.
objects
.
similar
(
unit
)
similar
_units
=
Unit
.
objects
.
similar
(
unit
)
# distinct('target') works with Django 1.4 so let's emulate that
# distinct('target') works with Django 1.4 so let's emulate that
# based on presumption we won't get too many results
# based on presumption we won't get too many results
targets
=
{}
targets
=
{}
res
=
[]
res
=
[]
for
s
in
similar
:
for
s
imilar
in
similar_units
:
if
s
.
target
in
targets
:
if
s
imilar
.
target
in
targets
:
continue
continue
targets
[
s
.
target
]
=
1
targets
[
s
.
target
]
=
1
res
.
append
(
s
)
res
.
append
(
s
imilar
)
similar
=
res
similar
=
res
return
render_to_response
(
'js/similar.html'
,
RequestContext
(
request
,
{
return
render_to_response
(
'js/similar.html'
,
RequestContext
(
request
,
{
...
@@ -1669,12 +1675,14 @@ def not_found(request):
...
@@ -1669,12 +1675,14 @@ def not_found(request):
'''
'''
Error handler showing list of available projects.
Error handler showing list of available projects.
'''
'''
t
=
loader
.
get_template
(
'404.html'
)
template
=
loader
.
get_template
(
'404.html'
)
return
HttpResponseNotFound
(
t
.
render
(
RequestContext
(
request
,
{
return
HttpResponseNotFound
(
template
.
render
(
RequestContext
(
request
,
{
'request_path'
:
request
.
path
,
'request_path'
:
request
.
path
,
'title'
:
_
(
'Page Not Found'
),
'title'
:
_
(
'Page Not Found'
),
'projects'
:
Project
.
objects
.
all
(),
'projects'
:
Project
.
objects
.
all
(),
})))
}
)))
# Cache this page for one month, it should not really change much
# Cache this page for one month, it should not really change much
...
...
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