-
-
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
11 changed files
with
110 additions
and
153 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,19 @@ | ||
from __future__ import annotations | ||
|
||
import importlib | ||
from typing import Any | ||
|
||
|
||
def import_module_from_str(string_path): | ||
def import_module_from_str(string_path: str) -> Any: | ||
paths = string_path.split(".") | ||
if len(paths) == 3: | ||
module = importlib.import_module(f"{paths[0]}.{paths[1]}") | ||
return getattr(module, paths[2]) | ||
elif len(paths) == 2: | ||
module = importlib.import_module(f"{paths[0]}") | ||
return getattr(module, paths[1]) | ||
else: | ||
try: | ||
module = importlib.import_module(f"{string_path}") | ||
except Exception as E: | ||
raise f"Failed to import {string_path} with \n:{E}" | ||
try: | ||
module = importlib.import_module(f"{string_path}") | ||
except Exception as e: | ||
raise Exception(f"Failed to import {string_path} with \n:{e}") | ||
return module |
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,77 @@ | ||
# Generated by Django 5.1.4 on 2025-01-13 21:28 | ||
from __future__ import annotations | ||
|
||
import uuid | ||
|
||
import django.db.models.deletion | ||
from django.conf import settings | ||
from django.db import migrations | ||
from django.db import models | ||
|
||
import django_namespaces.validators | ||
|
||
|
||
class Migration(migrations.Migration): | ||
replaces = [ | ||
("django_namespaces", "0001_initial"), | ||
("django_namespaces", "0002_alter_namespace_options_alter_namespace_slug"), | ||
("django_namespaces", "0003_alter_namespace_slug"), | ||
( | ||
"django_namespaces", | ||
"0004_alter_namespace_options_rename_slug_namespace_handle", | ||
), | ||
("django_namespaces", "0005_namespace_default"), | ||
("django_namespaces", "0006_alter_namespace_default"), | ||
] | ||
|
||
initial = True | ||
|
||
dependencies = [ | ||
migrations.swappable_dependency(settings.AUTH_USER_MODEL), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name="Namespace", | ||
fields=[ | ||
( | ||
"id", | ||
models.UUIDField( | ||
default=uuid.uuid4, | ||
editable=False, | ||
primary_key=True, | ||
serialize=False, | ||
), | ||
), | ||
( | ||
"handle", | ||
models.SlugField( | ||
help_text="Namespaces must be unique across this website.", | ||
unique=True, | ||
validators=[django_namespaces.validators.valid_project_id], | ||
), | ||
), | ||
("title", models.CharField(blank=True, max_length=255, null=True)), | ||
("description", models.TextField(blank=True, null=True)), | ||
("created_at", models.DateTimeField(auto_now_add=True)), | ||
("updated_at", models.DateTimeField(auto_now=True)), | ||
( | ||
"user", | ||
models.ForeignKey( | ||
on_delete=django.db.models.deletion.CASCADE, | ||
to=settings.AUTH_USER_MODEL, | ||
), | ||
), | ||
( | ||
"default", | ||
models.BooleanField( | ||
default=True, | ||
help_text="Default namespace for this user (only one possible)", | ||
), | ||
), | ||
], | ||
options={ | ||
"ordering": ["handle", "-updated_at", "-created_at"], | ||
}, | ||
), | ||
] |
This file was deleted.
Oops, something went wrong.
23 changes: 0 additions & 23 deletions
23
src/django_namespaces/migrations/0002_alter_namespace_options_alter_namespace_slug.py
This file was deleted.
Oops, something went wrong.
19 changes: 0 additions & 19 deletions
19
src/django_namespaces/migrations/0003_alter_namespace_slug.py
This file was deleted.
Oops, something went wrong.
22 changes: 0 additions & 22 deletions
22
...django_namespaces/migrations/0004_alter_namespace_options_rename_slug_namespace_handle.py
This file was deleted.
Oops, something went wrong.
18 changes: 0 additions & 18 deletions
18
src/django_namespaces/migrations/0005_namespace_default.py
This file was deleted.
Oops, something went wrong.
22 changes: 0 additions & 22 deletions
22
src/django_namespaces/migrations/0006_alter_namespace_default.py
This file was deleted.
Oops, something went wrong.
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