Skip to content

Commit

Permalink
set link to file
Browse files Browse the repository at this point in the history
  • Loading branch information
Guy-Galil committed Aug 29, 2024
1 parent bee1a8a commit 2644e7f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
5 changes: 4 additions & 1 deletion djang/djang/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,15 @@
from django.contrib import admin
from django.urls import path
from importer import views
from django.conf import settings
from django.conf.urls.static import static

urlpatterns = [
path("admin/", admin.site.urls),
path("", views.companies, name="חברות"),
path("<str:company_name>/", views.kupot, name="קופות"),
path("duchot/<int:kupa_id>/<str:kupa>", views.duchot, name="דוחות"),
path("tabs/<int:report_id>/<str:report_date>", views.tabs, name="טאבים"),
path("details/<int:report_id>/<str:tab>", views.details, name="")
path("details/<int:report_id>/<str:tab>", views.details, name=""),
path("files/<str:file_name>", views.files, name="")
]
18 changes: 15 additions & 3 deletions djang/importer/views.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from django.shortcuts import render
from importer import models
from django.http import HttpResponse
from django.http import FileResponse

root="/"

Expand Down Expand Up @@ -31,11 +32,13 @@ def duchot(request, kupa_id, kupa):

def tabs(request, report_id, report_date):
reports = models.Reports.objects.values().filter(id=report_id)
output = "קובץ "+reports[0]["file_name"]+"<br>רשימת טאבים:<br>"+\
file_name = reports[0]["file_name"]
file_name = file_name[file_name.rfind("/"):]
output = "<a href='/files"+file_name+"'>פתח קובץ:</a><br>רשימת טאבים:<br>"+\
"<select size = 10 onchange='window.location.replace(\"/details/"+str(report_id)+"/\"+this.options[this.selectedIndex].innerHTML)'>"
tab_list = models.AssetDetails.objects.values("category").filter(reports_id=report_id).distinct()
for k in tab_list:
output = output+"<option>"+k["category"]+"</option>"
output = output+"<option>"+k["category"]+"'</option>"
output = output+"</select><br><button onclick='window.location.replace(\"/\")'>Home</button>"
return HttpResponse(output)

Expand All @@ -55,4 +58,13 @@ def details(request, report_id, tab):
output = output + "<th></th>"
output = output + "</tr>"
output = output+"</table><br><button onclick='window.location.replace(\"/\")'>Home</button>"
return HttpResponse(output)
return HttpResponse(output)

def files(request,file_name):
filename="./xlsx-files/files/"+file_name
return FileResponse(open(filename, "rb"),
headers={
"Content-Type": "application/vnd.ms-excel",
"Content-Disposition": 'attachment; filename="'+filename+'"',
}
)

0 comments on commit 2644e7f

Please sign in to comment.