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
df0f4570
Commit
df0f4570
authored
Sep 10, 2015
by
Michal Čihař
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add hook after adding new translation.
Issue #840 Signed-off-by:
Michal Čihař
<
michal@cihar.com
>
parent
8ebeab8f
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
77 additions
and
5 deletions
+77
-5
docs/admin/config.rst
docs/admin/config.rst
+12
-0
docs/admin/continuous.rst
docs/admin/continuous.rst
+2
-2
docs/admin/projects.rst
docs/admin/projects.rst
+4
-0
docs/changes.rst
docs/changes.rst
+1
-0
weblate/appsettings.py
weblate/appsettings.py
+4
-0
weblate/trans/migrations/0042_auto_20150910_0854.py
weblate/trans/migrations/0042_auto_20150910_0854.py
+19
-0
weblate/trans/models/__init__.py
weblate/trans/models/__init__.py
+7
-2
weblate/trans/models/subproject.py
weblate/trans/models/subproject.py
+20
-1
weblate/trans/scripts.py
weblate/trans/scripts.py
+7
-0
weblate/trans/signals.py
weblate/trans/signals.py
+1
-0
No files found.
docs/admin/config.rst
View file @
df0f4570
...
...
@@ -440,6 +440,18 @@ information about Piwik see <http://piwik.org/>.
.. seealso:: :setting:`PIWIK_SITE_ID`
.. setting:: POST_ADD_SCRIPTS
POST_ADD_SCRIPTS
----------------
.. versionadded:: 2.3
List of scripts which are allowed as post add scripts. The script needs to be
later enabled in the :ref:`component`.
.. seealso:: :ref:`processing`
.. setting:: POST_UPDATE_SCRIPTS
POST_UPDATE_SCRIPTS
...
...
docs/admin/continuous.rst
View file @
df0f4570
...
...
@@ -217,8 +217,8 @@ Processing repository with scripts
You can customize way how Weblate manipulates with repository by set of
scripts. These include :guilabel:`Post-update script`, :guilabel:`Pre-commit
script`, :guilabel:`Post-commit script`
and :guilabel:`Post-push
script` and
are briefly described in :ref:`component`.
script`, :guilabel:`Post-commit script`
, :guilabel:`Post-add
script` and
:guilabel:`Post-push script` and
are briefly described in :ref:`component`.
Their naming quite clearly tells when given script is executed. The commit
related scripts always get one parameter with full path to the translation file
...
...
docs/admin/projects.rst
View file @
df0f4570
...
...
@@ -208,6 +208,10 @@ Post-push script
One of scripts defined in :setting:`POST_PUSH_SCRIPTS` which is executed
after push to remote repository. This can be used to generate notify external
parties about the change in repository (i.e. create pull request).
Post-add script
One of scripts defined in :setting:`POST_ADD_SCRIPTS` which is executed
when new translation has been added. This can be used to adjust additional
files in the repository when adding new translation.
Additional commit file
Additional file to include in commit, usually this one is generated by pre
commit script described above.
...
...
docs/changes.rst
View file @
df0f4570
...
...
@@ -34,6 +34,7 @@ Released on ? 2015.
* Commit pending changes on account removal.
* Add management command to change site name.
* Add option to confiugure default committer.
* Add hook after adding new translation.
weblate 2.3
-----------
...
...
weblate/appsettings.py
View file @
df0f4570
...
...
@@ -159,6 +159,10 @@ POST_PUSH_SCRIPTS = getvalue('POST_PUSH_SCRIPTS', ())
POST_PUSH_SCRIPT_CHOICES
=
[
(
script
,
get_script_name
(
script
))
for
script
in
POST_PUSH_SCRIPTS
]
+
[(
''
,
''
)]
POST_ADD_SCRIPTS
=
getvalue
(
'POST_ADD_SCRIPTS'
,
())
POST_ADD_SCRIPT_CHOICES
=
[
(
script
,
get_script_name
(
script
))
for
script
in
POST_ADD_SCRIPTS
]
+
[(
''
,
''
)]
# Font for charts and widgets
TTF_PATH
=
getvalue
(
'TTF_PATH'
,
os
.
path
.
join
(
BASE_DIR
,
'ttf'
))
...
...
weblate/trans/migrations/0042_auto_20150910_0854.py
0 → 100644
View file @
df0f4570
# -*- coding: utf-8 -*-
from
__future__
import
unicode_literals
from
django.db
import
models
,
migrations
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'trans'
,
'0041_auto_20150819_1457'
),
]
operations
=
[
migrations
.
AddField
(
model_name
=
'subproject'
,
name
=
'post_add_script'
,
field
=
models
.
CharField
(
default
=
b''
,
choices
=
[(
b''
,
b''
)],
max_length
=
200
,
blank
=
True
,
help_text
=
'Script to be executed after adding new translation, please check documentation for more details.'
,
verbose_name
=
'Post-add script'
),
),
]
weblate/trans/models/__init__.py
View file @
df0f4570
...
...
@@ -39,11 +39,11 @@ from weblate.trans.models.advertisement import Advertisement
from
weblate.trans.models.whiteboard
import
WhiteboardMessage
from
weblate.trans.signals
import
(
vcs_post_push
,
vcs_post_update
,
vcs_pre_commit
,
vcs_post_commit
,
user_pre_delete
,
user_pre_delete
,
translation_post_add
,
)
from
weblate.trans.scripts
import
(
run_post_push_script
,
run_post_update_script
,
run_pre_commit_script
,
run_post_commit_script
,
run_post_commit_script
,
run_post_add_script
,
)
__all__
=
[
...
...
@@ -227,6 +227,11 @@ def post_commit(sender, translation, **kwargs):
run_post_commit_script
(
translation
.
subproject
,
translation
.
get_filename
())
@
receiver
(
translation_post_add
)
def
post_add
(
sender
,
translation
,
**
kwargs
):
run_post_add_script
(
translation
.
subproject
,
translation
.
get_filename
())
@
receiver
(
user_pre_delete
)
def
user_commit_pending
(
sender
,
instance
,
**
kwargs
):
"""Commit pending changes for user on account removal."""
...
...
weblate/trans/models/subproject.py
View file @
df0f4570
...
...
@@ -40,7 +40,9 @@ from weblate.trans.fields import RegexField
from
weblate.trans.util
import
(
is_repo_link
,
get_site_url
,
cleanup_repo_url
,
cleanup_path
,
report_error
,
)
from
weblate.trans.signals
import
vcs_post_push
,
vcs_post_update
from
weblate.trans.signals
import
(
vcs_post_push
,
vcs_post_update
,
translation_post_add
)
from
weblate.trans.vcs
import
RepositoryException
,
VCS_REGISTRY
,
VCS_CHOICES
from
weblate.trans.models.translation
import
Translation
from
weblate.trans.validators
import
(
...
...
@@ -52,6 +54,7 @@ from weblate.lang.models import Language
from
weblate.appsettings
import
(
PRE_COMMIT_SCRIPT_CHOICES
,
POST_UPDATE_SCRIPT_CHOICES
,
POST_COMMIT_SCRIPT_CHOICES
,
POST_PUSH_SCRIPT_CHOICES
,
POST_ADD_SCRIPT_CHOICES
,
HIDE_REPO_CREDENTIALS
,
DEFAULT_COMMITER_EMAIL
,
DEFAULT_COMMITER_NAME
,
)
...
...
@@ -266,6 +269,18 @@ class SubProject(models.Model, PercentMixin, URLMixin, PathMixin):
'please check documentation for more details.'
),
)
post_add_script
=
models
.
CharField
(
verbose_name
=
ugettext_lazy
(
'Post-add script'
),
max_length
=
200
,
default
=
''
,
blank
=
True
,
choices
=
POST_ADD_SCRIPT_CHOICES
,
help_text
=
ugettext_lazy
(
'Script to be executed after adding new translation, '
'please check documentation for more details.'
),
)
locked
=
models
.
BooleanField
(
verbose_name
=
ugettext_lazy
(
'Locked'
),
...
...
@@ -1476,6 +1491,10 @@ class SubProject(models.Model, PercentMixin, URLMixin, PathMixin):
language_code
=
language
.
code
,
commit_message
=
'Created new translation.'
)
translation_post_add
.
send
(
sender
=
self
.
__class__
,
translation
=
translation
)
translation
.
git_commit
(
request
,
translation
.
get_author_name
(
request
.
user
),
...
...
weblate/trans/scripts.py
View file @
df0f4570
...
...
@@ -57,6 +57,13 @@ def run_post_commit_script(component, filename):
run_hook
(
component
,
component
.
post_commit_script
,
filename
)
def
run_post_add_script
(
component
,
filename
):
"""
Post add hook
"""
run_hook
(
component
,
component
.
post_add_script
,
filename
)
def
run_hook
(
component
,
script
,
*
args
):
"""
Generic script hook executor.
...
...
weblate/trans/signals.py
View file @
df0f4570
...
...
@@ -25,4 +25,5 @@ vcs_post_push = Signal(providing_args=['subproject'])
vcs_post_update
=
Signal
(
providing_args
=
[
'subproject'
])
vcs_pre_commit
=
Signal
(
providing_args
=
[
'translation'
])
vcs_post_commit
=
Signal
(
providing_args
=
[
'translation'
])
translation_post_add
=
Signal
(
providing_args
=
[
'translation'
])
user_pre_delete
=
Signal
()
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