2020-05-01 12:38:57 +02:00
|
|
|
from django.forms import ModelForm
|
|
|
|
from guardian.shortcuts import get_objects_for_user
|
|
|
|
from . import models
|
|
|
|
|
|
|
|
|
2024-02-27 20:44:35 +01:00
|
|
|
class RestreamFilteredStreamForm(ModelForm):
|
2020-05-01 12:38:57 +02:00
|
|
|
class Meta:
|
2024-02-27 20:44:35 +01:00
|
|
|
model = models.Restream
|
2021-12-14 18:35:58 +01:00
|
|
|
fields = ['name', 'stream', 'target', 'format', 'active']
|
2020-05-01 12:38:57 +02:00
|
|
|
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
|
|
user = kwargs.pop('user', None)
|
|
|
|
super().__init__(*args, **kwargs)
|
|
|
|
|
|
|
|
# limit the stream selection to user-accessible streams
|
2024-02-27 20:44:35 +01:00
|
|
|
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')
|