def lock_translation(request, project, subproject, lang): obj = get_translation(request, project, subproject, lang) if not can_lock_subproject(request.user, obj.subproject.project): raise PermissionDenied() if not obj.is_user_locked(request.user): obj.create_lock(request.user, True) messages.success(request, _('Translation is now locked for you.')) return redirect(obj)
def unlock_subproject(request, project, subproject): obj = get_subproject(request, project, subproject) if not can_lock_subproject(request.user, obj.project): raise PermissionDenied() obj.do_unlock(request.user) messages.success(request, _('Component is now open for translation updates.')) return redirect(obj)
def unlock_project(request, project): obj = get_project(request, project) if not can_lock_subproject(request.user, obj): raise PermissionDenied() for subproject in obj.subproject_set.all(): subproject.do_unlock(request.user) messages.success(request, _('Project is now open for translation updates.')) return redirect(obj)
def unlock_subproject(request, project, subproject): obj = get_subproject(request, project, subproject) if not can_lock_subproject(request.user, obj.project): raise PermissionDenied() obj.do_unlock(request.user) messages.success( request, _('Component is now open for translation updates.') ) return redirect(obj)
def lock_subproject(request, project, subproject): obj = get_subproject(request, project, subproject) if not can_lock_subproject(request.user, obj.project): raise PermissionDenied() obj.commit_pending(request) obj.do_lock(request.user) messages.success(request, _('Component is now locked for translation updates!')) return redirect(obj)
def unlock_project(request, project): obj = get_project(request, project) if not can_lock_subproject(request.user, obj): raise PermissionDenied() for subproject in obj.subproject_set.all(): subproject.do_unlock(request.user) messages.success( request, _('Project is now open for translation updates.') ) return redirect(obj)
def lock_project(request, project): obj = get_project(request, project) if not can_lock_subproject(request.user, obj): raise PermissionDenied() obj.commit_pending(request) for subproject in obj.subproject_set.all(): subproject.do_lock(request.user) messages.success( request, _('All components are now locked for translation updates!')) return redirect(obj)
def lock_subproject(request, project, subproject): obj = get_subproject(request, project, subproject) if not can_lock_subproject(request.user, obj.project): raise PermissionDenied() obj.commit_pending(request) obj.do_lock(request.user) messages.success( request, _('Component is now locked for translation updates!') ) return redirect(obj)
def lock(self, request, **kwargs): obj = self.get_object() if request.method == 'POST': if not can_lock_subproject(request.user, obj.project): raise PermissionDenied() serializer = LockRequestSerializer(data=request.data) serializer.is_valid(raise_exception=True) if serializer.validated_data['lock']: obj.do_lock(request.user) else: obj.do_unlock(request.user) return Response(data=LockSerializer(obj).data)
def lock_project(request, project): obj = get_project(request, project) if not can_lock_subproject(request.user, obj): raise PermissionDenied() obj.commit_pending(request) for subproject in obj.subproject_set.all(): subproject.do_lock(request.user) messages.success( request, _('All components are now locked for translation updates!') ) return redirect(obj)