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
Merged
Changes from all commits
Commits
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
17 changes: 17 additions & 0 deletions pod/video/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -677,6 +677,23 @@ def clean(self):
):
cleaned_data["is_restricted"] = True

def clean_channel(self):
"""Merge channels of a video."""
users_groups = self.current_user.owner.accessgroup_set.all()
if self.is_superuser:
user_channels = Channel.objects.all()
else:
user_channels = (
self.current_user.owners_channels.all()
| self.current_user.users_channels.all()
| Channel.objects.filter(allow_to_groups__in=users_groups)
).distinct()
user_channels.filter(site=get_current_site(None))
channels_to_keep = Video.objects.get(pk=self.instance.id).channel.exclude(
pk__in=[c.id for c in user_channels]
)
return self.cleaned_data["channel"].union(channels_to_keep)

def __init__(self, *args, **kwargs):
self.is_staff = (
kwargs.pop("is_staff") if "is_staff" in kwargs.keys() else self.is_staff
Expand Down