-
-
Notifications
You must be signed in to change notification settings - Fork 622
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate web server back-end from Flask to Django (#2040)
- Loading branch information
1 parent
e3cfeb1
commit 188e399
Showing
81 changed files
with
2,562 additions
and
2,756 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
[flake8] | ||
exclude = | ||
anthias_app/migrations/*.py | ||
per-file-ignores = | ||
bin/migrate.py: E501 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,3 +52,7 @@ docker/Dockerfile.test | |
docker-compose.yml | ||
|
||
balena-deploy/ | ||
db.sqlite3 | ||
|
||
# Django | ||
staticfiles/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from django.contrib import admin # noqa F401 | ||
|
||
# Register your models here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
from django.apps import AppConfig | ||
|
||
|
||
class AnthiasAppConfig(AppConfig): | ||
default_auto_field = 'django.db.models.BigAutoField' | ||
name = 'anthias_app' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# Generated by Django 3.2.18 on 2024-08-23 18:45 | ||
|
||
import anthias_app.models | ||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
initial = True | ||
|
||
dependencies = [ | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='Asset', | ||
fields=[ | ||
('asset_id', models.TextField(default=anthias_app.models.generate_asset_id, editable=False, primary_key=True, serialize=False)), | ||
('name', models.TextField(blank=True, null=True)), | ||
('uri', models.TextField(blank=True, null=True)), | ||
('md5', models.TextField(blank=True, null=True)), | ||
('start_date', models.DateTimeField(blank=True, null=True)), | ||
('end_date', models.DateTimeField(blank=True, null=True)), | ||
('duration', models.TextField(blank=True, null=True)), | ||
('mimetype', models.TextField(blank=True, null=True)), | ||
('is_enabled', models.IntegerField(default=0)), | ||
('is_processing', models.IntegerField(default=0)), | ||
('nocache', models.IntegerField(default=0)), | ||
('play_order', models.IntegerField(default=0)), | ||
('skip_asset_check', models.IntegerField(default=0)), | ||
], | ||
options={ | ||
'db_table': 'assets', | ||
}, | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# Generated by Django 3.2.18 on 2024-10-15 15:24 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('anthias_app', '0001_initial'), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name='asset', | ||
name='duration', | ||
field=models.BigIntegerField(blank=True, null=True), | ||
), | ||
migrations.AlterField( | ||
model_name='asset', | ||
name='is_enabled', | ||
field=models.BooleanField(default=False), | ||
), | ||
migrations.AlterField( | ||
model_name='asset', | ||
name='is_processing', | ||
field=models.BooleanField(default=False), | ||
), | ||
migrations.AlterField( | ||
model_name='asset', | ||
name='nocache', | ||
field=models.BooleanField(default=False), | ||
), | ||
migrations.AlterField( | ||
model_name='asset', | ||
name='skip_asset_check', | ||
field=models.BooleanField(default=False), | ||
), | ||
] |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import uuid | ||
from django.db import models | ||
from django.utils import timezone | ||
|
||
|
||
def generate_asset_id(): | ||
return uuid.uuid4().hex | ||
|
||
|
||
class Asset(models.Model): | ||
asset_id = models.TextField( | ||
primary_key=True, default=generate_asset_id, editable=False) | ||
name = models.TextField(blank=True, null=True) | ||
uri = models.TextField(blank=True, null=True) | ||
md5 = models.TextField(blank=True, null=True) | ||
start_date = models.DateTimeField(blank=True, null=True) | ||
end_date = models.DateTimeField(blank=True, null=True) | ||
duration = models.BigIntegerField(blank=True, null=True) | ||
mimetype = models.TextField(blank=True, null=True) | ||
is_enabled = models.BooleanField(default=False) | ||
is_processing = models.BooleanField(default=False) | ||
nocache = models.BooleanField(default=False) | ||
play_order = models.IntegerField(default=0) | ||
skip_asset_check = models.BooleanField(default=False) | ||
|
||
class Meta: | ||
db_table = 'assets' | ||
|
||
def is_active(self): | ||
if self.is_enabled and self.start_date and self.end_date: | ||
current_time = timezone.now() | ||
return ( | ||
self.start_date < current_time < self.end_date | ||
) | ||
|
||
return False |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from django.test import TestCase # noqa F401 | ||
|
||
# Create your tests here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
from django.urls import path | ||
from . import views | ||
|
||
app_name = 'anthias_app' | ||
|
||
urlpatterns = [ | ||
path('', views.index, name='index'), | ||
path('settings', views.settings_page, name='settings'), | ||
path('system-info', views.system_info, name='system_info'), | ||
path('integrations', views.integrations, name='integrations'), | ||
path('splash-page', views.splash_page, name='splash_page'), | ||
] |
Oops, something went wrong.