-
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.
- Loading branch information
Showing
15 changed files
with
284 additions
and
11 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
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,53 @@ | ||
from django.contrib.auth import get_user_model | ||
from django.core.management.base import BaseCommand | ||
from django.conf import settings | ||
import os | ||
from fakts import models, base_models | ||
import yaml | ||
from fakts.scan import scan | ||
from fakts.backends.instances import registry | ||
|
||
|
||
# import required module | ||
from pathlib import Path | ||
|
||
|
||
# assign directory | ||
directory = "files" | ||
|
||
# iterate over files in | ||
# that directory | ||
|
||
|
||
class Command(BaseCommand): | ||
help = "Creates an admin user non-interactively if it doesn't exist" | ||
|
||
def handle(self, *args, **kwargs): | ||
|
||
TOKENS = settings.REDEEM_TOKENS | ||
|
||
for token in TOKENS: | ||
|
||
user = get_user_model().objects.get(username=token["user"]) | ||
|
||
token, _ = models.RedeemToken.objects.update_or_create( | ||
token=token["token"], | ||
defaults={ | ||
"user": user, | ||
} | ||
) | ||
|
||
print(f"Token {token} created for user {user}") | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
69 changes: 69 additions & 0 deletions
69
fakts/migrations/0007_alter_devicecode_staging_kind_redeemtoken.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,69 @@ | ||
# Generated by Django 4.2.5 on 2024-04-02 10:29 | ||
|
||
from django.conf import settings | ||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
import django_choices_field.fields | ||
import fakts.enums | ||
import uuid | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
migrations.swappable_dependency(settings.AUTH_USER_MODEL), | ||
("fakts", "0006_alter_release_requirements_instanceconfig_and_more"), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name="devicecode", | ||
name="staging_kind", | ||
field=django_choices_field.fields.TextChoicesField( | ||
choices=[ | ||
("website", "WEBSITE (Value represent WEBSITE)"), | ||
("development", "DEVELOPMENT (Value represent DEVELOPMENT)"), | ||
("desktop", "DESKTOP (Value represent DESKTOP Aüü)"), | ||
], | ||
choices_enum=fakts.enums.ClientKindChoices, | ||
default="development", | ||
help_text="The kind of staging client", | ||
max_length=11, | ||
), | ||
), | ||
migrations.CreateModel( | ||
name="RedeemToken", | ||
fields=[ | ||
( | ||
"id", | ||
models.BigAutoField( | ||
auto_created=True, | ||
primary_key=True, | ||
serialize=False, | ||
verbose_name="ID", | ||
), | ||
), | ||
( | ||
"token", | ||
models.CharField(default=uuid.uuid4, max_length=1000, unique=True), | ||
), | ||
("created_at", models.DateTimeField(auto_now_add=True)), | ||
("expires_at", models.DateTimeField(null=True)), | ||
( | ||
"client", | ||
models.OneToOneField( | ||
on_delete=django.db.models.deletion.CASCADE, | ||
related_name="redeemed_client", | ||
to="fakts.client", | ||
), | ||
), | ||
( | ||
"user", | ||
models.ForeignKey( | ||
on_delete=django.db.models.deletion.CASCADE, | ||
related_name="issued_tokens", | ||
to=settings.AUTH_USER_MODEL, | ||
), | ||
), | ||
], | ||
), | ||
] |
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 4.2.5 on 2024-04-02 10:30 | ||
|
||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("fakts", "0007_alter_devicecode_staging_kind_redeemtoken"), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name="redeemtoken", | ||
name="client", | ||
field=models.OneToOneField( | ||
null=True, | ||
on_delete=django.db.models.deletion.CASCADE, | ||
related_name="redeemed_client", | ||
to="fakts.client", | ||
), | ||
), | ||
] |
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
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