createsonline 0.1.26__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- createsonline/__init__.py +46 -0
- createsonline/admin/__init__.py +7 -0
- createsonline/admin/content.py +526 -0
- createsonline/admin/crud.py +805 -0
- createsonline/admin/field_builder.py +559 -0
- createsonline/admin/integration.py +482 -0
- createsonline/admin/interface.py +2562 -0
- createsonline/admin/model_creator.py +513 -0
- createsonline/admin/model_manager.py +388 -0
- createsonline/admin/modern_dashboard.py +498 -0
- createsonline/admin/permissions.py +264 -0
- createsonline/admin/user_forms.py +594 -0
- createsonline/ai/__init__.py +202 -0
- createsonline/ai/fields.py +1226 -0
- createsonline/ai/orm.py +325 -0
- createsonline/ai/services.py +1244 -0
- createsonline/app.py +506 -0
- createsonline/auth/__init__.py +8 -0
- createsonline/auth/management.py +228 -0
- createsonline/auth/models.py +552 -0
- createsonline/cli/__init__.py +5 -0
- createsonline/cli/commands/__init__.py +122 -0
- createsonline/cli/commands/database.py +416 -0
- createsonline/cli/commands/info.py +173 -0
- createsonline/cli/commands/initdb.py +218 -0
- createsonline/cli/commands/project.py +545 -0
- createsonline/cli/commands/serve.py +173 -0
- createsonline/cli/commands/shell.py +93 -0
- createsonline/cli/commands/users.py +148 -0
- createsonline/cli/main.py +2041 -0
- createsonline/cli/manage.py +274 -0
- createsonline/config/__init__.py +9 -0
- createsonline/config/app.py +2577 -0
- createsonline/config/database.py +179 -0
- createsonline/config/docs.py +384 -0
- createsonline/config/errors.py +160 -0
- createsonline/config/orm.py +43 -0
- createsonline/config/request.py +93 -0
- createsonline/config/settings.py +176 -0
- createsonline/data/__init__.py +23 -0
- createsonline/data/dataframe.py +925 -0
- createsonline/data/io.py +453 -0
- createsonline/data/series.py +557 -0
- createsonline/database/__init__.py +60 -0
- createsonline/database/abstraction.py +440 -0
- createsonline/database/assistant.py +585 -0
- createsonline/database/fields.py +442 -0
- createsonline/database/migrations.py +132 -0
- createsonline/database/models.py +604 -0
- createsonline/database.py +438 -0
- createsonline/http/__init__.py +28 -0
- createsonline/http/client.py +535 -0
- createsonline/ml/__init__.py +55 -0
- createsonline/ml/classification.py +552 -0
- createsonline/ml/clustering.py +680 -0
- createsonline/ml/metrics.py +542 -0
- createsonline/ml/neural.py +560 -0
- createsonline/ml/preprocessing.py +784 -0
- createsonline/ml/regression.py +501 -0
- createsonline/performance/__init__.py +19 -0
- createsonline/performance/cache.py +444 -0
- createsonline/performance/compression.py +335 -0
- createsonline/performance/core.py +419 -0
- createsonline/project_init.py +789 -0
- createsonline/routing.py +528 -0
- createsonline/security/__init__.py +34 -0
- createsonline/security/core.py +811 -0
- createsonline/security/encryption.py +349 -0
- createsonline/server.py +295 -0
- createsonline/static/css/admin.css +263 -0
- createsonline/static/css/common.css +358 -0
- createsonline/static/css/dashboard.css +89 -0
- createsonline/static/favicon.ico +0 -0
- createsonline/static/icons/icon-128x128.png +0 -0
- createsonline/static/icons/icon-128x128.webp +0 -0
- createsonline/static/icons/icon-16x16.png +0 -0
- createsonline/static/icons/icon-16x16.webp +0 -0
- createsonline/static/icons/icon-180x180.png +0 -0
- createsonline/static/icons/icon-180x180.webp +0 -0
- createsonline/static/icons/icon-192x192.png +0 -0
- createsonline/static/icons/icon-192x192.webp +0 -0
- createsonline/static/icons/icon-256x256.png +0 -0
- createsonline/static/icons/icon-256x256.webp +0 -0
- createsonline/static/icons/icon-32x32.png +0 -0
- createsonline/static/icons/icon-32x32.webp +0 -0
- createsonline/static/icons/icon-384x384.png +0 -0
- createsonline/static/icons/icon-384x384.webp +0 -0
- createsonline/static/icons/icon-48x48.png +0 -0
- createsonline/static/icons/icon-48x48.webp +0 -0
- createsonline/static/icons/icon-512x512.png +0 -0
- createsonline/static/icons/icon-512x512.webp +0 -0
- createsonline/static/icons/icon-64x64.png +0 -0
- createsonline/static/icons/icon-64x64.webp +0 -0
- createsonline/static/image/android-chrome-192x192.png +0 -0
- createsonline/static/image/android-chrome-512x512.png +0 -0
- createsonline/static/image/apple-touch-icon.png +0 -0
- createsonline/static/image/favicon-16x16.png +0 -0
- createsonline/static/image/favicon-32x32.png +0 -0
- createsonline/static/image/favicon.ico +0 -0
- createsonline/static/image/favicon.svg +17 -0
- createsonline/static/image/icon-128x128.png +0 -0
- createsonline/static/image/icon-128x128.webp +0 -0
- createsonline/static/image/icon-16x16.png +0 -0
- createsonline/static/image/icon-16x16.webp +0 -0
- createsonline/static/image/icon-180x180.png +0 -0
- createsonline/static/image/icon-180x180.webp +0 -0
- createsonline/static/image/icon-192x192.png +0 -0
- createsonline/static/image/icon-192x192.webp +0 -0
- createsonline/static/image/icon-256x256.png +0 -0
- createsonline/static/image/icon-256x256.webp +0 -0
- createsonline/static/image/icon-32x32.png +0 -0
- createsonline/static/image/icon-32x32.webp +0 -0
- createsonline/static/image/icon-384x384.png +0 -0
- createsonline/static/image/icon-384x384.webp +0 -0
- createsonline/static/image/icon-48x48.png +0 -0
- createsonline/static/image/icon-48x48.webp +0 -0
- createsonline/static/image/icon-512x512.png +0 -0
- createsonline/static/image/icon-512x512.webp +0 -0
- createsonline/static/image/icon-64x64.png +0 -0
- createsonline/static/image/icon-64x64.webp +0 -0
- createsonline/static/image/logo-header-h100.png +0 -0
- createsonline/static/image/logo-header-h100.webp +0 -0
- createsonline/static/image/logo-header-h200@2x.png +0 -0
- createsonline/static/image/logo-header-h200@2x.webp +0 -0
- createsonline/static/image/logo.png +0 -0
- createsonline/static/js/admin.js +274 -0
- createsonline/static/site.webmanifest +35 -0
- createsonline/static/templates/admin/base.html +87 -0
- createsonline/static/templates/admin/dashboard.html +217 -0
- createsonline/static/templates/admin/model_form.html +270 -0
- createsonline/static/templates/admin/model_list.html +202 -0
- createsonline/static/test_script.js +15 -0
- createsonline/static/test_styles.css +59 -0
- createsonline/static_files.py +365 -0
- createsonline/templates/404.html +100 -0
- createsonline/templates/admin_login.html +169 -0
- createsonline/templates/base.html +102 -0
- createsonline/templates/index.html +151 -0
- createsonline/templates.py +205 -0
- createsonline/testing.py +322 -0
- createsonline/utils.py +448 -0
- createsonline/validation/__init__.py +49 -0
- createsonline/validation/fields.py +598 -0
- createsonline/validation/models.py +504 -0
- createsonline/validation/validators.py +561 -0
- createsonline/views.py +184 -0
- createsonline-0.1.26.dist-info/METADATA +46 -0
- createsonline-0.1.26.dist-info/RECORD +152 -0
- createsonline-0.1.26.dist-info/WHEEL +5 -0
- createsonline-0.1.26.dist-info/entry_points.txt +2 -0
- createsonline-0.1.26.dist-info/licenses/LICENSE +21 -0
- createsonline-0.1.26.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
"""
|
|
3
|
+
CREATESONLINE Management CLI
|
|
4
|
+
|
|
5
|
+
Similar to Django's manage.py - provides database and user management commands.
|
|
6
|
+
"""
|
|
7
|
+
import sys
|
|
8
|
+
import os
|
|
9
|
+
import logging
|
|
10
|
+
|
|
11
|
+
logger = logging.getLogger("createsonline.cli.manage")
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def main():
|
|
15
|
+
"""Main CLI entry point"""
|
|
16
|
+
if len(sys.argv) < 2:
|
|
17
|
+
print_help()
|
|
18
|
+
return
|
|
19
|
+
|
|
20
|
+
command = sys.argv[1]
|
|
21
|
+
|
|
22
|
+
if command == "migrate":
|
|
23
|
+
migrate_database()
|
|
24
|
+
elif command == "createsuperuser":
|
|
25
|
+
create_superuser()
|
|
26
|
+
elif command == "initdb":
|
|
27
|
+
init_database()
|
|
28
|
+
elif command == "shell":
|
|
29
|
+
open_shell()
|
|
30
|
+
elif command == "help":
|
|
31
|
+
print_help()
|
|
32
|
+
else:
|
|
33
|
+
logger.info(f"⌠Unknown command: {command}")
|
|
34
|
+
print_help()
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def print_help():
|
|
38
|
+
"""Print help message"""
|
|
39
|
+
logger.info("""
|
|
40
|
+
CREATESONLINE Management Commands
|
|
41
|
+
|
|
42
|
+
Usage: createsonline-admin <command>
|
|
43
|
+
|
|
44
|
+
Available commands:
|
|
45
|
+
migrate Create database tables (like Django migrate)
|
|
46
|
+
createsuperuser Create a superuser account
|
|
47
|
+
initdb Initialize database with tables and default data
|
|
48
|
+
shell Open Python shell with app context
|
|
49
|
+
help Show this help message
|
|
50
|
+
|
|
51
|
+
Examples:
|
|
52
|
+
createsonline-admin migrate
|
|
53
|
+
createsonline-admin createsuperuser
|
|
54
|
+
createsonline-admin initdb
|
|
55
|
+
""")
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def migrate_database():
|
|
59
|
+
"""Create/update database tables (like Django migrate)"""
|
|
60
|
+
logger.info("🔄 Running migrations...")
|
|
61
|
+
|
|
62
|
+
try:
|
|
63
|
+
from sqlalchemy import create_engine
|
|
64
|
+
from createsonline.auth.models import Base as AuthBase
|
|
65
|
+
# Content models now use same Base as auth models
|
|
66
|
+
|
|
67
|
+
database_url = os.getenv("DATABASE_URL", "sqlite:///./createsonline.db")
|
|
68
|
+
logger.info(f"📠Database: {database_url}")
|
|
69
|
+
|
|
70
|
+
engine = create_engine(database_url, echo=False)
|
|
71
|
+
|
|
72
|
+
logger.info("📦 Creating tables...")
|
|
73
|
+
# Import content models to register them with Base
|
|
74
|
+
try:
|
|
75
|
+
from createsonline.admin import content # This registers the models
|
|
76
|
+
except:
|
|
77
|
+
pass
|
|
78
|
+
|
|
79
|
+
AuthBase.metadata.create_all(engine)
|
|
80
|
+
|
|
81
|
+
logger.info("✅ Migrations completed successfully!")
|
|
82
|
+
logger.info(f"💾 Database: {database_url.replace('sqlite:///./', '')}")
|
|
83
|
+
|
|
84
|
+
except Exception as e:
|
|
85
|
+
logger.info(f"⌠Migration failed: {e}")
|
|
86
|
+
import traceback
|
|
87
|
+
traceback.print_exc()
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
def create_superuser():
|
|
91
|
+
"""Create a superuser (like Django createsuperuser)"""
|
|
92
|
+
logger.info("👤 Create Superuser")
|
|
93
|
+
logger.info("=" * 50)
|
|
94
|
+
|
|
95
|
+
try:
|
|
96
|
+
from sqlalchemy import create_engine
|
|
97
|
+
from sqlalchemy.orm import sessionmaker
|
|
98
|
+
from createsonline.auth.models import User, create_superuser as create_su
|
|
99
|
+
|
|
100
|
+
database_url = os.getenv("DATABASE_URL", "sqlite:///./createsonline.db")
|
|
101
|
+
engine = create_engine(database_url, echo=False)
|
|
102
|
+
SessionLocal = sessionmaker(bind=engine)
|
|
103
|
+
session = SessionLocal()
|
|
104
|
+
|
|
105
|
+
try:
|
|
106
|
+
# Get username
|
|
107
|
+
while True:
|
|
108
|
+
username = input("Username: ").strip()
|
|
109
|
+
if not username:
|
|
110
|
+
logger.info("⌠Username cannot be empty")
|
|
111
|
+
continue
|
|
112
|
+
|
|
113
|
+
# Check if user exists
|
|
114
|
+
existing = session.query(User).filter_by(username=username).first()
|
|
115
|
+
if existing:
|
|
116
|
+
logger.info(f"⌠User '{username}' already exists")
|
|
117
|
+
continue
|
|
118
|
+
|
|
119
|
+
break
|
|
120
|
+
|
|
121
|
+
# Get email
|
|
122
|
+
while True:
|
|
123
|
+
email = input("Email address: ").strip()
|
|
124
|
+
if not email:
|
|
125
|
+
logger.info("⌠Email cannot be empty")
|
|
126
|
+
continue
|
|
127
|
+
|
|
128
|
+
if '@' not in email:
|
|
129
|
+
logger.info("⌠Invalid email format")
|
|
130
|
+
continue
|
|
131
|
+
|
|
132
|
+
break
|
|
133
|
+
|
|
134
|
+
# Get password
|
|
135
|
+
import getpass
|
|
136
|
+
while True:
|
|
137
|
+
password = getpass.getpass("Password: ")
|
|
138
|
+
if not password:
|
|
139
|
+
logger.info("⌠Password cannot be empty")
|
|
140
|
+
continue
|
|
141
|
+
|
|
142
|
+
if len(password) < 8:
|
|
143
|
+
logger.info("⌠Password must be at least 8 characters")
|
|
144
|
+
continue
|
|
145
|
+
|
|
146
|
+
password_confirm = getpass.getpass("Password (again): ")
|
|
147
|
+
if password != password_confirm:
|
|
148
|
+
logger.info("⌠Passwords don't match")
|
|
149
|
+
continue
|
|
150
|
+
|
|
151
|
+
break
|
|
152
|
+
|
|
153
|
+
# Create superuser
|
|
154
|
+
user = create_su(
|
|
155
|
+
username=username,
|
|
156
|
+
email=email,
|
|
157
|
+
password=password
|
|
158
|
+
)
|
|
159
|
+
|
|
160
|
+
session.add(user)
|
|
161
|
+
session.commit()
|
|
162
|
+
|
|
163
|
+
logger.info("\n✅ Superuser created successfully!")
|
|
164
|
+
logger.info(f"👤 Username: {username}")
|
|
165
|
+
logger.info(f"📧 Email: {email}")
|
|
166
|
+
logger.info(f"\n🚀 You can now login at: http://localhost:8000/admin")
|
|
167
|
+
|
|
168
|
+
except KeyboardInterrupt:
|
|
169
|
+
logger.info("\nâš ï¸ Operation cancelled")
|
|
170
|
+
except Exception as e:
|
|
171
|
+
session.rollback()
|
|
172
|
+
logger.info(f"\n⌠Error: {e}")
|
|
173
|
+
finally:
|
|
174
|
+
session.close()
|
|
175
|
+
|
|
176
|
+
except ImportError as e:
|
|
177
|
+
logger.info(f"⌠Missing dependency: {e}")
|
|
178
|
+
logger.info("💡 Install SQLAlchemy: pip install sqlalchemy")
|
|
179
|
+
except Exception as e:
|
|
180
|
+
logger.info(f"⌠Error: {e}")
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
def init_database():
|
|
184
|
+
"""Initialize database with tables and default data"""
|
|
185
|
+
logger.info("🔧 Initializing CREATESONLINE database...")
|
|
186
|
+
logger.info("=" * 50)
|
|
187
|
+
|
|
188
|
+
# Run migrations first
|
|
189
|
+
migrate_database()
|
|
190
|
+
|
|
191
|
+
# Create default permissions
|
|
192
|
+
try:
|
|
193
|
+
from sqlalchemy import create_engine
|
|
194
|
+
from sqlalchemy.orm import sessionmaker
|
|
195
|
+
from createsonline.auth.models import Permission, create_default_permissions
|
|
196
|
+
|
|
197
|
+
database_url = os.getenv("DATABASE_URL", "sqlite:///./createsonline.db")
|
|
198
|
+
engine = create_engine(database_url, echo=False)
|
|
199
|
+
SessionLocal = sessionmaker(bind=engine)
|
|
200
|
+
session = SessionLocal()
|
|
201
|
+
|
|
202
|
+
try:
|
|
203
|
+
logger.info("\n🔠Creating default permissions...")
|
|
204
|
+
permissions = create_default_permissions()
|
|
205
|
+
|
|
206
|
+
for perm in permissions:
|
|
207
|
+
existing = session.query(Permission).filter_by(
|
|
208
|
+
codename=perm.codename,
|
|
209
|
+
content_type=perm.content_type
|
|
210
|
+
).first()
|
|
211
|
+
|
|
212
|
+
if not existing:
|
|
213
|
+
session.add(perm)
|
|
214
|
+
logger.info(f" ✅ {perm.content_type}.{perm.codename}")
|
|
215
|
+
|
|
216
|
+
session.commit()
|
|
217
|
+
logger.info("✅ Default permissions created")
|
|
218
|
+
|
|
219
|
+
except Exception as e:
|
|
220
|
+
session.rollback()
|
|
221
|
+
logger.info(f"âš ï¸ Could not create permissions: {e}")
|
|
222
|
+
finally:
|
|
223
|
+
session.close()
|
|
224
|
+
|
|
225
|
+
except Exception as e:
|
|
226
|
+
logger.info(f"âš ï¸ Could not create permissions: {e}")
|
|
227
|
+
|
|
228
|
+
# Prompt to create superuser
|
|
229
|
+
logger.info("\n" + "=" * 50)
|
|
230
|
+
response = input("Do you want to create a superuser now? [y/N] ").strip().lower()
|
|
231
|
+
|
|
232
|
+
if response in ['y', 'yes']:
|
|
233
|
+
create_superuser()
|
|
234
|
+
else:
|
|
235
|
+
logger.info("\n💡 You can create a superuser later with:")
|
|
236
|
+
logger.info(" createsonline-admin createsuperuser")
|
|
237
|
+
|
|
238
|
+
logger.info("\n✅ Database initialization complete!")
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
def open_shell():
|
|
242
|
+
"""Open interactive Python shell"""
|
|
243
|
+
logger.info("ðŸ CREATESONLINE Interactive Shell")
|
|
244
|
+
logger.info("=" * 50)
|
|
245
|
+
|
|
246
|
+
try:
|
|
247
|
+
from sqlalchemy import create_engine
|
|
248
|
+
from sqlalchemy.orm import sessionmaker
|
|
249
|
+
from createsonline.auth.models import User, Group, Permission
|
|
250
|
+
|
|
251
|
+
database_url = os.getenv("DATABASE_URL", "sqlite:///./createsonline.db")
|
|
252
|
+
engine = create_engine(database_url, echo=False)
|
|
253
|
+
SessionLocal = sessionmaker(bind=engine)
|
|
254
|
+
session = SessionLocal()
|
|
255
|
+
|
|
256
|
+
logger.info("\nImported:")
|
|
257
|
+
logger.info(" - User, Group, Permission from createsonline.auth.models")
|
|
258
|
+
logger.info(" - session (SQLAlchemy session)")
|
|
259
|
+
logger.info(f"\nDatabase: {database_url}")
|
|
260
|
+
logger.info("\nExample:")
|
|
261
|
+
logger.info(" users = session.query(User).all()")
|
|
262
|
+
logger.info(" for user in users: logger.info(user.username)")
|
|
263
|
+
logger.info()
|
|
264
|
+
|
|
265
|
+
import code
|
|
266
|
+
code.interact(local=locals())
|
|
267
|
+
|
|
268
|
+
except Exception as e:
|
|
269
|
+
logger.info(f"⌠Error: {e}")
|
|
270
|
+
|
|
271
|
+
|
|
272
|
+
if __name__ == "__main__":
|
|
273
|
+
main()
|
|
274
|
+
|