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
6ef69dc9
Commit
6ef69dc9
authored
Mar 27, 2012
by
Michal Čihař
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/master'
parents
6ea8c4a2
a585cb14
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
55 additions
and
16 deletions
+55
-16
docs/config.rst
docs/config.rst
+6
-0
settings.py
settings.py
+3
-0
trans/admin.py
trans/admin.py
+1
-2
trans/management/commands/updategit.py
trans/management/commands/updategit.py
+3
-6
trans/models.py
trans/models.py
+42
-8
No files found.
docs/config.rst
View file @
6ef69dc9
...
...
@@ -18,6 +18,12 @@ All settings are stored in :file:`settings.py` (as usual for Django).
Path where Weblate will store cloned Git repositories. Defaults to
:file:`repos` subdirectory.
.. envvar:: LAZY_COMMITS
Delay creating Git commits until this is necessary. This heavily reduces
number of commits generated by Weblate at expense of temporarily not being
able to merge some changes as they are not yet committed.
.. envvar:: MT_APERTIUM_KEY
API key for Apertium Web Service, you can register at http://api.apertium.org/register.jsp
...
...
settings.py
View file @
6ef69dc9
...
...
@@ -258,5 +258,8 @@ NEARBY_MESSAGES = 5
# Minimal number of similar messages to show
SIMILAR_MESSAGES
=
5
# Enable lazy commits
LAZY_COMMITS
=
True
# Where to put Whoosh index
WHOOSH_INDEX
=
os
.
path
.
join
(
WEB_ROOT
,
'whoosh-index'
)
trans/admin.py
View file @
6ef69dc9
...
...
@@ -17,8 +17,7 @@ class SubProjectAdmin(admin.ModelAdmin):
def
update_from_git
(
self
,
request
,
queryset
):
for
s
in
queryset
:
s
.
update_branch
()
s
.
create_translations
()
s
.
do_update
()
self
.
message_user
(
request
,
"Updated %d git repos."
%
queryset
.
count
())
def
update_checks
(
self
,
request
,
queryset
):
...
...
trans/management/commands/updategit.py
View file @
6ef69dc9
...
...
@@ -16,17 +16,14 @@ class Command(BaseCommand):
def
handle
(
self
,
*
args
,
**
options
):
if
options
[
'all'
]:
for
s
in
SubProject
.
objects
.
all
():
s
.
update_branch
()
s
.
create_translations
()
s
.
do_update
()
for
arg
in
args
:
parts
=
arg
.
split
(
'/'
)
if
len
(
parts
)
==
2
:
prj
,
subprj
=
parts
s
=
SubProject
.
objects
.
get
(
slug
=
subprj
,
project__slug
=
prj
)
s
.
update_branch
()
s
.
create_translations
()
s
.
do_update
()
else
:
for
s
in
SubProject
.
objects
.
filter
(
project__slug
=
parts
[
0
]):
s
.
update_branch
()
s
.
create_translations
()
s
.
do_update
()
trans/models.py
View file @
6ef69dc9
...
...
@@ -151,6 +151,21 @@ class SubProject(models.Model):
gitrepo
.
git
.
checkout
(
self
.
branch
)
del
gitrepo
def
do_update
(
self
):
'''
Wrapper for doing repository update and pushing them to translations.
'''
self
.
check_commit_needed
()
self
.
update_branch
()
self
.
create_translations
()
def
check_commit_needed
(
self
):
'''
Checks whether there is any translation which needs commit.
'''
for
translation
in
self
.
translation_set
.
all
():
translation
.
check_commit_needed
(
None
)
def
update_branch
(
self
):
'''
Updates current branch to match remote (if possible).
...
...
@@ -209,6 +224,7 @@ class SubProject(models.Model):
def
save
(
self
,
*
args
,
**
kwargs
):
self
.
configure_repo
()
self
.
configure_branch
()
self
.
check_commit_needed
()
self
.
update_branch
()
super
(
SubProject
,
self
).
save
(
*
args
,
**
kwargs
)
...
...
@@ -357,11 +373,24 @@ class Translation(models.Model):
self
.
revision
=
blob_hash
self
.
save
()
def
get_author_name
(
self
,
request
):
full_name
=
request
.
user
.
get_full_name
()
def
get_last_author
(
self
):
try
:
change
=
self
.
change_set
.
order_by
(
'-timestamp'
)[
0
]
return
self
.
get_author_name
(
change
.
user
)
except
:
return
None
def
check_commit_needed
(
self
,
author
):
last
=
self
.
get_last_author
()
if
author
==
last
or
last
is
None
:
return
self
.
git_commit
(
last
,
True
)
def
get_author_name
(
self
,
user
):
full_name
=
user
.
get_full_name
()
if
full_name
==
''
:
full_name
=
request
.
user
.
username
return
'%s <%s>'
%
(
full_name
,
request
.
user
.
email
)
full_name
=
user
.
username
return
'%s <%s>'
%
(
full_name
,
user
.
email
)
def
__git_commit
(
self
,
gitrepo
,
author
):
'''
...
...
@@ -373,7 +402,7 @@ class Translation(models.Model):
m
=
settings
.
COMMIT_MESSAGE
)
def
git_commit
(
self
,
author
):
def
git_commit
(
self
,
author
,
force_commit
=
False
):
'''
Wrapper for commiting translation to git.
'''
...
...
@@ -382,6 +411,9 @@ class Translation(models.Model):
if
status
==
''
:
# No changes to commit
return
False
if
not
force_commit
and
settings
.
LAZY_COMMITS
:
logger
.
info
(
'Delaying commiting %s as %s'
,
self
.
filename
,
author
)
return
False
logger
.
info
(
'Commiting %s as %s'
,
self
.
filename
,
author
)
try
:
self
.
__git_commit
(
gitrepo
,
author
)
...
...
@@ -416,7 +448,8 @@ class Translation(models.Model):
# We should have only one match
break
if
need_save
:
author
=
self
.
get_author_name
(
request
)
author
=
self
.
get_author_name
(
request
.
user
)
self
.
check_commit_needed
(
author
)
if
hasattr
(
store
,
'updateheader'
):
po_revision_date
=
datetime
.
now
().
strftime
(
'%Y-%m-%d %H:%M'
)
+
poheader
.
tzstring
()
...
...
@@ -480,8 +513,9 @@ class Translation(models.Model):
if
not
overwrite
and
unit1
.
istranslated
():
continue
unit1
.
merge
(
unit2
,
overwrite
=
True
,
comments
=
False
)
self
.
check_commit_needed
(
author
)
store1
.
save
()
ret
=
self
.
git_commit
(
author
)
ret
=
self
.
git_commit
(
author
,
True
)
self
.
check_sync
()
return
ret
...
...
@@ -493,7 +527,7 @@ class Translation(models.Model):
fileobj
.
mode
=
"r"
store2
=
factory
.
getobject
(
fileobj
)
if
author
is
None
:
author
=
self
.
get_author_name
(
request
)
author
=
self
.
get_author_name
(
request
.
user
)
ret
=
False
...
...
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