Merge pull request 'Testing' (#50) from testing into main
Dockerfile runner / Explore-Gitea-Actions (push) Successful in 6m23s
Dockerfile runner / Explore-Gitea-Actions (push) Successful in 6m23s
Reviewed-on: http://gitea.geeraert.eu/pi-ux-ce/Django_kube/pulls/50
This commit was merged in pull request #50.
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
from django.contrib import admin,messages
|
from django.contrib import admin,messages
|
||||||
from django.utils.translation import ngettext
|
from django.utils.translation import ngettext
|
||||||
from .models import Deployment_Data,Schedule_Day_Data,Schedule_Week_Data,Namespace_Data
|
from .models import Deployment_Data,Schedule_Day_Data,Schedule_Week_Data,Namespace_Data,Ingress_Data
|
||||||
from .utils import import_namespace,import_deployment,generate_default_day_schedule,generate_default_week_schedule,Check_server_supposed_XXX,retrieve_and_apply
|
from .utils import import_namespace,import_deployment,generate_default_day_schedule,generate_default_week_schedule,Check_server_supposed_XXX,retrieve_and_apply
|
||||||
from apps.kubernetes_connection.utils import scale_up,scale_down
|
from apps.kubernetes_connection.utils import scale_up,scale_down
|
||||||
from admin_extra_buttons.api import button
|
from admin_extra_buttons.api import button
|
||||||
@@ -117,3 +117,7 @@ class NamespaceAdmin(UniversalModelAdmin):
|
|||||||
# your business logic here
|
# your business logic here
|
||||||
import_namespace()
|
import_namespace()
|
||||||
self.message_user(request, 'Namespaces imported')
|
self.message_user(request, 'Namespaces imported')
|
||||||
|
|
||||||
|
@admin.register(Ingress_Data)
|
||||||
|
class IngressAdmin(UniversalModelAdmin):
|
||||||
|
list_display = ('url','namespace')
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
# Generated by Django 4.2.30 on 2026-09-21 16:14
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
import django.db.models.deletion
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('cloudmanager', '0012_alter_deployment_data_do_not_touch_until'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='Ingress_Data',
|
||||||
|
fields=[
|
||||||
|
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('url', models.CharField(max_length=100)),
|
||||||
|
('namespace', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='cloudmanager.namespace_data')),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
# Generated by Django 4.2.30 on 2026-09-21 21:06
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('cloudmanager', '0013_ingress_data'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='ingress_data',
|
||||||
|
name='namespace',
|
||||||
|
field=models.CharField(blank=True, max_length=100, null=True),
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -62,3 +62,9 @@ class Namespace_Data(models.Model):
|
|||||||
#deployments = models.ForeignKey(Schedule_Week_Data,null=True, blank=True, on_delete=models.SET_NULL)
|
#deployments = models.ForeignKey(Schedule_Week_Data,null=True, blank=True, on_delete=models.SET_NULL)
|
||||||
class Meta:
|
class Meta:
|
||||||
db_table = 'namespace'
|
db_table = 'namespace'
|
||||||
|
def __str__(self):
|
||||||
|
return self.namespace
|
||||||
|
|
||||||
|
class Ingress_Data(models.Model):
|
||||||
|
url = models.CharField(max_length=100)
|
||||||
|
namespace = models.CharField(max_length=100,null=True, blank=True)
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ Including another URLconf
|
|||||||
"""
|
"""
|
||||||
from django.urls import path
|
from django.urls import path
|
||||||
|
|
||||||
from .views import hello,import_namespace_view,retrieve_and_apply_view,scale_up_gui,scale_down_gui
|
from .views import hello,import_namespace_view,retrieve_and_apply_view,scale_up_gui,scale_down_gui,add_ingress,delete_ingress
|
||||||
|
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
@@ -26,4 +26,8 @@ urlpatterns = [
|
|||||||
path('retrieve_and_apply_view', retrieve_and_apply_view, name='retrieve_and_apply_view'),
|
path('retrieve_and_apply_view', retrieve_and_apply_view, name='retrieve_and_apply_view'),
|
||||||
path('scale_up/<str:namespace_name>/<str:deploy_name>', scale_up_gui),
|
path('scale_up/<str:namespace_name>/<str:deploy_name>', scale_up_gui),
|
||||||
path('scale_down/<str:namespace_name>/<str:deploy_name>', scale_down_gui),
|
path('scale_down/<str:namespace_name>/<str:deploy_name>', scale_down_gui),
|
||||||
|
path('add_ingress', add_ingress),
|
||||||
|
path('delete_ingress', delete_ingress),
|
||||||
|
|
||||||
|
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -2,10 +2,14 @@ from django.http import HttpResponse
|
|||||||
from django.shortcuts import render
|
from django.shortcuts import render
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
|
from django.views.decorators.csrf import csrf_exempt
|
||||||
|
from django.http import JsonResponse
|
||||||
|
|
||||||
|
from apps.import_aggregator.import_rest_framework import api_view, authentication_classes, permission_classes,TokenAuthentication,IsAuthenticated,Response,status
|
||||||
|
|
||||||
from .utils import import_namespace,retrieve_and_apply
|
from .utils import import_namespace,retrieve_and_apply
|
||||||
from apps.kubernetes_connection.utils import scale_up,scale_down
|
from apps.kubernetes_connection.utils import scale_up,scale_down
|
||||||
from .models import Deployment_Data
|
from .models import Deployment_Data,Ingress_Data
|
||||||
|
|
||||||
def hello(request):
|
def hello(request):
|
||||||
list_schedule = ['schedule1','schedule2']
|
list_schedule = ['schedule1','schedule2']
|
||||||
@@ -32,3 +36,42 @@ def scale_down_gui(request,namespace_name,deploy_name):
|
|||||||
scale_down(namespace_name=namespace_name,deploy_name=deploy_name)
|
scale_down(namespace_name=namespace_name,deploy_name=deploy_name)
|
||||||
return render(request, 'dashboard/shutdown.html',
|
return render(request, 'dashboard/shutdown.html',
|
||||||
{'namespace': namespace_name, 'deployment': deploy_name, 'url': 'https://namespace.com'})
|
{'namespace': namespace_name, 'deployment': deploy_name, 'url': 'https://namespace.com'})
|
||||||
|
|
||||||
|
|
||||||
|
@api_view(['POST'])
|
||||||
|
@authentication_classes([TokenAuthentication])
|
||||||
|
@permission_classes([IsAuthenticated])
|
||||||
|
def add_ingress(request):
|
||||||
|
url = request.POST.get('url')
|
||||||
|
namespace = request.POST.get('namespace')
|
||||||
|
print("URL: "+str(url))
|
||||||
|
print("NS: "+str(namespace))
|
||||||
|
|
||||||
|
try:
|
||||||
|
Ingress_Data.objects.update_or_create(url=url,namespace=namespace)
|
||||||
|
except Exception as exception:
|
||||||
|
return JsonResponse({"status": "error","reason":str(exception)})
|
||||||
|
|
||||||
|
return JsonResponse({"status": "added","url":str(url),"namespace":str(namespace)})
|
||||||
|
|
||||||
|
@api_view(['POST'])
|
||||||
|
@authentication_classes([TokenAuthentication])
|
||||||
|
@permission_classes([IsAuthenticated])
|
||||||
|
def delete_ingress(request):
|
||||||
|
url = request.POST.get('url')
|
||||||
|
namespace = request.POST.get('namespace')
|
||||||
|
print("URL: "+str(url))
|
||||||
|
print("NS: "+str(namespace))
|
||||||
|
|
||||||
|
try:
|
||||||
|
ingress_object = Ingress_Data.objects.filter(url=url,namespace=namespace)
|
||||||
|
except Exception as exception:
|
||||||
|
return JsonResponse({"status": "error","reason":str(exception)})
|
||||||
|
|
||||||
|
try:
|
||||||
|
ingress_object.delete()
|
||||||
|
except Exception as exception:
|
||||||
|
return JsonResponse({"status": "error","reason":str(exception)})
|
||||||
|
|
||||||
|
return JsonResponse({"status": "deleted","url":str(url),"namespace":str(namespace)})
|
||||||
|
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
from rest_framework.decorators import api_view, authentication_classes, permission_classes
|
||||||
|
from rest_framework.authentication import TokenAuthentication
|
||||||
|
from rest_framework.permissions import IsAuthenticated
|
||||||
|
from rest_framework.response import Response
|
||||||
|
from rest_framework import status
|
||||||
|
|
||||||
@@ -2,10 +2,24 @@ from django.contrib import admin
|
|||||||
from django.utils.html import format_html
|
from django.utils.html import format_html
|
||||||
from .models import StreamingSiteTestingData,StreamingRedirectData
|
from .models import StreamingSiteTestingData,StreamingRedirectData
|
||||||
from .utils import full_testing
|
from .utils import full_testing
|
||||||
|
from apps.website_redirection.utils import redirect_method
|
||||||
from urllib.parse import urlsplit, urlunsplit
|
from urllib.parse import urlsplit, urlunsplit
|
||||||
from core.admin import UniversalModelAdmin
|
from core.admin import UniversalModelAdmin
|
||||||
|
|
||||||
|
|
||||||
|
@admin.action(description="Add this show to streaming")
|
||||||
|
def re_redirect(modeladmin, request, queryset):
|
||||||
|
output_generated = ""
|
||||||
|
for query in queryset.values():
|
||||||
|
print(query)
|
||||||
|
key = "streaming"
|
||||||
|
value = query.get('url_display')
|
||||||
|
output_generated = output_generated + redirect_method(key,value)+";"
|
||||||
|
|
||||||
|
modeladmin.message_user(
|
||||||
|
request,
|
||||||
|
output_generated
|
||||||
|
)
|
||||||
|
|
||||||
@admin.action(description="check the URLs")
|
@admin.action(description="check the URLs")
|
||||||
def check(modeladmin, request, queryset):
|
def check(modeladmin, request, queryset):
|
||||||
@@ -61,6 +75,8 @@ class streamingAdmin(UniversalModelAdmin):
|
|||||||
@admin.register(StreamingRedirectData)
|
@admin.register(StreamingRedirectData)
|
||||||
class StreamingRedirectAdmin(UniversalModelAdmin):
|
class StreamingRedirectAdmin(UniversalModelAdmin):
|
||||||
list_display = ['name','image_tag','season','episode','randomViewing','clickable_links','addedDate','alias']
|
list_display = ['name','image_tag','season','episode','randomViewing','clickable_links','addedDate','alias']
|
||||||
|
actions = [re_redirect]
|
||||||
|
|
||||||
#fields = ['name','season','episode','url_example','prefix','infix','suffix','alias','randomViewing','seasonInformation']
|
#fields = ['name','season','episode','url_example','prefix','infix','suffix','alias','randomViewing','seasonInformation']
|
||||||
fieldsets = (
|
fieldsets = (
|
||||||
(
|
(
|
||||||
@@ -81,4 +97,4 @@ class StreamingRedirectAdmin(UniversalModelAdmin):
|
|||||||
link_field = 'url_display'
|
link_field = 'url_display'
|
||||||
|
|
||||||
def image_tag(self,obj):
|
def image_tag(self,obj):
|
||||||
return format_html('<img src="{0}" style="width: 150px; height:100px;" />'.format(obj.poster_url))
|
return format_html('<img src="{0}" style="width: 355px; height:200px;" />'.format(obj.poster_url))
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ class StreamingRedirectData(models.Model):
|
|||||||
name = models.CharField(primary_key=True,max_length=1000, help_text="Name of the show")
|
name = models.CharField(primary_key=True,max_length=1000, help_text="Name of the show")
|
||||||
season = models.IntegerField(null=False,default=1)
|
season = models.IntegerField(null=False,default=1)
|
||||||
episode = models.IntegerField(null=False,default=0)
|
episode = models.IntegerField(null=False,default=0)
|
||||||
url_display = models.CharField(max_length=1000, help_text="https://www.1shows.org/tv/456-the-simpsons?streaming=true&season=18&episode=5",blank=True, null=True)
|
url_display = models.CharField(max_length=1000, help_text="https://streaming.geeraert.eu/office",blank=True, null=True)
|
||||||
prefix = models.CharField(max_length=1000, help_text="https://www.1shows.org/tv/456-the-simpsons?streaming=true&season=",blank=True, null=True)
|
prefix = models.CharField(max_length=1000, help_text="https://www.1shows.org/tv/456-the-simpsons?streaming=true&season=",blank=True, null=True)
|
||||||
infix = models.CharField(max_length=1000, help_text="&episode=",blank=True, null=True)
|
infix = models.CharField(max_length=1000, help_text="&episode=",blank=True, null=True)
|
||||||
suffix = models.CharField(max_length=1000, help_text="" ,blank=True, null=True)
|
suffix = models.CharField(max_length=1000, help_text="" ,blank=True, null=True)
|
||||||
@@ -34,7 +34,7 @@ class StreamingRedirectData(models.Model):
|
|||||||
poster_url = models.CharField(max_length=1000, help_text="poster URL",blank=True, null=True)
|
poster_url = models.CharField(max_length=1000, help_text="poster URL",blank=True, null=True)
|
||||||
|
|
||||||
def sanitize(self, name):
|
def sanitize(self, name):
|
||||||
return name.replace(" ", "")
|
return name.replace(" ", "").lower()
|
||||||
|
|
||||||
def season_information(self, serie_name):
|
def season_information(self, serie_name):
|
||||||
betaserie = betaserieUtils()
|
betaserie = betaserieUtils()
|
||||||
|
|||||||
@@ -15,6 +15,9 @@ def hello(request):
|
|||||||
|
|
||||||
|
|
||||||
def streamingRedirect(request,alias):
|
def streamingRedirect(request,alias):
|
||||||
|
#sanitize
|
||||||
|
alias = alias.lower()
|
||||||
|
|
||||||
streaming_object = StreamingRedirectData.objects.filter(alias=alias)
|
streaming_object = StreamingRedirectData.objects.filter(alias=alias)
|
||||||
|
|
||||||
episode = streaming_object.values('episode')[0]['episode']
|
episode = streaming_object.values('episode')[0]['episode']
|
||||||
|
|||||||
@@ -54,6 +54,9 @@ INSTALLED_APPS = [
|
|||||||
'import_export',
|
'import_export',
|
||||||
'djangoql',
|
'djangoql',
|
||||||
'admin_extra_buttons',
|
'admin_extra_buttons',
|
||||||
|
'rest_framework',
|
||||||
|
'rest_framework.authtoken',
|
||||||
|
|
||||||
]
|
]
|
||||||
|
|
||||||
MIDDLEWARE = [
|
MIDDLEWARE = [
|
||||||
|
|||||||
@@ -17,3 +17,4 @@ xmltodict
|
|||||||
whitenoise
|
whitenoise
|
||||||
djangoql
|
djangoql
|
||||||
django-admin-extra-buttons
|
django-admin-extra-buttons
|
||||||
|
djangorestframework
|
||||||
|
|||||||
Reference in New Issue
Block a user