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

[Done] Add any video in user channel #864

Merged

Conversation

secale
Copy link
Contributor

@secale secale commented May 23, 2023

#795

pour un utilisateur avec les droits d'édition des vidéos, possibilité d'associer une vidéo à toute chaine dont il est propriétaire. L'association existante de la vidéo avec des chaines d'autres utilisateurs n'est plus supprimée

utilisation de la méthode clean_channel pour le merge des channels de l'utilisateur

@secale secale changed the title [WIP] Add any video in user channel [Done] Add any video in user channel May 31, 2023
@ptitloup
Copy link
Contributor

ptitloup commented Jun 1, 2023

Bonjour, n'hésitez pas à revenir vers nous sur le canal team pour nous signaler vos PR. Quel est le but de cette modification ? merci

@secale
Copy link
Contributor Author

secale commented Jun 1, 2023

Bonjour,
l'objectif est, pour un utilisateur avec un droit de modification sur les video , de pouvoir ajouter une video à une chaine dont il est propriétaire sans l'enlever d'autres chaines dont il n'est pas propriétaire, ce qui est le comportement jusqu'à présent : un gestionnaire éditorial doit pouvoir ajouter toute vidéo de la plateforme dans une chaine pour une mise en avant, sans modifier les associations de chaines qui existaient.

Copy link
Collaborator

@Badatos Badatos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Merci pour cette PR.
Pouvez-vous également ajouter un test unitaire qui vérifie la partie ajoutée ?

@@ -633,9 +633,28 @@ def clean_date_delete(self):
)
return self.cleaned_data["date_delete"]

def clean(self):
def clean(self): # noqa: C901
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Si vous pouvez ajouter une petite pydoc sous ce format : """Description de la fonction.""" ce serait top ;)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

c'est fait :)

cleaned_data = super(VideoForm, self).clean()

users_groups = self.current_user.owner.accessgroup_set.all()

if "channel" in cleaned_data.keys():
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ajouter un petit commentaire qui rappelle ce que cette partie fait.

Copy link
Contributor

@SebastienCozeDev SebastienCozeDev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AymericJak et moi avons testé en local. Lorsque nous tentons d'ajouter une vidéo dans une chaîne dont nous sommes propriétaire depuis l'édition d'une vidéo, nous avons ce soucis :

image

Environment:


Request Method: POST
Request URL: http://localhost:9090/video/edit/0002-le-coucher-du-soleil-111204mp4/

Django Version: 3.2.19
Python Version: 3.7.16
Installed Applications:
['modeltranslation',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'django.contrib.sites',
 'django.contrib.flatpages',
 'ckeditor',
 'sorl.thumbnail',
 'tagging',
 'cas',
 'captcha',
 'rest_framework',
 'rest_framework.authtoken',
 'django_filters',
 'django_select2',
 'shibboleth',
 'chunked_upload',
 'mozilla_django_oidc',
 'honeypot',
 'lti_provider',
 'pod.main',
 'django.contrib.admin',
 'pod.authentication',
 'pod.video',
 'pod.podfile',
 'pod.playlist',
 'pod.completion',
 'pod.chapter',
 'pod.enrichment',
 'pod.video_search',
 'pod.live',
 'pod.recorder',
 'pod.lti',
 'pod.bbb',
 'pod.meeting',
 'pod.cut',
 'pod.xapi',
 'pod.favorite',
 'pod.custom']
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.locale.LocaleMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware',
 'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware']



Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/django/core/handlers/exception.py", line 47, in inner
    response = get_response(request)
  File "/usr/local/lib/python3.7/site-packages/django/core/handlers/base.py", line 181, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/usr/local/lib/python3.7/site-packages/django/utils/decorators.py", line 130, in _wrapped_view
    response = view_func(request, *args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/django/utils/decorators.py", line 130, in _wrapped_view
    response = view_func(request, *args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/django/contrib/auth/decorators.py", line 21, in _wrapped_view
    return view_func(request, *args, **kwargs)
  File "/usr/src/app/pod/video/views.py", line 1000, in video_edit
    video = save_video_form(request, form)
  File "/usr/src/app/pod/video/views.py", line 1029, in save_video_form
    form.save_m2m()
  File "/usr/local/lib/python3.7/site-packages/django/forms/models.py", line 451, in _save_m2m
    f.save_form_data(self.instance, cleaned_data[f.name])
  File "/usr/local/lib/python3.7/site-packages/django/db/models/fields/related.py", line 1668, in save_form_data
    getattr(instance, self.attname).set(data)
  File "/usr/local/lib/python3.7/site-packages/django/db/models/fields/related_descriptors.py", line 992, in set
    objs = tuple(objs)
  File "/usr/local/lib/python3.7/site-packages/django/db/models/query.py", line 280, in __iter__
    self._fetch_all()
  File "/usr/local/lib/python3.7/site-packages/django/db/models/query.py", line 1324, in _fetch_all
    self._result_cache = list(self._iterable_class(self))
  File "/usr/local/lib/python3.7/site-packages/django/db/models/query.py", line 51, in __iter__
    results = compiler.execute_sql(chunked_fetch=self.chunked_fetch, chunk_size=self.chunk_size)
  File "/usr/local/lib/python3.7/site-packages/django/db/models/sql/compiler.py", line 1162, in execute_sql
    sql, params = self.as_sql()
  File "/usr/local/lib/python3.7/site-packages/django/db/models/sql/compiler.py", line 522, in as_sql
    result, params = self.get_combinator_sql(combinator, self.query.combinator_all)
  File "/usr/local/lib/python3.7/site-packages/django/db/models/sql/compiler.py", line 459, in get_combinator_sql
    raise DatabaseError('ORDER BY not allowed in subqueries of compound statements.')

Exception Type: DatabaseError at /video/edit/0002-le-coucher-du-soleil-111204mp4/
Exception Value: ORDER BY not allowed in subqueries of compound statements.

| Channel.objects.filter(allow_to_groups__in=users_groups)
).distinct()

user_channels.filter(site=get_current_site(None))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pourquoi avoir mis None dans get_current_site(None) ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cette ligne avait été utilisée dans une autre partie de l'application, je l'ai utilisé telle quelle. Je ne vois quel argument autre passer.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Vous pourriez tester de nouveau ?

@mattbild mattbild force-pushed the add_any_video_in_user_channel branch from 8afb94e to ea8873f Compare June 15, 2023 12:43
Copy link
Contributor

@ptitloup ptitloup left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pas testé fonctionnellement mais coté code ca me convient. Je regarde rapidement

Copy link
Contributor

@ptitloup ptitloup left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Testé, ca fonctionne de mon coté. Merci pour cette contribution

@ptitloup ptitloup merged commit e80c2ec into EsupPortail:develop Jun 16, 2023
@mattbild mattbild deleted the add_any_video_in_user_channel branch June 16, 2023 08:55
vsabatie pushed a commit to vsabatie/Pod that referenced this pull request Jun 28, 2023
* issue 795 - ajout n'importe quelle video à une chaine
* method clean_channel
* change line ending

---------

Co-authored-by: mattbild <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants