Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NOT TO MERGE] Pod v4 new #1229

Draft
wants to merge 28 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
73ed68a
* UPGRADE Django to v4.2.16
Badatos Oct 24, 2024
e50187e
Merge branch 'develop' into pod_V4
Badatos Oct 28, 2024
7e4cd06
* Remove USE_L10N deprecated param
Badatos Oct 28, 2024
af15471
Remove `USE_L10N` from test_settings
Badatos Oct 28, 2024
7c01d4b
Merge branch 'develop' into pod_V4
Badatos Oct 29, 2024
a721a03
* Correct video_edit slect2 display with tagulous (remove duplicated …
Badatos Oct 29, 2024
4deb722
* Remove Python 3.8 from compatible py versions, and add 3.12
Badatos Oct 30, 2024
b2975a6
Merge branch 'develop' into pod_V4
Badatos Oct 30, 2024
645b930
Upgrade dependencies
Badatos Oct 30, 2024
7c5d362
several corrections for 4.0. Prepare to say goodbye to CKEditor
Badatos Nov 13, 2024
917a006
correct video/models.py
Badatos Nov 13, 2024
9a4ab7f
Remove Compatibility with ES 6
Badatos Nov 21, 2024
097edab
Replace js_asset by django.templatetags.static, as js_asset is deprec…
Badatos Nov 21, 2024
151af7c
Fix code scanning alert no. 81: URL redirection from remote source
Badatos Nov 21, 2024
ccfebc3
Improve security in pod playlists, as suggested by CodeQL
Badatos Nov 21, 2024
5941015
Disable some video_tags functions
Badatos Nov 21, 2024
bf7dc21
Flake8 compliance
Badatos Nov 21, 2024
cb32056
Disable Debug in test_settings
Badatos Nov 21, 2024
c9de8e1
only add debug toolbar when not in testing mode
Badatos Nov 21, 2024
d28b3dc
Add title_en to sample videos.json
Badatos Nov 21, 2024
6bd0164
Reset ES-INDEX for tests as "Pod"
Badatos Nov 21, 2024
3c17c09
Use Elasticsearch 7 in github workflows
Badatos Nov 21, 2024
b54952b
set Video tags as "not required" + correct bug on video tags indexing
Badatos Nov 21, 2024
fd9fbaa
Adapt Video views and video-info to Tagulous
Badatos Nov 25, 2024
bf5cabd
adapt video get_json_to_index() function to Tagulous
Badatos Nov 25, 2024
92ac5b2
Adapt Video Recorder to Tagulous
Badatos Nov 25, 2024
cecec76
Only do dressing tests when `USE_DRESSING==True
Badatos Nov 25, 2024
f7d1a21
* Only run `cut` tests when `USE_CUT==True`
Badatos Nov 25, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .github/workflows/pod_dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,7 @@ jobs:
- name: Runs Elasticsearch
uses: elastic/elastic-github-actions/elasticsearch@refactor_with_plugins
with:
# stack-version: 7.6.0
stack-version: 6.8.23
stack-version: 7.17.25
plugins: analysis-icu

- name: Setup Pod
Expand Down
5 changes: 2 additions & 3 deletions .github/workflows/pod_main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
strategy:
max-parallel: 2
matrix:
python-version: ['3.8', '3.10']
python-version: ['3.10', '3.12']
steps:
- run: echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event."
- run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by GitHub!"
Expand Down Expand Up @@ -57,8 +57,7 @@ jobs:
- name: Runs Elasticsearch
uses: elastic/elastic-github-actions/elasticsearch@refactor_with_plugins
with:
# stack-version: 7.6.0
stack-version: 6.8.23
stack-version: 7.17.25
plugins: analysis-icu

- name: Setup Pod
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,13 @@ pod/static/
.cache_ggshield
htmlcov
compile-model
pod/activitypub/*.pub

# IDE Files #
#############
.idea
.vscode
*.code-workspace

# Certificates #
################
Expand Down
11 changes: 6 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,16 @@ help:
# Démarre le serveur de test
start:
(sleep 15 ; open http://pod.localhost:8000) &
python3 manage.py runserver pod.localhost:8000 --insecure
python3 -Wd manage.py runserver pod.localhost:8000 --insecure
# --insecure let serve static files even when DEBUG=False
# -Wd enable default warning mode (Warn once per call location)

# Démarre le serveur de test en https auto-signé
starts:
# nécessite les django-extensions
# cf https://timonweb.com/django/https-django-development-server-ssl-certificate/
(sleep 15 ; open https://pod.localhost:8000) &
python3 manage.py runserver_plus pod.localhost:8000 --cert-file cert.pem --key-file key.pem
python3 -Wd manage.py runserver_plus pod.localhost:8000 --cert-file cert.pem --key-file key.pem

# Première installation de pod (BDD SQLite intégrée)
install:
Expand All @@ -44,7 +45,7 @@ createDB:
find . -path "*/migrations/*.pyc" -delete
make updatedb
make migrate
python3 manage.py loaddata initial_data
python3 -Wd manage.py loaddata initial_data

# Mise à jour des fichiers de langue
lang:
Expand Down Expand Up @@ -82,8 +83,8 @@ statics:

# Generate configuration docs in .MD format
createconfigs:
python3 manage.py createconfiguration fr
python3 manage.py createconfiguration en
python3 -Wd manage.py createconfiguration fr
python3 -Wd manage.py createconfiguration en

# -- Docker
# Use for docker run and docker exec commands
Expand Down
4 changes: 2 additions & 2 deletions pod/ai_enhancement/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

from django import forms
from django.conf import settings
from django.utils.translation import ugettext_lazy as _
from tagging.fields import TagField
from django.utils.translation import gettext_lazy as _
from tagulous.models import TagField

from pod.main.forms_utils import add_placeholder_and_asterisk
from pod.video.models import Video, Discipline
Expand Down
2 changes: 1 addition & 1 deletion pod/ai_enhancement/models.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from django.db import models
from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _
from django.dispatch import receiver
from django.db.models.signals import post_save
from pod.video.models import Video
Expand Down
4 changes: 2 additions & 2 deletions pod/ai_enhancement/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from django.conf import settings
from requests import Response
from django.urls import reverse
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
from pod.ai_enhancement.models import AIEnhancement
from pod.main.utils import extract_json_from_str
from pod.video.models import Discipline, Video
Expand All @@ -27,7 +27,7 @@

AI_ENHANCEMENT_API_URL = getattr(settings, "AI_ENHANCEMENT_API_URL", "")
AI_ENHANCEMENT_API_VERSION = getattr(settings, "AI_ENHANCEMENT_API_VERSION", "")
USE_NOTIFICATIONS = getattr(settings, "USE_NOTIFICATIONS", True)
USE_NOTIFICATIONS = getattr(settings, "USE_NOTIFICATIONS", False)
EMAIL_ON_ENHANCEMENT_COMPLETION = getattr(
settings, "EMAIL_ON_ENHANCEMENT_COMPLETION", True
)
Expand Down
2 changes: 1 addition & 1 deletion pod/ai_enhancement/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from django.http import HttpResponse, JsonResponse
from django.shortcuts import get_object_or_404, redirect, render
from django.urls import reverse
from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _
from django.views.decorators.csrf import csrf_protect, csrf_exempt
from django.views.decorators.csrf import ensure_csrf_cookie
from django.core.exceptions import PermissionDenied
Expand Down
1 change: 0 additions & 1 deletion pod/authentication/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
default_app_config = "pod.authentication.apps.AuthConfig"
12 changes: 5 additions & 7 deletions pod/authentication/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from django.contrib import admin
from django.contrib.auth.admin import UserAdmin as BaseUserAdmin
from django.contrib.auth.models import User
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
from django.utils.html import format_html
from django.contrib.sites.shortcuts import get_current_site
from django.contrib.auth.models import Group
Expand Down Expand Up @@ -84,12 +84,11 @@ class Media:


class UserAdmin(BaseUserAdmin):
@admin.display(description=_("Email"))
def clickable_email(self, obj):
email = obj.email
return format_html('<a href="mailto:{}">{}</a>', email, email)

clickable_email.allow_tags = True
clickable_email.short_description = _("Email")
list_display = (
"username",
"last_name",
Expand Down Expand Up @@ -130,11 +129,10 @@ def formfield_for_manytomany(self, db_field, request, **kwargs):
kwargs["widget"] = widgets.FilteredSelectMultiple(db_field.verbose_name, False)
return super().formfield_for_foreignkey(db_field, request, **kwargs)

@admin.display(description=_("Establishment"))
def owner_establishment(self, obj) -> str:
return "%s" % Owner.objects.get(user=obj).establishment

owner_establishment.short_description = _("Establishment")

ordering = (
"-is_superuser",
"username",
Expand Down Expand Up @@ -188,6 +186,7 @@ def get_inline_instances(self, request, obj=None):
return _inlines


@admin.register(AccessGroup)
class AccessGroupAdmin(admin.ModelAdmin):
# form = AccessGroupAdminForm
# search_fields = ["user__username__icontains", "user__email__icontains"]
Expand All @@ -200,6 +199,7 @@ class AccessGroupAdmin(admin.ModelAdmin):
)


@admin.register(Owner)
class OwnerAdmin(admin.ModelAdmin):
# form = AdminOwnerForm
autocomplete_fields = ["user", "accessgroups"]
Expand All @@ -225,5 +225,3 @@ class Meta:
# Register the new Group ModelAdmin instead of the original one.
admin.site.unregister(Group)
admin.site.register(Group, GroupAdmin)
admin.site.register(Owner, OwnerAdmin)
admin.site.register(AccessGroup, AccessGroupAdmin)
2 changes: 1 addition & 1 deletion pod/authentication/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from django.contrib.auth import get_user_model
from django.contrib.admin.widgets import FilteredSelectMultiple
from django.contrib.auth.models import Group
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
from django.contrib.sites.models import Site

__FILEPICKER__ = False
Expand Down
2 changes: 1 addition & 1 deletion pod/authentication/models.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Esup-Pod authentication models."""

from django.db import models
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
from django.contrib.auth.models import User, Permission, Group
from django.conf import settings
from django.dispatch import receiver
Expand Down
4 changes: 2 additions & 2 deletions pod/authentication/shibmiddleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def check_user_meta(self, user, shib_meta):
and user.owner.affiliation != shib_meta["affiliation"]
)

def is_staffable(self, user):
def is_staffable(self, user) -> bool:
"""Check that given user, his domain is in authorized domains of shibboleth staff.

Args:
Expand All @@ -81,7 +81,7 @@ def is_staffable(self, user):
return True
return False

def make_profile(self, user, shib_meta):
def make_profile(self, user, shib_meta) -> None:
if ("affiliation" in shib_meta) and self.check_user_meta(user, shib_meta):
user.owner.affiliation = shib_meta["affiliation"]
user.owner.save()
Expand Down
19 changes: 12 additions & 7 deletions pod/authentication/tests/test_populated.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
"""Esup-Pod test populated authentication."""
"""Unit tests for Esup-Pod populated authentication.

* run with 'python manage.py test pod.authentication.tests.test_populated'
"""

import random
from django.conf import settings
from django.test import TestCase, override_settings
from django.contrib.auth.models import User
from django.test import TestCase, override_settings, RequestFactory
from importlib import reload
from ldap3 import Server, Connection, MOCK_SYNC
from unittest import skip
from xml.etree import ElementTree as ET

from pod.authentication.models import Owner, AccessGroup, AFFILIATION_STAFF
from pod.authentication import populatedCASbackend
from pod.authentication import shibmiddleware
Expand All @@ -13,12 +22,7 @@
OIDC_CLAIM_FAMILY_NAME,
OIDC_CLAIM_GIVEN_NAME,
)
from django.test import RequestFactory
from django.contrib.auth.models import User
from importlib import reload
from xml.etree import ElementTree as ET

from ldap3 import Server, Connection, MOCK_SYNC

"""
USER_CAS_MAPPING_ATTRIBUTES = getattr(
Expand Down Expand Up @@ -431,6 +435,7 @@ def test_populate_user_from_entry_unpopulate_group(self) -> None:
)


@skip("# Esup-Pod 4.0 is no more comapible with Shibb (until someone correct this)")
class PopulatedShibTestCase(TestCase):
def setUp(self) -> None:
"""Set up PopulatedShibTestCase create user Pod."""
Expand Down
2 changes: 1 addition & 1 deletion pod/authentication/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from django.test import Client
from django.contrib.auth.models import User
from django.conf import settings
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _


class authenticationViewsTestCase(TestCase):
Expand Down
18 changes: 9 additions & 9 deletions pod/authentication/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,26 @@
from .views import authentication_logout
from .views import authentication_login_gateway

from django.conf.urls import url
from django.urls import path

app_name = "authentication"

urlpatterns = [
# auth cas
url(
r"^login/$",
path(
"login/",
authentication_login,
name="authentication_login",
),
url(
r"^logout/$",
path(
"logout/",
authentication_logout,
name="authentication_logout",
),
# url(r"^login/$", authentication_login, name="login"),
# url(r"^logout/$", authentication_logout, name="logout"),
url(
r"^login_gateway/$",
# re_path(r"^login/$", authentication_login, name="login"),
# re_path(r"^logout/$", authentication_logout, name="logout"),
path(
"login_gateway/",
authentication_login_gateway,
name="authentication_login_gateway",
),
Expand Down
2 changes: 1 addition & 1 deletion pod/authentication/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from django.urls import reverse
from django.conf import settings
from django.core.exceptions import SuspiciousOperation
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
from cas.decorators import gateway
from django.contrib import auth

Expand Down
4 changes: 1 addition & 3 deletions pod/chapter/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from pod.video.models import Video


@admin.register(Chapter)
class ChapterAdmin(admin.ModelAdmin):
"""Chapter administration."""

Expand All @@ -33,9 +34,6 @@ def formfield_for_foreignkey(self, db_field, request, **kwargs):
return super().formfield_for_foreignkey(db_field, request, **kwargs)


admin.site.register(Chapter, ChapterAdmin)


class ChapterInline(admin.TabularInline):
model = Chapter
extra = 0
2 changes: 1 addition & 1 deletion pod/chapter/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from django import forms
from django.conf import settings
from django.core.exceptions import ValidationError
from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _

from pod.chapter.models import Chapter
from pod.chapter.utils import vtt_to_chapter
Expand Down
2 changes: 1 addition & 1 deletion pod/chapter/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from django.core.exceptions import ValidationError
from django.db import models
from django.template.defaultfilters import slugify
from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _

from pod.video.models import Video
from pod.video.utils import verify_field_length
Expand Down
4 changes: 2 additions & 2 deletions pod/chapter/urls.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from django.conf.urls import url
from django.urls import re_path
from pod.chapter.views import video_chapter

app_name = "chapter"

urlpatterns = [
url(
re_path(
r"^(?P<slug>[\-\d\w]+)/$",
video_chapter,
name="video_chapter",
Expand Down
2 changes: 1 addition & 1 deletion pod/chapter/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from django.template.loader import render_to_string
from django.contrib import messages
from django.contrib.auth.decorators import login_required
from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _
from django.views.decorators.csrf import csrf_protect
from pod.video.models import Video
from pod.chapter.models import Chapter
Expand Down
Loading
Loading