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,218 @@
|
|
|
1
|
+
# createsonline/cli/commands/initdb.py
|
|
2
|
+
"""
|
|
3
|
+
Database initialization command
|
|
4
|
+
|
|
5
|
+
Creates all tables and initial data.
|
|
6
|
+
"""
|
|
7
|
+
import os
|
|
8
|
+
import sys
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def init_database():
|
|
12
|
+
"""Initialize database with all tables"""
|
|
13
|
+
print("š§ Initializing CREATESONLINE database...")
|
|
14
|
+
|
|
15
|
+
try:
|
|
16
|
+
from sqlalchemy import create_engine
|
|
17
|
+
from createsonline.auth.models import Base as AuthBase, User, Group, Permission, create_default_permissions, create_superuser
|
|
18
|
+
from createsonline.admin.content import Base as ContentBase
|
|
19
|
+
|
|
20
|
+
# Get database URL
|
|
21
|
+
database_url = os.getenv("DATABASE_URL", "sqlite:///./createsonline.db")
|
|
22
|
+
print(f"š Database: {database_url}")
|
|
23
|
+
|
|
24
|
+
# Create engine
|
|
25
|
+
engine = create_engine(database_url, echo=True)
|
|
26
|
+
|
|
27
|
+
# Create all tables
|
|
28
|
+
print("\nš¦ Creating tables...")
|
|
29
|
+
AuthBase.metadata.create_all(engine)
|
|
30
|
+
ContentBase.metadata.create_all(engine)
|
|
31
|
+
print("ā
Tables created successfully")
|
|
32
|
+
|
|
33
|
+
# Create session
|
|
34
|
+
from sqlalchemy.orm import sessionmaker
|
|
35
|
+
SessionLocal = sessionmaker(bind=engine)
|
|
36
|
+
session = SessionLocal()
|
|
37
|
+
|
|
38
|
+
try:
|
|
39
|
+
# Create default permissions
|
|
40
|
+
print("\nš Creating default permissions...")
|
|
41
|
+
permissions = create_default_permissions()
|
|
42
|
+
for perm in permissions:
|
|
43
|
+
# Check if permission already exists
|
|
44
|
+
existing = session.query(Permission).filter_by(
|
|
45
|
+
codename=perm.codename,
|
|
46
|
+
content_type=perm.content_type
|
|
47
|
+
).first()
|
|
48
|
+
|
|
49
|
+
if not existing:
|
|
50
|
+
session.add(perm)
|
|
51
|
+
print(f" ā
Created permission: {perm.content_type}.{perm.codename}")
|
|
52
|
+
|
|
53
|
+
session.commit()
|
|
54
|
+
print("ā
Default permissions created")
|
|
55
|
+
|
|
56
|
+
# Check if superuser exists
|
|
57
|
+
superuser = session.query(User).filter_by(is_superuser=True).first()
|
|
58
|
+
|
|
59
|
+
if not superuser:
|
|
60
|
+
print("\nš¤ No superuser found. Let's create one!")
|
|
61
|
+
username = input("Username (admin): ").strip() or "admin"
|
|
62
|
+
email = input("Email (admin@createsonline.com): ").strip() or "admin@createsonline.com"
|
|
63
|
+
password = input("Password: ").strip()
|
|
64
|
+
|
|
65
|
+
if not password:
|
|
66
|
+
print("ā Password cannot be empty")
|
|
67
|
+
return False
|
|
68
|
+
|
|
69
|
+
# Create superuser
|
|
70
|
+
superuser = create_superuser(
|
|
71
|
+
username=username,
|
|
72
|
+
email=email,
|
|
73
|
+
password=password
|
|
74
|
+
)
|
|
75
|
+
|
|
76
|
+
session.add(superuser)
|
|
77
|
+
session.commit()
|
|
78
|
+
|
|
79
|
+
print(f"ā
Superuser '{username}' created successfully!")
|
|
80
|
+
print(f"\nš Login credentials:")
|
|
81
|
+
print(f" Username: {username}")
|
|
82
|
+
print(f" Password: {password}")
|
|
83
|
+
print(f"\nš Start your server and login at /admin")
|
|
84
|
+
else:
|
|
85
|
+
print(f"\nā
Superuser already exists: {superuser.username}")
|
|
86
|
+
|
|
87
|
+
# Migrate from superuser.json if exists
|
|
88
|
+
if os.path.exists("superuser.json"):
|
|
89
|
+
print("\nš¦ Found superuser.json - migrating...")
|
|
90
|
+
import json
|
|
91
|
+
with open("superuser.json", "r") as f:
|
|
92
|
+
data = json.load(f)
|
|
93
|
+
|
|
94
|
+
# Check if user already exists
|
|
95
|
+
existing_user = session.query(User).filter_by(username=data["username"]).first()
|
|
96
|
+
|
|
97
|
+
if not existing_user:
|
|
98
|
+
migrated_user = User(
|
|
99
|
+
username=data["username"],
|
|
100
|
+
email=f"{data['username']}@createsonline.com",
|
|
101
|
+
password_hash=data["password_hash"],
|
|
102
|
+
is_staff=True,
|
|
103
|
+
is_superuser=True,
|
|
104
|
+
is_active=True,
|
|
105
|
+
email_verified=True
|
|
106
|
+
)
|
|
107
|
+
session.add(migrated_user)
|
|
108
|
+
session.commit()
|
|
109
|
+
print(f"ā
Migrated user from superuser.json: {data['username']}")
|
|
110
|
+
else:
|
|
111
|
+
print(f"ā ļø User {data['username']} already exists - skipping migration")
|
|
112
|
+
|
|
113
|
+
print("\nā
Database initialized successfully!")
|
|
114
|
+
print("š You can now run your CREATESONLINE application")
|
|
115
|
+
|
|
116
|
+
return True
|
|
117
|
+
|
|
118
|
+
except Exception as e:
|
|
119
|
+
session.rollback()
|
|
120
|
+
print(f"\nā Error: {e}")
|
|
121
|
+
import traceback
|
|
122
|
+
traceback.print_exc()
|
|
123
|
+
return False
|
|
124
|
+
finally:
|
|
125
|
+
session.close()
|
|
126
|
+
|
|
127
|
+
except ImportError as e:
|
|
128
|
+
print(f"\nā Missing dependency: {e}")
|
|
129
|
+
print("š” Install SQLAlchemy: pip install sqlalchemy")
|
|
130
|
+
return False
|
|
131
|
+
except Exception as e:
|
|
132
|
+
print(f"\nā Error: {e}")
|
|
133
|
+
import traceback
|
|
134
|
+
traceback.print_exc()
|
|
135
|
+
return False
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
def create_superuser_command():
|
|
139
|
+
"""Create a new superuser"""
|
|
140
|
+
print("š¤ Creating CREATESONLINE superuser...")
|
|
141
|
+
|
|
142
|
+
try:
|
|
143
|
+
from sqlalchemy import create_engine
|
|
144
|
+
from sqlalchemy.orm import sessionmaker
|
|
145
|
+
from createsonline.auth.models import User, create_superuser
|
|
146
|
+
|
|
147
|
+
# Get database URL
|
|
148
|
+
database_url = os.getenv("DATABASE_URL", "sqlite:///./createsonline.db")
|
|
149
|
+
print(f"š Database: {database_url}")
|
|
150
|
+
|
|
151
|
+
# Create engine
|
|
152
|
+
engine = create_engine(database_url, echo=False)
|
|
153
|
+
SessionLocal = sessionmaker(bind=engine)
|
|
154
|
+
session = SessionLocal()
|
|
155
|
+
|
|
156
|
+
try:
|
|
157
|
+
username = input("Username: ").strip()
|
|
158
|
+
if not username:
|
|
159
|
+
print("ā Username cannot be empty")
|
|
160
|
+
return False
|
|
161
|
+
|
|
162
|
+
# Check if user exists
|
|
163
|
+
existing = session.query(User).filter_by(username=username).first()
|
|
164
|
+
if existing:
|
|
165
|
+
print(f"ā User '{username}' already exists")
|
|
166
|
+
return False
|
|
167
|
+
|
|
168
|
+
email = input("Email: ").strip()
|
|
169
|
+
if not email:
|
|
170
|
+
print("ā Email cannot be empty")
|
|
171
|
+
return False
|
|
172
|
+
|
|
173
|
+
password = input("Password: ").strip()
|
|
174
|
+
if not password:
|
|
175
|
+
print("ā Password cannot be empty")
|
|
176
|
+
return False
|
|
177
|
+
|
|
178
|
+
confirm_password = input("Confirm password: ").strip()
|
|
179
|
+
if password != confirm_password:
|
|
180
|
+
print("ā Passwords do not match")
|
|
181
|
+
return False
|
|
182
|
+
|
|
183
|
+
# Create superuser
|
|
184
|
+
user = create_superuser(
|
|
185
|
+
username=username,
|
|
186
|
+
email=email,
|
|
187
|
+
password=password
|
|
188
|
+
)
|
|
189
|
+
|
|
190
|
+
session.add(user)
|
|
191
|
+
session.commit()
|
|
192
|
+
|
|
193
|
+
print(f"\nā
Superuser '{username}' created successfully!")
|
|
194
|
+
print(f"š Login at /admin with username: {username}")
|
|
195
|
+
|
|
196
|
+
return True
|
|
197
|
+
|
|
198
|
+
except Exception as e:
|
|
199
|
+
session.rollback()
|
|
200
|
+
print(f"\nā Error: {e}")
|
|
201
|
+
return False
|
|
202
|
+
finally:
|
|
203
|
+
session.close()
|
|
204
|
+
|
|
205
|
+
except ImportError as e:
|
|
206
|
+
print(f"\nā Missing dependency: {e}")
|
|
207
|
+
print("š” Install SQLAlchemy: pip install sqlalchemy")
|
|
208
|
+
return False
|
|
209
|
+
except Exception as e:
|
|
210
|
+
print(f"\nā Error: {e}")
|
|
211
|
+
return False
|
|
212
|
+
|
|
213
|
+
|
|
214
|
+
if __name__ == "__main__":
|
|
215
|
+
if len(sys.argv) > 1 and sys.argv[1] == "createsuperuser":
|
|
216
|
+
create_superuser_command()
|
|
217
|
+
else:
|
|
218
|
+
init_database()
|