Commit 2bdb46b9 authored by Weblate's avatar Weblate

Merge remote-tracking branch 'origin/master'

parents c7a5af92 a1e4cd81
...@@ -210,12 +210,11 @@ Projects ...@@ -210,12 +210,11 @@ Projects
Performs given operation on the VCS repository. Performs given operation on the VCS repository.
The response is same as for :http:get:`/api/projects/(string:project)/repository/`.
:query operation: Operation to perform, one of ``push``, ``pull``, ``commit``, ``reset`` :query operation: Operation to perform, one of ``push``, ``pull``, ``commit``, ``reset``
:param project: Project URL slug :param project: Project URL slug
:type project: string :type project: string
:>json boolean result: result of the operation
.. seealso:: .. seealso::
......
...@@ -93,9 +93,12 @@ class WeblateViewSet(viewsets.ReadOnlyModelViewSet): ...@@ -93,9 +93,12 @@ class WeblateViewSet(viewsets.ReadOnlyModelViewSet):
if not permission_check(request.user, project): if not permission_check(request.user, project):
raise PermissionDenied() raise PermissionDenied()
getattr(obj, method)(request) return getattr(obj, method)(request)
@detail_route(methods=['get', 'post']) @detail_route(
methods=['get', 'post'],
serializer_class=RepoRequestSerializer
)
def repository(self, request, **kwargs): def repository(self, request, **kwargs):
obj = self.get_object() obj = self.get_object()
...@@ -110,9 +113,14 @@ class WeblateViewSet(viewsets.ReadOnlyModelViewSet): ...@@ -110,9 +113,14 @@ class WeblateViewSet(viewsets.ReadOnlyModelViewSet):
serializer = RepoRequestSerializer(data=request.data) serializer = RepoRequestSerializer(data=request.data)
serializer.is_valid(raise_exception=True) serializer.is_valid(raise_exception=True)
self.repository_operation( result = self.repository_operation(
request, obj, project, serializer.validated_data['operation'] request, obj, project, serializer.validated_data['operation']
) )
return Response(
data={
'result': result
}
)
if not can_see_repository_status(request.user, project): if not can_see_repository_status(request.user, project):
raise PermissionDenied() raise PermissionDenied()
...@@ -175,7 +183,10 @@ class ComponentViewSet(MultipleFieldMixin, WeblateViewSet): ...@@ -175,7 +183,10 @@ class ComponentViewSet(MultipleFieldMixin, WeblateViewSet):
'project__source_language' 'project__source_language'
) )
@detail_route(methods=['get', 'post']) @detail_route(
methods=['get', 'post'],
serializer_class=LockRequestSerializer
)
def lock(self, request, **kwargs): def lock(self, request, **kwargs):
obj = self.get_object() obj = self.get_object()
......
...@@ -852,6 +852,8 @@ class SubProject(models.Model, PercentMixin, URLMixin, PathMixin): ...@@ -852,6 +852,8 @@ class SubProject(models.Model, PercentMixin, URLMixin, PathMixin):
if not from_link and not skip_push: if not from_link and not skip_push:
self.push_if_needed(request) self.push_if_needed(request)
return True
def handle_parse_error(self, error, translation=None): def handle_parse_error(self, error, translation=None):
"""Handler for parse error.""" """Handler for parse error."""
report_error(error, sys.exc_info()) report_error(error, sys.exc_info())
......
...@@ -665,12 +665,13 @@ class Translation(models.Model, URLMixin, PercentMixin, LoggerMixin): ...@@ -665,12 +665,13 @@ class Translation(models.Model, URLMixin, PercentMixin, LoggerMixin):
# If it is same as current one, we don't have to commit # If it is same as current one, we don't have to commit
if author == last or last is None: if author == last or last is None:
return return False
# Commit changes # Commit changes
self.git_commit( self.git_commit(
request, last, self.last_change, True, True, skip_push request, last, self.last_change, True, True, skip_push
) )
return True
def get_commit_message(self): def get_commit_message(self):
"""Formats commit message based on project configuration.""" """Formats commit message based on project configuration."""
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment