diff --git a/common/utils/mongodb.py b/common/utils/mongodb.py new file mode 100644 index 0000000..80dc3cc --- /dev/null +++ b/common/utils/mongodb.py @@ -0,0 +1,8 @@ +import mongoengine +from django.conf import settings + +def connect_colio_mongo(): + mongoengine.connect( + db=settings.MONGODB_NAME, + host=settings.MONGODB_URI + ) \ No newline at end of file diff --git a/config/settings.py b/config/settings.py index dd50230..a407419 100644 --- a/config/settings.py +++ b/config/settings.py @@ -65,6 +65,7 @@ INSTALLED_APPS = [ 'projects', 'codes', 'notifications', + 'nocodetools', ] MIDDLEWARE = [ @@ -102,6 +103,9 @@ WSGI_APPLICATION = 'config.wsgi.application' # Database # https://docs.djangoproject.com/en/5.1/ref/settings/#databases +MONGODB_URI = env("MONGODB_URI") +MONGODB_NAME = env('MONGODB_NAME') + DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql', diff --git a/nocodetools/__init__.py b/nocodetools/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/nocodetools/admin.py b/nocodetools/admin.py new file mode 100644 index 0000000..8c38f3f --- /dev/null +++ b/nocodetools/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/nocodetools/apps.py b/nocodetools/apps.py new file mode 100644 index 0000000..58fae68 --- /dev/null +++ b/nocodetools/apps.py @@ -0,0 +1,9 @@ +from django.apps import AppConfig +from common.utils.mongodb import connect_colio_mongo + +class NocodetoolsConfig(AppConfig): + # default_auto_field = 'django.db.models.BigAutoField' + name = 'nocodetools' + + def ready(self): + connect_colio_mongo() diff --git a/nocodetools/models.py b/nocodetools/models.py new file mode 100644 index 0000000..0213803 --- /dev/null +++ b/nocodetools/models.py @@ -0,0 +1,14 @@ +from django.db import models + +import mongoengine as me + +class Element(me.EmbeddedDocument): + element_type = me.StringField() + content = me.StringField() + css = me.DictField() + +class Page(me.Document): + cut = me.IntField() + elements = me.ListField(me.EmbeddedDocumentField(Element)) + created_at = me.DateTimeField() + updated_at = me.DateTimeField() \ No newline at end of file diff --git a/nocodetools/tests.py b/nocodetools/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/nocodetools/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/nocodetools/views.py b/nocodetools/views.py new file mode 100644 index 0000000..d43f642 --- /dev/null +++ b/nocodetools/views.py @@ -0,0 +1 @@ +# views.py diff --git a/requirements.txt b/requirements.txt index 5d54216..4030916 100644 Binary files a/requirements.txt and b/requirements.txt differ