Projects
Eulaceura:Factory
ostree_assembly
_service:obs_scm:0001-support-upload-cfgs.patch
Sign Up
Log In
Username
Password
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File _service:obs_scm:0001-support-upload-cfgs.patch of Package ostree_assembly
From 0e7512ec48b196391dd054e5155a458e986436fb Mon Sep 17 00:00:00 2001 From: mazhiguo <mazhiguo@kylinsec.com.cn> Date: Wed, 24 May 2023 09:37:52 +0800 Subject: [PATCH] support upload cfgs --- ostree_assembly/app/ostree_cfg_edit.py | 15 ++++++ .../app/templates/version_ostree.html | 47 +++++++++++++++++++ ostree_assembly/app/urls.py | 1 + 3 files changed, 63 insertions(+) diff --git a/ostree_assembly/app/ostree_cfg_edit.py b/ostree_assembly/app/ostree_cfg_edit.py index 53f3ea1..37ea463 100644 --- a/ostree_assembly/app/ostree_cfg_edit.py +++ b/ostree_assembly/app/ostree_cfg_edit.py @@ -582,3 +582,18 @@ def ostree_download(req): messages.success(req, '该版本不存在') return redirect('ostree') +def ostree_upload(req): + ostid = int(req.POST.get('ostree_id')) + cfgname = str(req.POST.get('file_name')) + + changelog = req.POST.get('changelog') + version_id = OStreeVer.objects.filter(id=ostid) + upload_file = req.FILES.get('cfg-file', None) + + + file_path = _get_cfg_path(ostid, cfgname) + + with open(file_path, 'wb+') as fr: + data = upload_file.file.read() + fr.write(data) + return redirect('ostree') diff --git a/ostree_assembly/app/templates/version_ostree.html b/ostree_assembly/app/templates/version_ostree.html index 64506ab..df94f95 100644 --- a/ostree_assembly/app/templates/version_ostree.html +++ b/ostree_assembly/app/templates/version_ostree.html @@ -131,6 +131,7 @@ function sendUpdateid(idStr) { $('#update_id').val(idStr); + $('#ostree_id').val(idStr); } function showchangelogs(idStr) { @@ -226,6 +227,11 @@ location.href = "{% url 'ostree_download' %}?cfgname="+cfgname+"&ostid="+ostid; } + function ost_upload() { + var cfgname = this.name; + var ostid = $("input[name='update_id']").val(); + $('#file_name').val(cfgname); + } </script> {% endblock script %} @@ -720,5 +726,46 @@ </div> </div> + <div class="modal fade" id="uploadModal" role="dialog" aria-labelledby="uploadModalLabel"> + <div class="modal-dialog modal-lg"> + <div class="modal-content"> + <div class="modal-header"> + <h5 class="modal-title" id="uploadModalLabel">导入文件</h5> + </div> + <div class="modal-body"> + <form class="form-group" method="POST" action="{% url 'ostree_upload' %}" enctype="multipart/form-data"> + {% csrf_token %} + {% load bootstrap3 %} + <div class="form-group"> + <label class="control-label" hidden for="ostree_id">软件源ID</label> + <input class="form-control" id="ostree_id" name="ostree_id" required="required" title="" readonly="readonly" type="hidden" value=""> + </div> + <div class="form-group"> + <label class="control-label" for="tag">版本信息</label> + <input class="form-control" readonly="readonly" id="ostree_name" name="ostree_name" required="required" title="" type="text" value=""> + </div> + <div class="form-group"> + <label class="control-label" for="arch">文件名称</label> + <input class="form-control" readonly="readonly" id="file_name" name="file_name" required="required" title="" type="text" value=""> + </div> + <div class="form-group"> + <label class="control-label" for="changelog">改动记录</label> + <input class="form-control" id="changelog" name="changelog" required="required" title="" type="text" placeholder="changelog" + onkeyup="this.value=this.value.replace(/["]/g,'')"> + </div> + <div class="form-group"> + <label class="control-label" for="changelog">导入文件</label> + <input type="file" name="cfg-file" id="cfg-file" required="required" accept=""> + </div> + <div class="text-center"> + <input type='submit' class='btn btn-primary' id='submitBtn' value='确定' style="margin-right: 5%;" onclick=""> + <button type="button" class="btn btn-white" style="margin-left: 5%;" data-dismiss="modal"> 取消 + </button> + </div> + </form> + </div> + </div> + </div> + </div> {% endblock content %} diff --git a/ostree_assembly/app/urls.py b/ostree_assembly/app/urls.py index 9e74176..e6ec7d6 100644 --- a/ostree_assembly/app/urls.py +++ b/ostree_assembly/app/urls.py @@ -41,6 +41,7 @@ urlpatterns = [ url(r'^ost_cfg_save/$', ostree_cfg_edit.ost_cfg_save, name='ost_cfg_save'), url(r'^ostree_download/$', ostree_cfg_edit.ostree_download, name='ostree_download'), + url(r'^ostree_upload/$', ostree_cfg_edit.ostree_upload, name='ostree_upload'), #iso_preview -- 2.27.0
Locations
Projects
Search
Status Monitor
Help
Open Build Service
OBS Manuals
API Documentation
OBS Portal
Reporting a Bug
Contact
Mailing List
Forums
Chat (IRC)
Twitter
Open Build Service (OBS)
is an
openSUSE project
.
浙ICP备2022010568号-2