From a13ba7a06d4bcac18cb7e4b71668c8d81c98e344 Mon Sep 17 00:00:00 2001 From: Jonathan Baecker Date: Tue, 28 Apr 2020 17:51:40 +0200 Subject: [PATCH] add messenger table and view --- .../api/migrations/0002_messengepresets.py | 32 ++++++++++++++++++ ffplayout/api/models.py | 24 +++++++++++++ ffplayout/api/serializers.py | 8 ++++- ffplayout/api/views.py | 19 +++++++++-- ffplayout/db.sqlite3 | Bin 135168 -> 139264 bytes ffplayout/ffplayout/urls.py | 1 + 6 files changed, 81 insertions(+), 3 deletions(-) create mode 100644 ffplayout/api/migrations/0002_messengepresets.py diff --git a/ffplayout/api/migrations/0002_messengepresets.py b/ffplayout/api/migrations/0002_messengepresets.py new file mode 100644 index 00000000..87b38f5b --- /dev/null +++ b/ffplayout/api/migrations/0002_messengepresets.py @@ -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)), + ], + ), + ] diff --git a/ffplayout/api/models.py b/ffplayout/api/models.py index 93106fa6..8c8abc05 100644 --- a/ffplayout/api/models.py +++ b/ffplayout/api/models.py @@ -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='') diff --git a/ffplayout/api/serializers.py b/ffplayout/api/serializers.py index fce81c7d..6245d748 100644 --- a/ffplayout/api/serializers.py +++ b/ffplayout/api/serializers.py @@ -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__' diff --git a/ffplayout/api/views.py b/ffplayout/api/views.py index d62c47f0..9cde384f 100644 --- a/ffplayout/api/views.py +++ b/ffplayout/api/views.py @@ -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 diff --git a/ffplayout/db.sqlite3 b/ffplayout/db.sqlite3 index 218acb354e8a6a45c875948640b9ae3248ff7377..0df31773ee694da3c06f95006baf7406a3750196 100644 GIT binary patch delta 1982 zcma)6O>7%Q6yB-Vcx`7hX-tz8H_5~ylDDzr_1bRZv?YWRiqxtlRZtM6b=UUT-m>1c z?6J3jgX5}F1r?}~rCQ|DAgXfWVC4{@a)2A49(texPVI$5%a0HjP6%e#b=o+t#7Lf% z-+SMi_rCewtgLe@Uvt;IyALxALoQ}mdE_l~i4+oC{ z_z<3lw_ydY!K?5dY<#MKSDV*<>)ksDZ4p2dcP6#h&xiH{RKFT}9dPv@LX*(rqJ?rW z!N5PD0TUZN;sP8RWIdB6yrU$pZp?o4JO|G)@OSt#{2qP@f@#mVg*Wl0q$1|FfPwZ#5N476) z1HidjyT5eVHRBkJM8K6pL{6%>%dK=V`Hr5RpIe+qi*v7>m`A=Y5siflAl7(a0lkeg z8sMt|`$VEy{(H|D2sDMtsdEx~1UVLJYg{3X?a(8n^*GQtIyhpPs8o^my zL?=%zwsW<-1v#Z?*;YWcTSQ7%_2QHK)~OvyWVMi!eW-|K_2~mjIo(Jkby{;$*SC47 zG0`RO;#1X`AW0L4{YM+>^gYahFo_Vjt3ylxl8UDH*no))-JoM5oBjTY__Y? zkIEV{C5hU@h8{lv2S+I=e)JhLV8U9{u@gAb0&dO6nQae?iEO!cAj88H89CBzcuW+X zsU48bTfc(0U+m|hhq3cc2CnnY-qXGNpx&(g-BZ2Px2undlqUoLyiTXr0WR%L>V)X| zAi)<&Fe9gNP|+517?letJx|qya0P1w8H%c+BsN==mvI^;mywJzCQFJ|Cb%@^H>?y1 zLkLO!Tu@asoX83L#i@8dJD#!DxLBnRt0>Ms{KQ;qtdh}m;#brDun;H_e>gw{;gFK? ztHe(NmU)tT#K3lwBn12<*n&~N5DIq$ObdZdQ=DSLL4S1%H!WB|k$!|I3z;z);^H7s#^JjwlYX<5tn)<4?PIvG$U!j}esG*cO+tlq%{f?L2E?moUo76-;@e5?)41 zzMxl&M5biQnx>bv6waH>5*_8`ck$H!Bg2@C28^H)3QPO*dYbakVvqjy87&S%0R3TQ>Y3OE+4C delta 334 zcmZoTz|pXPV}i7xE&~IDA`ruX+e95>M%|4GOZb_ExU(j+3#e{vwBz2KB|VEph@C%y zk^d!s0{?FQGX7co-TYTKHhS?-PSDq4l$qSE@4?7E`HH?auMii|Fn0cO2L5;a<(v5o z0{JISkeXa>-wQOLjDi0x|4sf={CoK4^LO!=ZEQ^7pIqkO$1KBpU^07v<;KPa-pvPM zU5c1x_+uxtUjPco@^6m4zofyQEtx@p@f8D067zOu6~ zTxGw`F@fEIaR&nfx6cK}y$oCzKx`0TOJ-cRv2hjS_V#SXN){H5vkZ49Hr|{rmdrSP z`m1EdozvGQGum=+&ST&Jsh++#h4CZ{kl{YD(Rq7LDx)+TBiCle2h0Y`Sr#xlFw1Z+ Uo6i1#5$Lou?(NH7Ge)TZ0JE22z5oCK diff --git a/ffplayout/ffplayout/urls.py b/ffplayout/ffplayout/urls.py index 2c8aad45..fa7540c2 100644 --- a/ffplayout/ffplayout/urls.py +++ b/ffplayout/ffplayout/urls.py @@ -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),