-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixed dark-them, add userdefined services (configs)
- Loading branch information
Showing
21 changed files
with
371 additions
and
41 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
from .client import * | ||
from .scan import * | ||
from .render import * | ||
from .render import * | ||
from .service import * |
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,55 @@ | ||
import hashlib | ||
import json | ||
import logging | ||
import uuid | ||
|
||
import namegenerator | ||
import strawberry | ||
import strawberry_django | ||
from ekke.types import Info | ||
|
||
from fakts import enums, inputs, models, scalars, types | ||
from fakts.base_models import DevelopmentClientConfig, Manifest, Requirement | ||
from fakts.builders import create_client | ||
from fakts.models import Composition | ||
from django.conf import settings | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
|
||
|
||
def create_user_defined_service_instance(info: Info, input: inputs.UserDefinedServiceInstanceInput) -> types.UserDefinedServiceInstance: | ||
|
||
service, _ = models.Service.objects.get_or_create( | ||
identifier=input.identifier, | ||
defaults=dict( | ||
name=input.identifier, | ||
description=" No description", | ||
), | ||
) | ||
|
||
|
||
instance, _ = models.ServiceInstance.objects.get_or_create( | ||
service=service, | ||
backend=settings.USER_DEFINED_BACKEND_NAME, | ||
identifier=service.identifier, | ||
defaults=dict( | ||
template="None" | ||
), | ||
) | ||
|
||
user_defined, _ = models.UserDefinedServiceInstance.objects.update_or_create( | ||
instance=instance, | ||
creator=info.context.request.user, | ||
defaults=dict( | ||
values=[strawberry.asdict(x) for x in input.values], | ||
), | ||
) | ||
|
||
|
||
|
||
return user_defined | ||
|
||
|
||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# Generated by Django 4.2.5 on 2024-12-09 10:28 | ||
|
||
from django.conf import settings | ||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
migrations.swappable_dependency(settings.AUTH_USER_MODEL), | ||
("fakts", "0009_client_redirect_uris"), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name="UserDefinedServiceInstance", | ||
fields=[ | ||
( | ||
"id", | ||
models.BigAutoField( | ||
auto_created=True, | ||
primary_key=True, | ||
serialize=False, | ||
verbose_name="ID", | ||
), | ||
), | ||
("values", models.JSONField(default=dict)), | ||
( | ||
"creator", | ||
models.ForeignKey( | ||
on_delete=django.db.models.deletion.CASCADE, | ||
related_name="services", | ||
to=settings.AUTH_USER_MODEL, | ||
), | ||
), | ||
( | ||
"instance", | ||
models.OneToOneField( | ||
on_delete=django.db.models.deletion.CASCADE, | ||
related_name="user_defined", | ||
to="fakts.serviceinstance", | ||
), | ||
), | ||
], | ||
), | ||
] |
27 changes: 27 additions & 0 deletions
27
fakts/migrations/0011_alter_userdefinedserviceinstance_instance_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,27 @@ | ||
# Generated by Django 4.2.5 on 2024-12-09 10:32 | ||
|
||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("fakts", "0010_userdefinedserviceinstance"), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name="userdefinedserviceinstance", | ||
name="instance", | ||
field=models.ForeignKey( | ||
on_delete=django.db.models.deletion.CASCADE, | ||
related_name="defined", | ||
to="fakts.serviceinstance", | ||
), | ||
), | ||
migrations.AlterField( | ||
model_name="userdefinedserviceinstance", | ||
name="values", | ||
field=models.JSONField(default=list), | ||
), | ||
] |
22 changes: 22 additions & 0 deletions
22
fakts/migrations/0012_alter_userdefinedserviceinstance_instance.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,22 @@ | ||
# Generated by Django 4.2.5 on 2024-12-09 13:28 | ||
|
||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("fakts", "0011_alter_userdefinedserviceinstance_instance_and_more"), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name="userdefinedserviceinstance", | ||
name="instance", | ||
field=models.ForeignKey( | ||
on_delete=django.db.models.deletion.CASCADE, | ||
related_name="user_definitions", | ||
to="fakts.serviceinstance", | ||
), | ||
), | ||
] |
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.