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
ec938c30
Commit
ec938c30
authored
Feb 10, 2016
by
Michal Čihař
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add API to commit pending
Signed-off-by:
Michal Čihař
<
michal@cihar.com
>
parent
6e282062
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
61 additions
and
2 deletions
+61
-2
weblate/trans/tests/test_hooks.py
weblate/trans/tests/test_hooks.py
+21
-0
weblate/trans/views/api.py
weblate/trans/views/api.py
+30
-2
weblate/urls.py
weblate/urls.py
+10
-0
No files found.
weblate/trans/tests/test_hooks.py
View file @
ec938c30
...
@@ -293,6 +293,27 @@ BITBUCKET_PAYLOAD_WEBHOOK = r'''
...
@@ -293,6 +293,27 @@ BITBUCKET_PAYLOAD_WEBHOOK = r'''
class
HooksViewTest
(
ViewTestCase
):
class
HooksViewTest
(
ViewTestCase
):
@
OverrideSettings
(
ENABLE_HOOKS
=
True
)
@
OverrideSettings
(
BACKGROUND_HOOKS
=
False
)
def
test_view_commit_hook_project
(
self
):
response
=
self
.
client
.
get
(
reverse
(
'hook-commit-project'
,
kwargs
=
{
'project'
:
self
.
subproject
.
project
.
slug
})
)
self
.
assertContains
(
response
,
'Commit performed'
)
@
OverrideSettings
(
ENABLE_HOOKS
=
True
)
@
OverrideSettings
(
BACKGROUND_HOOKS
=
False
)
def
test_view_commit_hook_subproject
(
self
):
response
=
self
.
client
.
get
(
reverse
(
'hook-commit-subproject'
,
kwargs
=
{
'project'
:
self
.
subproject
.
project
.
slug
,
'subproject'
:
self
.
subproject
.
slug
,
})
)
self
.
assertContains
(
response
,
'Commit performed'
)
@
OverrideSettings
(
ENABLE_HOOKS
=
True
)
@
OverrideSettings
(
ENABLE_HOOKS
=
True
)
@
OverrideSettings
(
BACKGROUND_HOOKS
=
False
)
@
OverrideSettings
(
BACKGROUND_HOOKS
=
False
)
def
test_view_hook_project
(
self
):
def
test_view_hook_project
(
self
):
...
...
weblate/trans/views/api.py
View file @
ec938c30
...
@@ -70,10 +70,10 @@ GITHUB_REPOS = (
...
@@ -70,10 +70,10 @@ GITHUB_REPOS = (
HOOK_HANDLERS
=
{}
HOOK_HANDLERS
=
{}
def
hook_response
():
def
hook_response
(
response
=
'Update triggered'
):
"""Generic okay hook response"""
"""Generic okay hook response"""
return
JsonResponse
(
return
JsonResponse
(
data
=
{
'status'
:
'success'
,
'message'
:
'Update triggered'
},
data
=
{
'status'
:
'success'
,
'message'
:
response
},
)
)
...
@@ -97,6 +97,34 @@ def perform_update(obj):
...
@@ -97,6 +97,34 @@ def perform_update(obj):
obj
.
do_update
()
obj
.
do_update
()
@
csrf_exempt
def
commit_subproject
(
request
,
project
,
subproject
):
'''
API hook for updating git repos.
'''
if
not
appsettings
.
ENABLE_HOOKS
:
return
HttpResponseNotAllowed
([])
obj
=
get_subproject
(
request
,
project
,
subproject
,
True
)
if
not
obj
.
project
.
enable_hooks
:
return
HttpResponseNotAllowed
([])
obj
.
commit_pending
(
None
)
return
hook_response
(
'Commit performed'
)
@
csrf_exempt
def
commit_project
(
request
,
project
):
'''
API hook for updating git repos.
'''
if
not
appsettings
.
ENABLE_HOOKS
:
return
HttpResponseNotAllowed
([])
obj
=
get_project
(
request
,
project
,
True
)
if
not
obj
.
enable_hooks
:
return
HttpResponseNotAllowed
([])
obj
.
commit_pending
(
None
)
return
hook_response
(
'Commit performed'
)
@
csrf_exempt
@
csrf_exempt
def
update_subproject
(
request
,
project
,
subproject
):
def
update_subproject
(
request
,
project
,
subproject
):
'''
'''
...
...
weblate/urls.py
View file @
ec938c30
...
@@ -472,6 +472,16 @@ urlpatterns = [
...
@@ -472,6 +472,16 @@ urlpatterns = [
weblate
.
trans
.
views
.
api
.
update_project
,
weblate
.
trans
.
views
.
api
.
update_project
,
name
=
'hook-project'
,
name
=
'hook-project'
,
),
),
url
(
r'^hooks/commit/'
+
SUBPROJECT
+
'$'
,
weblate
.
trans
.
views
.
api
.
commit_subproject
,
name
=
'hook-commit-subproject'
,
),
url
(
r'^hooks/commit/'
+
PROJECT
+
'$'
,
weblate
.
trans
.
views
.
api
.
commit_project
,
name
=
'hook-commit-project'
,
),
url
(
url
(
r'^hooks/github/$'
,
weblate
.
trans
.
views
.
api
.
vcs_service_hook
,
r'^hooks/github/$'
,
weblate
.
trans
.
views
.
api
.
vcs_service_hook
,
{
'service'
:
'github'
},
{
'service'
:
'github'
},
...
...
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