-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
48 changed files
with
3,809 additions
and
1,656 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
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
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
23 changes: 23 additions & 0 deletions
23
apps/migrations/0018_customappinstance_default_url_subpath.py
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,23 @@ | ||
# Generated by Django 5.1.1 on 2024-11-19 13:27 | ||
|
||
import apps.models.app_types.custom.custom | ||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("apps", "0017_alter_streamlitinstance_port"), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name="customappinstance", | ||
name="default_url_subpath", | ||
field=models.CharField( | ||
blank=True, | ||
default="", | ||
max_length=255, | ||
validators=[apps.models.app_types.custom.custom.validate_default_url_subpath], | ||
), | ||
), | ||
] |
20 changes: 20 additions & 0 deletions
20
apps/migrations/0019_alter_shinyinstance_shiny_site_dir.py
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,20 @@ | ||
# Generated by Django 5.1.1 on 2024-11-27 12:47 | ||
|
||
import apps.models.app_types.shiny | ||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("apps", "0018_customappinstance_default_url_subpath"), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name="shinyinstance", | ||
name="shiny_site_dir", | ||
field=models.CharField( | ||
blank=True, default="", max_length=255, validators=[apps.helpers.validate_path_k8s_label_compatible] | ||
), | ||
), | ||
] |
28 changes: 28 additions & 0 deletions
28
apps/migrations/0020_alter_jupyterinstance_environment_and_more.py
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,28 @@ | ||
# Generated by Django 5.1.1 on 2024-12-12 10:06 | ||
|
||
import django.db.models.deletion | ||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("apps", "0019_alter_shinyinstance_shiny_site_dir"), | ||
("projects", "0008_project_deleted_on"), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name="jupyterinstance", | ||
name="environment", | ||
field=models.ForeignKey( | ||
blank=True, null=True, on_delete=django.db.models.deletion.RESTRICT, to="projects.environment" | ||
), | ||
), | ||
migrations.AlterField( | ||
model_name="rstudioinstance", | ||
name="environment", | ||
field=models.ForeignKey( | ||
blank=True, null=True, on_delete=django.db.models.deletion.RESTRICT, to="projects.environment" | ||
), | ||
), | ||
] |
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,11 +1,40 @@ | ||
import regex as re | ||
from django.core.exceptions import ValidationError | ||
from django.db import models | ||
|
||
from apps.models import AppInstanceManager, BaseAppInstance | ||
|
||
from .base import AbstractCustomAppInstance | ||
|
||
|
||
def validate_default_url_subpath(candidate): | ||
""" | ||
Validates a custom default url path addition. | ||
The RegexValidator will raise a ValidationError if the input does not match the regular expression. | ||
It is up to the caller to handle the raised exception if desired. | ||
""" | ||
error_message = ( | ||
"Your custom URL subpath is not valid, please correct it. " | ||
"It must be 1-53 characters long." | ||
" It can contain only Unicode letters, digits, hyphens" | ||
" ( - ), forward slashes ( / ), and underscores ( _ )." | ||
" It cannot start or end with a hyphen ( - ) and " | ||
"cannot start with a forward slash ( / )." | ||
" It cannot contain consecutive forward slashes ( // )." | ||
) | ||
|
||
pattern = r"^(?!-)(?!/)(?!.*//)[\p{Letter}\p{Mark}0-9-/_]{1,53}(?<!-)$|^$" | ||
|
||
if not re.match(pattern, candidate): | ||
raise ValidationError(error_message) | ||
|
||
|
||
class CustomAppInstanceManager(AppInstanceManager): | ||
model_type = "customappinstance" | ||
|
||
|
||
class CustomAppInstance(AbstractCustomAppInstance, BaseAppInstance): | ||
default_url_subpath = models.CharField( | ||
validators=[validate_default_url_subpath], max_length=255, default="", blank=True | ||
) | ||
objects = CustomAppInstanceManager() |
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
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
Oops, something went wrong.