export
This commit is contained in:
@@ -68,9 +68,6 @@ def get_active_experiments(session, expid=None):
|
|||||||
if session:
|
if session:
|
||||||
experiments = models.SessionExperiment.experiment_by_session(session.id, active=True) or []
|
experiments = models.SessionExperiment.experiment_by_session(session.id, active=True) or []
|
||||||
eid = [str(e.id) for e in experiments]
|
eid = [str(e.id) for e in experiments]
|
||||||
|
|
||||||
print(f"Found {eid} active experiments for session {session.id}")
|
|
||||||
|
|
||||||
if experiments and not expid or expid not in eid:
|
if experiments and not expid or expid not in eid:
|
||||||
return experiments, experiments[0]
|
return experiments, experiments[0]
|
||||||
|
|
||||||
|
|||||||
@@ -278,8 +278,8 @@ class Session(models.Model):
|
|||||||
name = models.CharField(_("Nom de la session"), help_text=_("Session d'expérience. 4 Multi-puits maximum"), max_length=100, null=True, blank=False)
|
name = models.CharField(_("Nom de la session"), help_text=_("Session d'expérience. 4 Multi-puits maximum"), max_length=100, null=True, blank=False)
|
||||||
author = models.ForeignKey(User, on_delete=models.SET_NULL, verbose_name="Auteur", null=True, blank=True)
|
author = models.ForeignKey(User, on_delete=models.SET_NULL, verbose_name="Auteur", null=True, blank=True)
|
||||||
active = models.BooleanField(_("Active"), default=True)
|
active = models.BooleanField(_("Active"), default=True)
|
||||||
expected_export = models.DateTimeField(_("Date d'exportation"), help_text=_("Date d'exportation prévue"), null=True, blank=True)
|
expected_export = models.DateTimeField(_("Date d'exportation"), help_text=_("Date d'exportation prévue"), null=True, blank=True)
|
||||||
expected_scanning = models.DateTimeField(_("Date du balayage"), help_text=_("Date du balayage prévue"), null=True, blank=True)
|
expected_scanning = models.DateTimeField(_("Date du balayage"), help_text=_("Date du balayage prévue"), null=True, blank=True)
|
||||||
|
|
||||||
created = models.DateTimeField(_("Date de création"), default=timezone.now)
|
created = models.DateTimeField(_("Date de création"), default=timezone.now)
|
||||||
finished = models.DateTimeField (_("Date de fin"), null=True, blank=True)
|
finished = models.DateTimeField (_("Date de fin"), null=True, blank=True)
|
||||||
@@ -340,8 +340,8 @@ def create_periodic_task(sender, instance, created, **kwargs):
|
|||||||
)
|
)
|
||||||
# Sauvegarde sans re-déclencher le signal
|
# Sauvegarde sans re-déclencher le signal
|
||||||
Session.objects.filter(pk=instance.pk).update(export_task=export_task)
|
Session.objects.filter(pk=instance.pk).update(export_task=export_task)
|
||||||
except:
|
except Exception as e:
|
||||||
pass
|
print("create_periodic_task error", e)
|
||||||
|
|
||||||
if instance.expected_scanning:
|
if instance.expected_scanning:
|
||||||
try:
|
try:
|
||||||
|
|||||||
@@ -145,9 +145,13 @@
|
|||||||
<a href="{% url 'scanner:images' %}" class="w3-bar-item w3-btn w3-hover-opacity">
|
<a href="{% url 'scanner:images' %}" class="w3-bar-item w3-btn w3-hover-opacity">
|
||||||
<i class="fa-regular fa-images w3-text-cyan w3-xlarge" w3-xlarge""></i> {% trans "Gestionnaire d'images" %}
|
<i class="fa-regular fa-images w3-text-cyan w3-xlarge" w3-xlarge""></i> {% trans "Gestionnaire d'images" %}
|
||||||
</a>
|
</a>
|
||||||
<a href="{% url 'scanner:replay' %}" class="w3-bar-item w3-btn w3-hover-opacity">
|
<a href="{% url 'scanner:replay' %}" class="w3-bar-item w3-btn w3-hover-opacity">
|
||||||
<i class="fa-solid fa-podcast w3-text-amber w3-xlarge"r"></i> {% trans "Redifusion vidéos" %}
|
<i class="fa-solid fa-podcast w3-text-amber w3-xlarge"r"></i> {% trans "Redifusion vidéos" %}
|
||||||
</a>
|
</a>
|
||||||
|
<a href="{% url 'scanner:export_medias' %}" class="w3-bar-item w3-btn w3-hover-opacity">
|
||||||
|
<i class="fa-solid fa-file-export w3-text-pink w3-xlarge"></i> {% trans "Exporter les fichiers multimédias" %}
|
||||||
|
</a>
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
</div>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|||||||
@@ -0,0 +1,68 @@
|
|||||||
|
{% extends 'scanner/base.html' %}
|
||||||
|
{% load i18n %}
|
||||||
|
{% block columns %}{% endblock %}
|
||||||
|
{% block sidebar_list %}
|
||||||
|
<a href="/" class="w3-bar-item w3-btn w3-hover-opacity"><i class="fa-solid fa-house w3-text-orange w3-xlarge"></i> {% trans "Retour accueil" %}</a>
|
||||||
|
<form method="post" class="w3-bar-item" action="">
|
||||||
|
{% csrf_token %}
|
||||||
|
<select id="_sid" name="_sid" class="w3-select w3-margin-bottom" onchange="this.form.submit()" title="{% trans "Ensemble d'expériences" %}">
|
||||||
|
<option value="0">---- {% trans "Session" %}</option>
|
||||||
|
{% for s in sessions %}
|
||||||
|
<option value="{{ s.id }}" {% if s.id == current_session.id %}selected{% endif %}>{{ s }}</option>
|
||||||
|
{% endfor %}
|
||||||
|
</select>
|
||||||
|
</form>
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<div class="w3-container w50 w3-div-center w3-border w3-round w3-round-xlarge w3-margin-top">
|
||||||
|
<div class="w3-panel w3-pale-blue w3-round w3-round-xlarge w3-margin-bottom">
|
||||||
|
<p>
|
||||||
|
{% trans "L'explortation des fichiers multimédia peut durer plusieurs heures." %}
|
||||||
|
{% trans "Préférer l'exportation différée." %}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{% if current_session %}
|
||||||
|
<form method="post" novalidate class="w3-row w3-row-padding">
|
||||||
|
{% csrf_token %}
|
||||||
|
<input type="hidden" name="_sid" value="{{ current_session.id }}">
|
||||||
|
<div class="w3-col w3-margin-bottom">
|
||||||
|
<label class="w3-text-blue-grey">{% trans "Auteur" %}</label> {{ current_session.author }}
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div class="w3-col w3-margin-bottom">
|
||||||
|
<label class="w3-text-blue-grey">{% trans "Session" %}</label> {{ current_session }}
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div class="w3-col w3-margin-bottom">
|
||||||
|
<label class="w3-text-blue-grey">{% trans "Date de création" %}</label> {{ current_session.created }}
|
||||||
|
</div>
|
||||||
|
<div class="w3-col w3-margin-bottom">
|
||||||
|
<label class="w3-text-blue-grey">{% trans "Status" %}</label> {{ current_session.export_status }}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="w3-col w3-margin-top">
|
||||||
|
<button type="submit" name="valid" class="w3-button w3-blue w3-round w3-round-large w3-large w3-padding w3-margin-bottom" value="ok">
|
||||||
|
<i class="fa-solid fa-file-export w3-text-red w3-xlarge"></i> {% trans "Exporter" %}
|
||||||
|
</button>
|
||||||
|
<a href="/" class="w3-button w3-light-grey w3-round w3-round-large w3-large w3-padding w3-margin-left w3-margin-bottom">
|
||||||
|
<span class="w3-xlarge">✖</span>{% trans "Annuler" %}
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
{% else %}
|
||||||
|
<div class="w3-container w3-padding-64 w3-margin" style="max-width:760px; margin:auto;">
|
||||||
|
<h3 class="w3-panel w3-blue w3-round-xlarge w3-padding-64 w3-center"> {% trans "Choisir une session" %}</h3>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
{% if current_session and current_session.export_status == 'running' %}
|
||||||
|
<div class="w3-padding w3-margin-top">
|
||||||
|
<iframe width="100%" src="{{ url }}" style="border:none; height:30vh;display:block;"></iframe>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -23,6 +23,8 @@ urlpatterns = [
|
|||||||
path('scanning/', views.scanning_view, name='scanning'),
|
path('scanning/', views.scanning_view, name='scanning'),
|
||||||
path('images/', views.images_view, name='images'),
|
path('images/', views.images_view, name='images'),
|
||||||
path('replay/', views.replay_view, name='replay'),
|
path('replay/', views.replay_view, name='replay'),
|
||||||
|
path('export/medias/', views.export_medias, name='export_medias'),
|
||||||
|
|
||||||
path('api/stats/', views.stats_view, name='api_stats'),
|
path('api/stats/', views.stats_view, name='api_stats'),
|
||||||
path('api/video/', views.download_api, name='download_api'),
|
path('api/video/', views.download_api, name='download_api'),
|
||||||
path('api/export/', views.export_api, name='export_api'),
|
path('api/export/', views.export_api, name='export_api'),
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ from django.views.decorators.http import require_GET, require_POST
|
|||||||
from django.views.decorators.csrf import csrf_exempt
|
from django.views.decorators.csrf import csrf_exempt
|
||||||
from django.contrib.auth.decorators import login_required, user_passes_test
|
from django.contrib.auth.decorators import login_required, user_passes_test
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
from django.utils import timezone
|
||||||
|
|
||||||
from reduct.time import unix_timestamp_to_iso
|
from reduct.time import unix_timestamp_to_iso
|
||||||
from modules.system_stats import get_cached_stats, start_background_updater
|
from modules.system_stats import get_cached_stats, start_background_updater
|
||||||
@@ -195,6 +196,34 @@ def images_view(request):
|
|||||||
)
|
)
|
||||||
return render(request, "scanner/images.html", context=global_context(request, **ctx))
|
return render(request, "scanner/images.html", context=global_context(request, **ctx))
|
||||||
|
|
||||||
|
@login_required
|
||||||
|
def export_medias(request):
|
||||||
|
cursid = 0
|
||||||
|
if request.method == 'POST':
|
||||||
|
cursid = request.POST.get('_sid')
|
||||||
|
valid = request.POST.get('valid')
|
||||||
|
if valid == 'ok':
|
||||||
|
try:
|
||||||
|
session = models.Session.objects.get(pk=cursid)
|
||||||
|
session.expected_export = timezone.now()
|
||||||
|
if not session.export_status == "running":
|
||||||
|
session.export_status = "running"
|
||||||
|
if session.export_task:
|
||||||
|
session.export_task.enabled = True
|
||||||
|
session.export_task.save()
|
||||||
|
session.save()
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
print("export_medias error", e)
|
||||||
|
|
||||||
|
current_session = models.Session.get_session(cursid)
|
||||||
|
ctx = dict(
|
||||||
|
choice_title=_("Exporter les fichiers médias"),
|
||||||
|
sessions=models.Session.objects.filter(active=False).all(),
|
||||||
|
current_session=current_session,
|
||||||
|
url=f'http://{settings.LOCAL_IP_SERVER}:9001/logtail/test_tube:services',
|
||||||
|
)
|
||||||
|
return render(request, "scanner/export_medias.html", context=global_context(request, **ctx))
|
||||||
|
|
||||||
@require_POST
|
@require_POST
|
||||||
@csrf_exempt
|
@csrf_exempt
|
||||||
|
|||||||
Reference in New Issue
Block a user