portier/source/config/forms.py

17 lines
548 B
Python

from django.forms import ModelForm
from guardian.shortcuts import get_objects_for_user
from . import models
class RestreamFilteredStreamForm(ModelForm):
class Meta:
model = models.Restream
fields = ['name', 'stream', 'target', 'format', 'active']
def __init__(self, *args, **kwargs):
user = kwargs.pop('user', None)
super().__init__(*args, **kwargs)
# limit the stream selection to user-accessible streams
self.fields['stream'].queryset = get_objects_for_user(user, 'config.view_stream')