add messenger table and view

This commit is contained in:
Jonathan Baecker 2020-04-28 17:51:40 +02:00
parent b5631fe8b8
commit a13ba7a06d
6 changed files with 81 additions and 3 deletions

View File

@ -0,0 +1,32 @@
# Generated by Django 3.0.5 on 2020-04-28 13:47
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('api', '0001_initial'),
]
operations = [
migrations.CreateModel(
name='MessengePresets',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(help_text='the preset name', max_length=255)),
('message', models.CharField(blank=True, default='', max_length=1024, null=True)),
('x', models.CharField(blank=True, default='', max_length=512, null=True)),
('y', models.CharField(blank=True, default='', max_length=512, null=True)),
('font_size', models.IntegerField(default=24)),
('font_spacing', models.IntegerField(default=4)),
('font_color', models.CharField(default='#ffffff', max_length=12)),
('font_alpha', models.FloatField(default=1.0)),
('show_box', models.BooleanField(default=True)),
('box_color', models.CharField(default='#000000', max_length=12)),
('box_alpha', models.FloatField(default=0.8)),
('border_width', models.IntegerField(default=4)),
('overall_alpha', models.CharField(blank=True, default='', max_length=255, null=True)),
],
),
]

View File

@ -41,3 +41,27 @@ class GuiSettings(models.Model):
class Meta:
verbose_name_plural = "guisettings"
class MessengePresets(models.Model):
name = models.CharField(max_length=255, help_text="the preset name")
message = models.CharField(
max_length=1024, blank=True, null=True, default='')
x = models.CharField(
max_length=512, blank=True, null=True, default='')
y = models.CharField(
max_length=512, blank=True, null=True, default='')
font_size = models.IntegerField(default=24)
font_spacing = models.IntegerField(default=4)
font_color = models.CharField(max_length=12, default='#ffffff')
font_alpha = models.FloatField(default=1.0)
show_box = models.BooleanField(default=True)
box_color = models.CharField(max_length=12, default='#000000')
box_alpha = models.FloatField(default=0.8)
border_width = models.IntegerField(default=4)
overall_alpha = models.CharField(
max_length=255, blank=True, null=True, default='')

View File

@ -2,7 +2,7 @@ from django.contrib.auth.models import User
from rest_framework import serializers
from api.models import GuiSettings
from api.models import GuiSettings, MessengePresets
class UserSerializer(serializers.ModelSerializer):
@ -55,3 +55,9 @@ class GuiSettingsSerializer(serializers.ModelSerializer):
if request is not None and not request.parser_context.get('kwargs'):
fields.pop('id', None)
return fields
class MessengerSerializer(serializers.ModelSerializer):
class Meta:
model = MessengePresets
fields = '__all__'

View File

@ -2,8 +2,9 @@ import os
import shutil
from urllib.parse import unquote
from api.models import GuiSettings
from api.serializers import GuiSettingsSerializer, UserSerializer
from api.models import GuiSettings, MessengePresets
from api.serializers import (GuiSettingsSerializer, MessengerSerializer,
UserSerializer)
from django.contrib.auth.models import User
from django_filters import rest_framework as filters
from rest_framework import viewsets
@ -43,6 +44,20 @@ class GuiSettingsViewSet(viewsets.ModelViewSet):
serializer_class = GuiSettingsSerializer
class MessengerFilter(filters.FilterSet):
class Meta:
model = MessengePresets
fields = ['name']
class MessengerViewSet(viewsets.ModelViewSet):
queryset = MessengePresets.objects.all()
serializer_class = MessengerSerializer
filter_backends = (filters.DjangoFilterBackend,)
filterset_class = MessengerFilter
class Config(APIView):
"""
read and write config from ffplayout engine

Binary file not shown.

View File

@ -27,6 +27,7 @@ from rest_framework_simplejwt.views import (
router = routers.DefaultRouter()
router.register(r'users', views.UserViewSet)
router.register(r'guisettings', views.GuiSettingsViewSet, 'guisettings')
router.register(r'messenger', views.MessengerViewSet, 'messenger')
urlpatterns = [
path('admin/', admin.site.urls),