diff --git a/apps/develop/tasks.py b/apps/develop/tasks.py index c4610ae8..1e165106 100755 --- a/apps/develop/tasks.py +++ b/apps/develop/tasks.py @@ -29,6 +29,13 @@ def reload_server_git(): return completed +@shared_task +def reload_client_git(): + command = 'bash {}/git_client.sh'.format(SH_PATH) + completed = subprocess.run(command, shell=True, capture_output=True, text=True) + return completed + + @shared_task def reload_server_only(): command = 'echo "{}" | sudo -S service supervisor reload'.format(SD_PWD) diff --git a/apps/develop/urls.py b/apps/develop/urls.py index 5f7d21db..2c581f39 100755 --- a/apps/develop/urls.py +++ b/apps/develop/urls.py @@ -1,11 +1,12 @@ from django.urls import path -from apps.develop.views import BackupDatabase, BackupMedia, ReloadServerGit, ReloadServerOnly +from apps.develop.views import BackupDatabase, BackupMedia, ReloadClientGit, ReloadServerGit, ReloadServerOnly API_BASE_URL = 'api/develop/' HTML_BASE_URL = 'develop/' urlpatterns = [ path(API_BASE_URL + 'reload_server_git/', ReloadServerGit.as_view()), + path(API_BASE_URL + 'reload_client_git/', ReloadClientGit.as_view()), path(API_BASE_URL + 'reload_server_only/', ReloadServerOnly.as_view()), path(API_BASE_URL + 'backup_database/', BackupDatabase.as_view()), path(API_BASE_URL + 'backup_media/', BackupMedia.as_view()) diff --git a/apps/develop/views.py b/apps/develop/views.py index 0c020328..74223bdd 100755 --- a/apps/develop/views.py +++ b/apps/develop/views.py @@ -1,7 +1,7 @@ from rest_framework.views import APIView from rest_framework.permissions import IsAdminUser from rest_framework.response import Response -from apps.develop.tasks import backup_database, backup_media, reload_server_git, reload_server_only +from apps.develop.tasks import backup_database, backup_media, reload_client_git, reload_server_git, reload_server_only from rest_framework.exceptions import APIException # Create your views here. @@ -23,6 +23,23 @@ class ReloadServerGit(APIView): raise APIException(completed.stdout) +class ReloadClientGit(APIView): + authentication_classes = [] + permission_classes = [] + + def post(self, request): + """ + 拉取前端代码并打包 + + 拉取前端代码并打包 + """ + completed = reload_client_git() + if completed.returncode == 0: + return Response() + else: + raise APIException(completed.stdout) + + class ReloadServerOnly(APIView): permission_classes = [IsAdminUser] diff --git a/server/urls.py b/server/urls.py index 2dfb5da8..2a787222 100755 --- a/server/urls.py +++ b/server/urls.py @@ -38,7 +38,7 @@ urlpatterns = [ # django后台 path('django/doc/', include('django.contrib.admindocs.urls')), path('django/', admin.site.urls), - path('api-auth/', include('rest_framework.urls')), + path('django/api-auth/', include('rest_framework.urls')), # api path('', include('apps.auth1.urls')),