deploy
This commit is contained in:
parent
b367df2a32
commit
e4a26855e9
@ -22,4 +22,4 @@ class Dump(FileStorageMixin, models.Model):
|
|||||||
@property
|
@property
|
||||||
def filename(self):
|
def filename(self):
|
||||||
if self.task is not None:
|
if self.task is not None:
|
||||||
return f"dump-task-{self.task.id}-{self.str_date}"
|
return f"dump-task-{self.task.id}-{self.str_date}.zip"
|
||||||
|
20
Main/views/DownloadFileView.py
Normal file
20
Main/views/DownloadFileView.py
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
from django.http import HttpResponse
|
||||||
|
|
||||||
|
from SprintLib.BaseView import BaseView, AccessError
|
||||||
|
from SprintLib.utils import get_bytes
|
||||||
|
|
||||||
|
|
||||||
|
class DownloadFileView(BaseView):
|
||||||
|
endpoint = "download_file"
|
||||||
|
required_login = True
|
||||||
|
|
||||||
|
def get(self):
|
||||||
|
dump = self.entities.dump
|
||||||
|
if dump.task:
|
||||||
|
if self.request.user == dump.task.creator or self.request.user.username in dump.task.editors:
|
||||||
|
response = HttpResponse(
|
||||||
|
get_bytes(dump.fs_id), content_type='application/force-download'
|
||||||
|
)
|
||||||
|
response['Content-Disposition'] = f'inline; filename={dump.filename}'
|
||||||
|
return response
|
||||||
|
raise AccessError()
|
@ -18,3 +18,4 @@ from Main.views.SetView import SetView
|
|||||||
from Main.views.GroupView import GroupView
|
from Main.views.GroupView import GroupView
|
||||||
from Main.views.CheckersView import CheckersView
|
from Main.views.CheckersView import CheckersView
|
||||||
from Main.views.ChatsView import ChatsView
|
from Main.views.ChatsView import ChatsView
|
||||||
|
from Main.views.DownloadFileView import DownloadFileView
|
||||||
|
@ -326,7 +326,7 @@
|
|||||||
<td>{{ dump.id }}</td>
|
<td>{{ dump.id }}</td>
|
||||||
<td>{{ dump.timestamp }}</td>
|
<td>{{ dump.timestamp }}</td>
|
||||||
<td>{{ dump.executor.username }}</td>
|
<td>{{ dump.executor.username }}</td>
|
||||||
<td>{% if dump.ready %}<a href="#">Скачать</a>{% else %}<badge class="badge badge-info"><svg aria-hidden="true" focusable="false" data-prefix="fas" data-icon="circle-notch" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" style="width: 20px;" class="svg-inline--fa fa-circle-notch fa-w-16 fa-spin fa-lg"><path fill="currentColor" d="M288 39.056v16.659c0 10.804 7.281 20.159 17.686 23.066C383.204 100.434 440 171.518 440 256c0 101.689-82.295 184-184 184-101.689 0-184-82.295-184-184 0-84.47 56.786-155.564 134.312-177.219C216.719 75.874 224 66.517 224 55.712V39.064c0-15.709-14.834-27.153-30.046-23.234C86.603 43.482 7.394 141.206 8.003 257.332c.72 137.052 111.477 246.956 248.531 246.667C393.255 503.711 504 392.788 504 256c0-115.633-79.14-212.779-186.211-240.236C302.678 11.889 288 23.456 288 39.056z" class=""></path></svg> В процессе</badge>{% endif %}</td>
|
<td>{% if dump.ready %}<a href="/download_file?dump_id={{ dump.id }}">Скачать</a>{% else %}<badge class="badge badge-info"><svg aria-hidden="true" focusable="false" data-prefix="fas" data-icon="circle-notch" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" style="width: 20px;" class="svg-inline--fa fa-circle-notch fa-w-16 fa-spin fa-lg"><path fill="currentColor" d="M288 39.056v16.659c0 10.804 7.281 20.159 17.686 23.066C383.204 100.434 440 171.518 440 256c0 101.689-82.295 184-184 184-101.689 0-184-82.295-184-184 0-84.47 56.786-155.564 134.312-177.219C216.719 75.874 224 66.517 224 55.712V39.064c0-15.709-14.834-27.153-30.046-23.234C86.603 43.482 7.394 141.206 8.003 257.332c.72 137.052 111.477 246.956 248.531 246.667C393.255 503.711 504 392.788 504 256c0-115.633-79.14-212.779-186.211-240.236C302.678 11.889 288 23.456 288 39.056z" class=""></path></svg> В процессе</badge>{% endif %}</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tbody>
|
</tbody>
|
||||||
|
Loading…
Reference in New Issue
Block a user