refactor python package structure
This commit is contained in:
parent
9eff769622
commit
8c9671602b
19 changed files with 56 additions and 49 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -12,4 +12,4 @@ wheels/
|
||||||
# Project specifics
|
# Project specifics
|
||||||
.env
|
.env
|
||||||
*.sqlite3
|
*.sqlite3
|
||||||
hub/media/
|
media/
|
||||||
|
|
13
hub/__main__.py
Normal file
13
hub/__main__.py
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "hub.settings")
|
||||||
|
from django.core.management import execute_from_command_line
|
||||||
|
|
||||||
|
execute_from_command_line(sys.argv)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
|
@ -1,22 +0,0 @@
|
||||||
#!/usr/bin/env python
|
|
||||||
"""Django's command-line utility for administrative tasks."""
|
|
||||||
import os
|
|
||||||
import sys
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
|
||||||
"""Run administrative tasks."""
|
|
||||||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "hub.settings")
|
|
||||||
try:
|
|
||||||
from django.core.management import execute_from_command_line
|
|
||||||
except ImportError as exc:
|
|
||||||
raise ImportError(
|
|
||||||
"Couldn't import Django. Are you sure it's installed and "
|
|
||||||
"available on your PYTHONPATH environment variable? Did you "
|
|
||||||
"forget to activate a virtual environment?"
|
|
||||||
) from exc
|
|
||||||
execute_from_command_line(sys.argv)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
main()
|
|
|
@ -3,4 +3,4 @@ from django.apps import AppConfig
|
||||||
|
|
||||||
class ServicebrokerConfig(AppConfig):
|
class ServicebrokerConfig(AppConfig):
|
||||||
default_auto_field = "django.db.models.BigAutoField"
|
default_auto_field = "django.db.models.BigAutoField"
|
||||||
name = "servicebroker"
|
name = "hub.servicebroker"
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
from rest_framework import serializers
|
from rest_framework import serializers
|
||||||
from services.models import Service, CloudProvider
|
from hub.services.models import Service, CloudProvider
|
||||||
|
|
||||||
|
|
||||||
class ServicePlanSerializer(serializers.Serializer):
|
class ServicePlanSerializer(serializers.Serializer):
|
||||||
|
|
|
@ -10,7 +10,7 @@ from .serializers import (
|
||||||
BindingRequestSerializer,
|
BindingRequestSerializer,
|
||||||
BindingResponseSerializer,
|
BindingResponseSerializer,
|
||||||
)
|
)
|
||||||
from services.models import Service
|
from hub.services.models import Service
|
||||||
|
|
||||||
|
|
||||||
class ServiceBrokerView(APIView):
|
class ServiceBrokerView(APIView):
|
||||||
|
|
|
@ -3,4 +3,4 @@ from django.apps import AppConfig
|
||||||
|
|
||||||
class ServicesConfig(AppConfig):
|
class ServicesConfig(AppConfig):
|
||||||
default_auto_field = "django.db.models.BigAutoField"
|
default_auto_field = "django.db.models.BigAutoField"
|
||||||
name = "services"
|
name = "hub.services"
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
# Generated by Django 5.1.5 on 2025-01-29 08:34
|
# Generated by Django 5.1.5 on 2025-01-29 08:34
|
||||||
|
|
||||||
import django.db.models.deletion
|
import django.db.models.deletion
|
||||||
import services.models
|
import hub.services.models
|
||||||
from django.db import migrations, models
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
@ -67,7 +67,7 @@ class Migration(migrations.Migration):
|
||||||
blank=True,
|
blank=True,
|
||||||
null=True,
|
null=True,
|
||||||
upload_to="cloud_provider_logos/",
|
upload_to="cloud_provider_logos/",
|
||||||
validators=[services.models.validate_image_size],
|
validators=[hub.services.models.validate_image_size],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
@ -190,7 +190,7 @@ class Migration(migrations.Migration):
|
||||||
blank=True,
|
blank=True,
|
||||||
null=True,
|
null=True,
|
||||||
upload_to="service_logos/",
|
upload_to="service_logos/",
|
||||||
validators=[services.models.validate_image_size],
|
validators=[hub.services.models.validate_image_size],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
("features", models.TextField()),
|
("features", models.TextField()),
|
||||||
|
@ -293,7 +293,7 @@ class Migration(migrations.Migration):
|
||||||
blank=True,
|
blank=True,
|
||||||
null=True,
|
null=True,
|
||||||
upload_to="partner_logos/",
|
upload_to="partner_logos/",
|
||||||
validators=[services.models.validate_image_size],
|
validators=[hub.services.models.validate_image_size],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
("website", models.URLField(blank=True)),
|
("website", models.URLField(blank=True)),
|
||||||
|
|
|
@ -3,13 +3,13 @@ from django.conf import settings
|
||||||
from django.shortcuts import render, get_object_or_404, redirect
|
from django.shortcuts import render, get_object_or_404, redirect
|
||||||
from django.contrib import messages
|
from django.contrib import messages
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
from services.models import (
|
from hub.services.models import (
|
||||||
Service,
|
Service,
|
||||||
ServiceOffering,
|
ServiceOffering,
|
||||||
Plan,
|
Plan,
|
||||||
)
|
)
|
||||||
from services.forms import LeadForm
|
from hub.services.forms import LeadForm
|
||||||
from services.odoo import OdooAPI
|
from hub.services.odoo import OdooAPI
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
from django.shortcuts import render, get_object_or_404
|
from django.shortcuts import render, get_object_or_404
|
||||||
from django.db.models import Q
|
from django.db.models import Q
|
||||||
from services.models import (
|
from hub.services.models import (
|
||||||
ServiceOffering,
|
ServiceOffering,
|
||||||
CloudProvider,
|
CloudProvider,
|
||||||
Category,
|
Category,
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
from django.shortcuts import render, get_object_or_404
|
from django.shortcuts import render, get_object_or_404
|
||||||
from django.db.models import Q
|
from django.db.models import Q
|
||||||
from services.models import (
|
from hub.services.models import (
|
||||||
ConsultingPartner,
|
ConsultingPartner,
|
||||||
CloudProvider,
|
CloudProvider,
|
||||||
)
|
)
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
from django.shortcuts import render, get_object_or_404
|
from django.shortcuts import render, get_object_or_404
|
||||||
from django.db.models import Q
|
from django.db.models import Q
|
||||||
from services.models import (
|
from hub.services.models import (
|
||||||
Service,
|
Service,
|
||||||
CloudProvider,
|
CloudProvider,
|
||||||
)
|
)
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
from django.shortcuts import render, get_object_or_404
|
from django.shortcuts import render, get_object_or_404
|
||||||
from django.db.models import Q
|
from django.db.models import Q
|
||||||
from services.models import (
|
from hub.services.models import (
|
||||||
Service,
|
Service,
|
||||||
ConsultingPartner,
|
ConsultingPartner,
|
||||||
CloudProvider,
|
CloudProvider,
|
||||||
|
|
|
@ -59,8 +59,8 @@ INSTALLED_APPS = [
|
||||||
"rest_framework",
|
"rest_framework",
|
||||||
"schema_viewer",
|
"schema_viewer",
|
||||||
# local
|
# local
|
||||||
"services",
|
"hub.services",
|
||||||
"servicebroker",
|
"hub.servicebroker",
|
||||||
]
|
]
|
||||||
if DEBUG:
|
if DEBUG:
|
||||||
INSTALLED_APPS += ["django_browser_reload"]
|
INSTALLED_APPS += ["django_browser_reload"]
|
||||||
|
@ -169,19 +169,19 @@ MEDIA_URL = "/media/"
|
||||||
MEDIA_ROOT = env.path("MEDIA_ROOT", default=BASE_DIR / "media")
|
MEDIA_ROOT = env.path("MEDIA_ROOT", default=BASE_DIR / "media")
|
||||||
|
|
||||||
ODOO_CONFIG = {
|
ODOO_CONFIG = {
|
||||||
"url": env.str("ODOO_URL"),
|
"url": env.str("ODOO_URL", default="http://localhost:8069"),
|
||||||
"db": env.str("ODOO_DB"),
|
"db": env.str("ODOO_DB", default="odoo"),
|
||||||
"username": env.str("ODOO_USERNAME"),
|
"username": env.str("ODOO_USERNAME", default="odoo"),
|
||||||
"password": env.str("ODOO_PASSWORD"),
|
"password": env.str("ODOO_PASSWORD", default="odoo"),
|
||||||
}
|
}
|
||||||
|
|
||||||
BROKER_USERNAME = env.str("BROKER_USERNAME")
|
BROKER_USERNAME = env.str("BROKER_USERNAME", default="broker")
|
||||||
BROKER_PASSWORD = env.str("BROKER_PASSWORD")
|
BROKER_PASSWORD = env.str("BROKER_PASSWORD", default="secret")
|
||||||
BASE_URL = "https://your-domain.com"
|
BASE_URL = "https://your-domain.com"
|
||||||
|
|
||||||
REST_FRAMEWORK = {
|
REST_FRAMEWORK = {
|
||||||
"DEFAULT_AUTHENTICATION_CLASSES": [
|
"DEFAULT_AUTHENTICATION_CLASSES": [
|
||||||
"servicebroker.authentication.ServiceBrokerAuthentication",
|
"hub.servicebroker.authentication.ServiceBrokerAuthentication",
|
||||||
],
|
],
|
||||||
"UNAUTHENTICATED_USER": None,
|
"UNAUTHENTICATED_USER": None,
|
||||||
}
|
}
|
|
@ -5,8 +5,8 @@ from django.urls import path, include
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path("admin/", admin.site.urls),
|
path("admin/", admin.site.urls),
|
||||||
path("", include("services.urls")),
|
path("", include("hub.services.urls")),
|
||||||
path("broker/", include("servicebroker.urls")),
|
path("broker/", include("hub.servicebroker.urls")),
|
||||||
]
|
]
|
||||||
if settings.DEBUG:
|
if settings.DEBUG:
|
||||||
urlpatterns += [
|
urlpatterns += [
|
16
manage.py
Executable file
16
manage.py
Executable file
|
@ -0,0 +1,16 @@
|
||||||
|
#!/usr/bin/env python
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "hub.settings")
|
||||||
|
try:
|
||||||
|
from django.core.management import execute_from_command_line
|
||||||
|
except ImportError as exc:
|
||||||
|
raise ImportError("Couldn't import Django") from exc
|
||||||
|
execute_from_command_line(sys.argv)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
Loading…
Add table
Add a link
Reference in a new issue