diff --git a/Sistemas/forms.py b/Sistemas/forms.py new file mode 100644 index 0000000..2a2f4b2 --- /dev/null +++ b/Sistemas/forms.py @@ -0,0 +1,6 @@ +from django import forms +from .models import Sistema +class SistemaForm(forms.ModelForm): + class Meta: + model = Sistema + fields = ['nombre_sistema','version'] \ No newline at end of file diff --git a/Sistemas/views.py b/Sistemas/views.py index 8593444..219f4e5 100644 --- a/Sistemas/views.py +++ b/Sistemas/views.py @@ -31,6 +31,7 @@ import traceback from django.core.files.storage import default_storage from django.core.files.base import ContentFile from .customStorage import CustomStorage +from .forms import SistemaForm from django.contrib.auth.decorators import login_required @login_required @@ -39,10 +40,12 @@ def uploadZipViewHTML(request): user = request.user if user.is_superuser: token= Token.objects.get(user=user) + sistemas= Sistema.objects.all() else: redirect('index') context = { 'token':token.key, + 'sistemas':sistemas, } template_name= 'Sistemas/manageSystem/uploadZip.html' return render(request, template_name,context) @@ -57,13 +60,20 @@ class UploadZipVersionView(APIView): def post(self,request,format=None): try: zip_file=request.FILES['zip_file'] + version = request.POST.get('version') + sistema = request.POST.get('sistema') + #print(request.POST) except KeyError: return Response({'error':'Zip file is required'},status=status.HTTP_400_BAD_REQUEST) try: + versionSistema = Sistema.objects.get(id=sistema) + versionSistema.version=version + versionSistema.save() + BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) download_system_dir = os.path.join(BASE_DIR,'downloadSystems') custom_storage = CustomStorage(location=download_system_dir) - print('path exist? ',os.path.exists(download_system_dir)) + #print('path exist? ',os.path.exists(download_system_dir)) fileName = custom_storage.save(zip_file.name, ContentFile(zip_file.read())) except Exception as ex: diff --git a/Templates/Sistemas/manageSystem/uploadZip.html b/Templates/Sistemas/manageSystem/uploadZip.html index 659cd28..f854018 100644 --- a/Templates/Sistemas/manageSystem/uploadZip.html +++ b/Templates/Sistemas/manageSystem/uploadZip.html @@ -6,18 +6,60 @@ {% block content %} -
- + + +
+ +

+ +

+ + + + + + + + +

+
{% endblock content %} - - {% block scripts %}