Testing #28
@@ -12,7 +12,6 @@ python django_code/manage.py makemigrations job
|
||||
python django_code/manage.py makemigrations telegram
|
||||
python django_code/manage.py makemigrations podcast
|
||||
python django_code/manage.py makemigrations streaming
|
||||
python django_code/manage.py makemigrations streaming_redirect
|
||||
|
||||
python django_code/manage.py migrate
|
||||
python django_code/manage.py migrate --database=cloudmanager_db
|
||||
@@ -22,7 +21,6 @@ python django_code/manage.py migrate --database=job_db
|
||||
python django_code/manage.py migrate --database=telegram_db
|
||||
python django_code/manage.py migrate --database=podcast_db
|
||||
python django_code/manage.py migrate --database=streaming_db
|
||||
python django_code/manage.py migrate --database=streaming_redirect_db
|
||||
```
|
||||
### Database debug
|
||||
|
||||
@@ -35,7 +33,6 @@ create database job;
|
||||
create database telegram;
|
||||
create database podcast;
|
||||
create database streaming;
|
||||
create database streaming_redirect;
|
||||
|
||||
|
||||
|
||||
@@ -46,7 +43,6 @@ drop database job;
|
||||
drop database telegram;
|
||||
drop database podcast;
|
||||
drop database streaming;
|
||||
drop database streaming_redirect;
|
||||
```
|
||||
|
||||
|
||||
|
||||
@@ -9,3 +9,20 @@ class streamingData(models.Model):
|
||||
|
||||
class Meta:
|
||||
db_table = 'streaming'
|
||||
|
||||
class urlData(models.Model):
|
||||
def sanitize(self):
|
||||
print(self)
|
||||
return 1
|
||||
|
||||
name = models.CharField(primary_key=True,max_length=1000, help_text="Name of the show")
|
||||
url_example = models.CharField(max_length=1000, help_text="https://www.1shows.org/tv/456-the-simpsons?streaming=true&season=18&episode=5")
|
||||
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)
|
||||
suffix = models.CharField(max_length=1000, help_text="" ,blank=True, null=True)
|
||||
addedDate = models.DateField('Published', blank=True, null=True, auto_now_add=True)
|
||||
alias = models.CharField(max_length=1000, default=sanitize)
|
||||
|
||||
|
||||
class Meta:
|
||||
db_table = 'redirectUrl'
|
||||
@@ -1,3 +0,0 @@
|
||||
from django.contrib import admin
|
||||
|
||||
# Register your models here.
|
||||
@@ -1,7 +0,0 @@
|
||||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class StreamingRedirectConfig(AppConfig):
|
||||
default_auto_field = 'django.db.models.BigAutoField'
|
||||
name = 'apps.streaming_redirect'
|
||||
label = 'streaming_redirect'
|
||||
@@ -1,30 +0,0 @@
|
||||
# Generated by Django 4.2.30 on 2026-08-07 10:54
|
||||
|
||||
import apps.streaming_redirect.models
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
initial = True
|
||||
|
||||
dependencies = [
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='urlData',
|
||||
fields=[
|
||||
('name', models.CharField(help_text='Name of the show', max_length=1000, primary_key=True, serialize=False)),
|
||||
('url_example', models.CharField(help_text='https://www.1shows.org/tv/456-the-simpsons?streaming=true&season=18&episode=5', max_length=1000)),
|
||||
('prefix', models.CharField(blank=True, help_text='https://www.1shows.org/tv/456-the-simpsons?streaming=true&season=', max_length=1000, null=True)),
|
||||
('infix', models.CharField(blank=True, help_text='&episode=', max_length=1000, null=True)),
|
||||
('suffix', models.CharField(blank=True, max_length=1000, null=True)),
|
||||
('addedDate', models.DateField(auto_now_add=True, null=True, verbose_name='Published')),
|
||||
('alias', models.CharField(default=apps.streaming_redirect.models.urlData.sanitize, max_length=1000)),
|
||||
],
|
||||
options={
|
||||
'db_table': 'redirectUrl',
|
||||
},
|
||||
),
|
||||
]
|
||||
@@ -1,19 +0,0 @@
|
||||
from django.db import models
|
||||
|
||||
# Create your models here.
|
||||
class urlData(models.Model):
|
||||
def sanitize(self):
|
||||
print(self)
|
||||
return 1
|
||||
|
||||
name = models.CharField(primary_key=True,max_length=1000, help_text="Name of the show")
|
||||
url_example = models.CharField(max_length=1000, help_text="https://www.1shows.org/tv/456-the-simpsons?streaming=true&season=18&episode=5")
|
||||
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)
|
||||
suffix = models.CharField(max_length=1000, help_text="" ,blank=True, null=True)
|
||||
addedDate = models.DateField('Published', blank=True, null=True, auto_now_add=True)
|
||||
alias = models.CharField(max_length=1000, default=sanitize)
|
||||
|
||||
|
||||
class Meta:
|
||||
db_table = 'redirectUrl'
|
||||
@@ -1,3 +0,0 @@
|
||||
from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
||||
@@ -1,3 +0,0 @@
|
||||
from django.shortcuts import render
|
||||
|
||||
# Create your views here.
|
||||
@@ -30,9 +30,6 @@ class ProjectDatabaseRouter:
|
||||
if model._meta.app_label == 'streaming':
|
||||
return 'streaming_db'
|
||||
|
||||
if model._meta.app_label == 'streaming_redirect':
|
||||
return 'streaming_redirect_db'
|
||||
|
||||
return 'default'
|
||||
|
||||
def db_for_write(self, model, **hints):
|
||||
@@ -59,17 +56,14 @@ class ProjectDatabaseRouter:
|
||||
if model._meta.app_label == 'streaming':
|
||||
return 'streaming_db'
|
||||
|
||||
if model._meta.app_label == 'streaming_redirect':
|
||||
return 'streaming_redirect_db'
|
||||
|
||||
return 'default'
|
||||
|
||||
def allow_relation(self, obj1, obj2, **hints):
|
||||
"""Allow relations if both models are in the same database."""
|
||||
# Prevents accidental foreign key relationships across different physical DBs
|
||||
if (
|
||||
obj1._meta.app_label in ['cloudmanager', 'simpsons', 'redirect', 'job', 'telegram', 'podcast', 'streaming', 'streaming_redirect'] or
|
||||
obj2._meta.app_label in ['cloudmanager', 'simpsons', 'redirect', 'job', 'telegram', 'podcast', 'streaming', 'streaming_redirect']
|
||||
obj1._meta.app_label in ['cloudmanager', 'simpsons', 'redirect', 'job', 'telegram', 'podcast', 'streaming'] or
|
||||
obj2._meta.app_label in ['cloudmanager', 'simpsons', 'redirect', 'job', 'telegram', 'podcast', 'streaming']
|
||||
):
|
||||
return obj1._meta.app_label == obj2._meta.app_label
|
||||
return None
|
||||
@@ -98,11 +92,8 @@ class ProjectDatabaseRouter:
|
||||
if app_label == 'streaming':
|
||||
return db == 'streaming_db'
|
||||
|
||||
if app_label == 'streaming_redirect':
|
||||
return db == 'streaming_redirect_db'
|
||||
|
||||
# Ensure default Django apps (auth, sessions, etc.) don't migrate into simpsons/cloudmanager
|
||||
if db in ['cloudmanager_db', 'simpsons_db', 'redirect_db', 'job_db', 'telegram_db', 'podcast_db', 'streaming_db', 'streaming_redirect_db']:
|
||||
if db in ['cloudmanager_db', 'simpsons_db', 'redirect_db', 'job_db', 'telegram_db', 'podcast_db', 'streaming_db']:
|
||||
return False
|
||||
|
||||
return None
|
||||
|
||||
@@ -51,7 +51,6 @@ INSTALLED_APPS = [
|
||||
'apps.telegram_communication.apps.TelegramCommunicationConfig',
|
||||
'apps.podcast_aggregator.apps.PodcastAggregatorConfig',
|
||||
'apps.streaming.apps.StreamingConfig',
|
||||
'apps.streaming_redirect.apps.StreamingRedirectConfig',
|
||||
'import_export',
|
||||
'djangoql',
|
||||
]
|
||||
@@ -164,14 +163,7 @@ DATABASES = {
|
||||
'HOST': os.environ.get('DB_HOST'),
|
||||
'PORT': os.environ.get('DB_PORT'),
|
||||
},
|
||||
'streaming_redirect_db': {
|
||||
'ENGINE': 'django.db.backends.postgresql',
|
||||
'NAME': 'streaming_redirect',
|
||||
'USER': os.environ.get('DB_USERNAME'),
|
||||
'PASSWORD': os.environ.get('DB_PASSWORD'),
|
||||
'HOST': os.environ.get('DB_HOST'),
|
||||
'PORT': os.environ.get('DB_PORT'),
|
||||
},
|
||||
|
||||
}
|
||||
DATABASE_ROUTERS = ['core.routers.ProjectDatabaseRouter']
|
||||
#DATABASE_ROUTERS = []
|
||||
|
||||
@@ -8,7 +8,7 @@ python django_code/manage.py makemigrations job
|
||||
python django_code/manage.py makemigrations telegram
|
||||
python django_code/manage.py makemigrations podcast
|
||||
python django_code/manage.py makemigrations streaming
|
||||
python django_code/manage.py makemigrations streaming_redirect
|
||||
|
||||
|
||||
python django_code/manage.py migrate
|
||||
python django_code/manage.py migrate --database=cloudmanager_db
|
||||
@@ -18,7 +18,7 @@ python django_code/manage.py migrate --database=job_db
|
||||
python django_code/manage.py migrate --database=telegram_db
|
||||
python django_code/manage.py migrate --database=podcast_db
|
||||
python django_code/manage.py migrate --database=streaming_db
|
||||
python django_code/manage.py migrate --database=streaming_redirect_db
|
||||
|
||||
|
||||
|
||||
python django_code/manage.py runserver "0.0.0.0:8000"
|
||||
|
||||
@@ -15,7 +15,6 @@ python django_code/manage.py makemigrations job
|
||||
python django_code/manage.py makemigrations telegram
|
||||
python django_code/manage.py makemigrations podcast
|
||||
python django_code/manage.py makemigrations streaming
|
||||
python django_code/manage.py makemigrations streaming_redirect
|
||||
|
||||
python django_code/manage.py migrate
|
||||
python django_code/manage.py migrate --database=cloudmanager_db
|
||||
@@ -25,7 +24,6 @@ python django_code/manage.py migrate --database=job_db
|
||||
python django_code/manage.py migrate --database=telegram_db
|
||||
python django_code/manage.py migrate --database=podcast_db
|
||||
python django_code/manage.py migrate --database=streaming_db
|
||||
python django_code/manage.py migrate --database=streaming_redirect_db
|
||||
|
||||
python django_code/manage.py runserver "0.0.0.0:8000"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user