Skip to content

Commit

Permalink
Merge pull request #897 from EsupPortail/develop
Browse files Browse the repository at this point in the history
[DONE] Develop #3.3.1
  • Loading branch information
ptitloup authored Jun 28, 2023
2 parents 1b27faa + b8d45a1 commit c4d132c
Show file tree
Hide file tree
Showing 29 changed files with 1,360 additions and 1,029 deletions.
19 changes: 16 additions & 3 deletions dockerfile-dev-with-volumes/README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,16 @@ ES_VERSION = 7
ES_URL = ['http://elasticsearch:9200/']
CACHES = {
# … default cache config and others
"default": {
"BACKEND": "django.core.cache.backends.locmem.LocMemCache",
"BACKEND": "django_redis.cache.RedisCache",
"LOCATION": "redis://redis:6379/3",
"OPTIONS": {
"CLIENT_CLASS": "django_redis.client.DefaultClient",
},
"KEY_PREFIX": "pod"
},
# Persistent cache setup for select2 (NOT DummyCache or LocMemCache).
"select2": {
"BACKEND": "django_redis.cache.RedisCache",
"LOCATION": "redis://redis:6379/2",
Expand All @@ -90,6 +94,15 @@ CACHES = {
},
},
}
SESSION_ENGINE = "redis_sessions.session"
SESSION_REDIS = {
"host": "redis",
"port": 6379,
"db": 4,
"prefix": "session",
"socket_timeout": 1,
"retry_on_timeout": False,
}
# Uniquement lors d’environnement conteneurisé
MIGRATION_MODULES = {'flatpages': 'pod.db_migrations'}
Expand Down
5 changes: 3 additions & 2 deletions dockerfile-dev-with-volumes/pod/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,13 @@ WORKDIR /usr/src/app

COPY ./requirements.txt .
COPY ./requirements-conteneur.txt .
COPY ./requirements-dev.txt .
RUN mkdir /tmp/node_modules/

COPY --from=source-build-js /tmp/pod/node_modules/ /tmp/node_modules/

RUN pip3 install --no-cache-dir -r requirements.txt \
&& pip3 install --no-cache-dir -r requirements-conteneur.txt
RUN pip3 install --no-cache-dir -r requirements-conteneur.txt \
&& pip3 install elasticsearch==7.17.7

# ENTRYPOINT :
COPY ./dockerfile-dev-with-volumes/pod/my-entrypoint.sh /tmp/my-entrypoint.sh
Expand Down
17 changes: 3 additions & 14 deletions pod/import_video/templates/import_video/list.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,20 +47,9 @@
{% for record in recordings %}
<tr class="recordings_list_item">
<td class="recording_name">{{ record.name }}</td>
<td>
{% if not record.uploadedToPodBy %}
{% trans "Video file not uploaded to Pod" %}
{% else %}
{% trans "Video file already uploaded to Pod" %}
{% if request.user != record.uploadedToPodBy %}
{% trans "by"%} {{ record.uploadedToPodBy.first_name }} {{ record.uploadedToPodBy.last_name }}
{% endif %}
{% endif %}
</td>
<td> {{ record.startTime }}</td>
<td>
{{ record.type }}
</td>
<td>{{ record.state }}</td>
<td>{{ record.startTime }}</td>
<td>{{ record.type }}</td>
<td>
{% if record.presentationUrl != "" %}
<a class="btn btn-primary pod-btn-primary btn-sm" href="{{ record.presentationUrl }}" target="_blank" title="{% trans 'Display the recording in presentation format'%}" data-bs-toggle="tooltip" data-bs-placement="top">
Expand Down
16 changes: 16 additions & 0 deletions pod/import_video/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,22 @@ def save_video(request, dest_file, recording_name, description, date_evt=None):
raise ValueError(msg)


def check_file_exists(source_url):
"""Check that the URL exists.
Args:
source_url (String): Source URL
Returns:
Boolean: file exists (True) or not (False)
"""
response = requests.head(source_url)
if response.status_code < 400:
return True
else:
return False


class video_parser(HTMLParser):
"""Useful to parse the BBB Web page and search for video file.
Expand Down
104 changes: 65 additions & 39 deletions pod/import_video/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@

from .models import ExternalRecording
from .forms import ExternalRecordingForm
from .utils import download_video_file, save_video
from .utils import secure_request_for_upload, parse_remote_file
from .utils import StatelessRecording
from .utils import StatelessRecording, download_video_file, check_file_exists
from .utils import save_video, secure_request_for_upload, parse_remote_file
from datetime import datetime
from django.conf import settings
from django.contrib.sites.shortcuts import get_current_site
Expand Down Expand Up @@ -163,8 +162,6 @@ def external_recordings(request):
Returns:
HTTPResponse: external recordings list
"""
# print(timezone.localtime().strftime("%y%m%d-%H%M%S"))

