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
9ca6d750
Commit
9ca6d750
authored
May 07, 2014
by
Michal Čihař
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Split source string manipulations to separate file
Signed-off-by:
Michal Čihař
<
michal@cihar.com
>
parent
d475dcbb
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
107 additions
and
73 deletions
+107
-73
weblate/trans/forms.py
weblate/trans/forms.py
+8
-0
weblate/trans/views/basic.py
weblate/trans/views/basic.py
+0
-71
weblate/trans/views/source.py
weblate/trans/views/source.py
+97
-0
weblate/urls.py
weblate/urls.py
+2
-2
No files found.
weblate/trans/forms.py
View file @
9ca6d750
...
@@ -27,6 +27,7 @@ from django.utils.encoding import smart_unicode
...
@@ -27,6 +27,7 @@ from django.utils.encoding import smart_unicode
from
django.forms
import
ValidationError
from
django.forms
import
ValidationError
from
weblate.lang.models
import
Language
from
weblate.lang.models
import
Language
from
weblate.trans.models
import
Unit
from
weblate.trans.models
import
Unit
from
weblate.trans.models.source
import
PRIORITY_CHOICES
from
urllib
import
urlencode
from
urllib
import
urlencode
import
weblate
import
weblate
...
@@ -496,3 +497,10 @@ class NewLanguageForm(forms.Form):
...
@@ -496,3 +497,10 @@ class NewLanguageForm(forms.Form):
super
(
NewLanguageForm
,
self
).
__init__
(
*
args
,
**
kwargs
)
super
(
NewLanguageForm
,
self
).
__init__
(
*
args
,
**
kwargs
)
choices
=
[(
l
.
code
,
l
.
__unicode__
())
for
l
in
Language
.
objects
.
all
()]
choices
=
[(
l
.
code
,
l
.
__unicode__
())
for
l
in
Language
.
objects
.
all
()]
self
.
fields
[
'lang'
].
choices
=
choices
self
.
fields
[
'lang'
].
choices
=
choices
class
PriorityForm
(
forms
.
Form
):
priority
=
forms
.
ChoiceField
}(
label
=
_
(
'Priority'
),
choices
=
PRIORITY_CHOICES
)
weblate/trans/views/basic.py
View file @
9ca6d750
...
@@ -20,7 +20,6 @@
...
@@ -20,7 +20,6 @@
from
django.shortcuts
import
render
,
redirect
from
django.shortcuts
import
render
,
redirect
from
django.utils.translation
import
ugettext
as
_
from
django.utils.translation
import
ugettext
as
_
from
django.http
import
Http404
from
django.contrib.auth.decorators
import
login_required
from
django.contrib.auth.decorators
import
login_required
from
django.contrib
import
messages
from
django.contrib
import
messages
from
django.db.models
import
Sum
,
Count
,
Q
from
django.db.models
import
Sum
,
Count
,
Q
...
@@ -277,76 +276,6 @@ def show_subproject(request, project, subproject):
...
@@ -277,76 +276,6 @@ def show_subproject(request, project, subproject):
)
)
def
review_source
(
request
,
project
,
subproject
):
"""
Listing of source strings to review.
"""
obj
=
get_subproject
(
request
,
project
,
subproject
)
# Grab first translation in subproject
# (this assumes all have same source strings)
try
:
source
=
obj
.
translation_set
.
all
()[
0
]
except
Translation
.
DoesNotExist
:
raise
Http404
(
'No translation exists in this subproject.'
)
# Grab search type and page number
rqtype
=
request
.
GET
.
get
(
'type'
,
'all'
)
limit
=
request
.
GET
.
get
(
'limit'
,
50
)
page
=
request
.
GET
.
get
(
'page'
,
1
)
ignored
=
'ignored'
in
request
.
GET
# Filter units:
sources
=
source
.
unit_set
.
filter_type
(
rqtype
,
source
,
ignored
)
paginator
=
Paginator
(
sources
,
limit
)
try
:
sources
=
paginator
.
page
(
page
)
except
PageNotAnInteger
:
# If page is not an integer, deliver first page.
sources
=
paginator
.
page
(
1
)
except
EmptyPage
:
# If page is out of range (e.g. 9999), deliver last page of results.
sources
=
paginator
.
page
(
paginator
.
num_pages
)
return
render
(
request
,
'source-review.html'
,
{
'object'
:
obj
,
'source'
:
source
,
'sources'
:
sources
,
'rqtype'
:
rqtype
,
'title'
:
_
(
'Review source strings in %s'
)
%
obj
.
__unicode__
(),
}
)
def
show_source
(
request
,
project
,
subproject
):
"""
Show source strings summary and checks.
"""
obj
=
get_subproject
(
request
,
project
,
subproject
)
# Grab first translation in subproject
# (this assumes all have same source strings)
try
:
source
=
obj
.
translation_set
.
all
()[
0
]
except
Translation
.
DoesNotExist
:
raise
Http404
(
'No translation exists in this subproject.'
)
return
render
(
request
,
'source.html'
,
{
'object'
:
obj
,
'source'
:
source
,
'title'
:
_
(
'Source strings in %s'
)
%
obj
.
__unicode__
(),
}
)
def
show_translation
(
request
,
project
,
subproject
,
lang
):
def
show_translation
(
request
,
project
,
subproject
,
lang
):
obj
=
get_translation
(
request
,
project
,
subproject
,
lang
)
obj
=
get_translation
(
request
,
project
,
subproject
,
lang
)
last_changes
=
Change
.
objects
.
prefetch
().
filter
(
last_changes
=
Change
.
objects
.
prefetch
().
filter
(
...
...
weblate/trans/views/source.py
0 → 100644
View file @
9ca6d750
# -*- coding: utf-8 -*-
#
# Copyright © 2012 - 2014 Michal Čihař <michal@cihar.com>
#
# This file is part of Weblate <http://weblate.org/>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
from
django.http
import
Http404
from
django.core.paginator
import
Paginator
,
EmptyPage
,
PageNotAnInteger
from
django.shortcuts
import
render
from
django.utils.translation
import
ugettext
as
_
from
weblate.trans.views.helper
import
get_subproject
from
weblate.trans.models
import
Translation
def
review_source
(
request
,
project
,
subproject
):
"""
Listing of source strings to review.
"""
obj
=
get_subproject
(
request
,
project
,
subproject
)
# Grab first translation in subproject
# (this assumes all have same source strings)
try
:
source
=
obj
.
translation_set
.
all
()[
0
]
except
Translation
.
DoesNotExist
:
raise
Http404
(
'No translation exists in this subproject.'
)
# Grab search type and page number
rqtype
=
request
.
GET
.
get
(
'type'
,
'all'
)
limit
=
request
.
GET
.
get
(
'limit'
,
50
)
page
=
request
.
GET
.
get
(
'page'
,
1
)
ignored
=
'ignored'
in
request
.
GET
# Filter units:
sources
=
source
.
unit_set
.
filter_type
(
rqtype
,
source
,
ignored
)
paginator
=
Paginator
(
sources
,
limit
)
try
:
sources
=
paginator
.
page
(
page
)
except
PageNotAnInteger
:
# If page is not an integer, deliver first page.
sources
=
paginator
.
page
(
1
)
except
EmptyPage
:
# If page is out of range (e.g. 9999), deliver last page of results.
sources
=
paginator
.
page
(
paginator
.
num_pages
)
return
render
(
request
,
'source-review.html'
,
{
'object'
:
obj
,
'source'
:
source
,
'sources'
:
sources
,
'rqtype'
:
rqtype
,
'title'
:
_
(
'Review source strings in %s'
)
%
obj
.
__unicode__
(),
}
)
def
show_source
(
request
,
project
,
subproject
):
"""
Show source strings summary and checks.
"""
obj
=
get_subproject
(
request
,
project
,
subproject
)
# Grab first translation in subproject
# (this assumes all have same source strings)
try
:
source
=
obj
.
translation_set
.
all
()[
0
]
except
Translation
.
DoesNotExist
:
raise
Http404
(
'No translation exists in this subproject.'
)
return
render
(
request
,
'source.html'
,
{
'object'
:
obj
,
'source'
:
source
,
'title'
:
_
(
'Source strings in %s'
)
%
obj
.
__unicode__
(),
}
)
weblate/urls.py
View file @
9ca6d750
...
@@ -131,12 +131,12 @@ urlpatterns = patterns(
...
@@ -131,12 +131,12 @@ urlpatterns = patterns(
),
),
url
(
url
(
r'^projects/'
+
SUBPROJECT
+
'source/$'
,
r'^projects/'
+
SUBPROJECT
+
'source/$'
,
'weblate.trans.views.
basic
.show_source'
,
'weblate.trans.views.
source
.show_source'
,
name
=
'show_source'
,
name
=
'show_source'
,
),
),
url
(
url
(
r'^projects/'
+
SUBPROJECT
+
'source/review/$'
,
r'^projects/'
+
SUBPROJECT
+
'source/review/$'
,
'weblate.trans.views.
basic
.review_source'
,
'weblate.trans.views.
source
.review_source'
,
name
=
'review_source'
,
name
=
'review_source'
,
),
),
...
...
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