portier/source/config/forms.py

29 lines
969 B
Python
Raw Permalink Normal View History

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')
2024-04-01 16:27:31 +02:00
class PullFilteredStreamForm(ModelForm):
class Meta:
model = models.Pull
fields = ['name', 'stream', 'source', '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')