if RESTRICT_EDIT_IMPORT_VIDEO_ACCESS_TO_STAFF_ONLY and request.user.is_staff is False:
return render(request, "import_video/list.html", {"access_not_allowed": True})

Expand All @@ -179,38 +176,7 @@ def external_recordings(request):

recordings = []
for data in external_recordings:
# Management of the stateless recording
recording = StatelessRecording(data.id, data.name, "published")
# Upload to Pod is always possible in such a case
recording.canUpload = True
# Only owner can delete this external recording
recording.canDelete = get_can_delete_external_recording(request, data.owner)

recording.startTime = data.start_at

# Management of the external recording type
if data.type == "bigbluebutton":
# For BBB, external URL can be the video or presentation playback
if data.source_url.find("playback/video") != -1:
# Management for standards video URLs with BBB or Scalelite server
recording.videoUrl = data.source_url
elif data.source_url.find("playback/presentation/2.3") != -1:
# Management for standards presentation URLs with BBB or Scalelite server
# Add computed video playback
recording.videoUrl = data.source_url.replace(
"playback/presentation/2.3", "playback/video"
)
else:
# Management of other situations, non standards URLs
recording.videoUrl = data.source_url
else:
# For PeerTube, Video file, Youtube
recording.videoUrl = data.source_url

# Display type label
recording.type = data.get_type_display

recording.uploadedToPodBy = data.uploaded_to_pod_by
recording = get_stateless_recording(request, data)

recordings.append(recording)

Expand Down Expand Up @@ -589,9 +555,9 @@ def upload_youtube_recording_to_pod(request, record_id):
"Try changing the access rights to the video directly in Youtube."
)
raise ValueError(msg)
except PytubeError:
except PytubeError as pterror:
msg = {}
msg["error"] = _("YouTube error")
msg["error"] = _("YouTube error '%s'" % (mark_safe(pterror)))
msg["message"] = _(
"YouTube content is inaccessible. "
"This content does not appear to be publicly available."
Expand Down Expand Up @@ -738,3 +704,63 @@ def upload_peertube_recording_to_pod(request, record_id): # noqa: C901
"Try changing the record type or address for this recording."
)
raise ValueError(msg)


def get_stateless_recording(request, data):
"""Return a stateless recording from an external recording.
Args:
request (Request): HTTP request
data (ExternalRecording): external recording
Returns:
StatelessRecording: stateless recording
"""
recording = StatelessRecording(data.id, data.name, "published")
# By default, upload to Pod is possible
recording.canUpload = True
# Only owner can delete this external recording
recording.canDelete = get_can_delete_external_recording(request, data.owner)

recording.startTime = data.start_at

recording.uploadedToPodBy = data.uploaded_to_pod_by

# State management
if recording.uploadedToPodBy is None:
recording.state = _("Video file not uploaded to Pod")
else:
recording.state = _("Video file already uploaded to Pod")

# Management of the external recording type
if data.type == "bigbluebutton":
# For BBB, external URL can be the video or presentation playback
if data.source_url.find("playback/video") != -1:
# Management for standards video URLs with BBB or Scalelite server
recording.videoUrl = data.source_url
elif data.source_url.find("playback/presentation/2.3") != -1:
# Management for standards presentation URLs with BBB or Scalelite server
# Add computed video playback
recording.videoUrl = data.source_url.replace(
"playback/presentation/2.3", "playback/video"
)
recording.presentationUrl = data.source_url
else:
# Management of other situations, non standards URLs
recording.videoUrl = data.source_url

# For old BBB or BBB 2.6+ without video playback
if check_file_exists(recording.videoUrl) is False:
recording.state = _(
"No video file found. " "Upload to Pod as a video is not possible."
)
recording.canUpload = False
recording.videoUrl = ""
else:
# For PeerTube, Video file, Youtube
recording.videoUrl = data.source_url

# Display type label
recording.type = data.get_type_display

return recording
Binary file modified pod/locale/fr/LC_MESSAGES/django.mo
Binary file not shown.
Loading

0 comments on commit c4d132c

Please sign in to comment.