new applets app for cross-board usage of Applet() & UserApplet() models; dashboard migrations reset and apps reseeded w. new default specs; core.settings & many tests thru-out suite updated accordingly
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
This commit is contained in:
36
src/apps/applets/migrations/0001_initial.py
Normal file
36
src/apps/applets/migrations/0001_initial.py
Normal file
@@ -0,0 +1,36 @@
|
||||
import django.db.models.deletion
|
||||
|
||||
from django.conf import settings
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
initial = True
|
||||
dependencies = [
|
||||
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='Applet',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('slug', models.SlugField(unique=True)),
|
||||
('name', models.CharField(max_length=100)),
|
||||
('context', models.CharField(choices=[('dashboard', 'Dashboard'), ('gameboard', 'Gameboard')], default='dashboard', max_length=20)),
|
||||
('default_visible', models.BooleanField(default=True)),
|
||||
('grid_cols', models.PositiveSmallIntegerField(default=12)),
|
||||
('grid_rows', models.PositiveSmallIntegerField(default=3)),
|
||||
],
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='UserApplet',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('visible', models.BooleanField(default=True)),
|
||||
('applet', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='applets.applet')),
|
||||
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='user_applets', to=settings.AUTH_USER_MODEL)),
|
||||
],
|
||||
options={'unique_together': {('user', 'applet')}},
|
||||
),
|
||||
]
|
||||
29
src/apps/applets/migrations/0002_seed_applets.py
Normal file
29
src/apps/applets/migrations/0002_seed_applets.py
Normal file
@@ -0,0 +1,29 @@
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
def seed_applets(apps, schema_editor):
|
||||
Applet = apps.get_model('applets', 'Applet')
|
||||
for slug, name, cols, rows, context in [
|
||||
('wallet', 'Wallet', 12, 3, 'dashboard'),
|
||||
('new-list', 'New List', 9, 3, 'dashboard'),
|
||||
('my-lists', 'My Lists', 3, 3, 'dashboard'),
|
||||
('username', 'Username', 6, 3, 'dashboard'),
|
||||
('palette', 'Palette', 6, 3, 'dashboard'),
|
||||
('new-game', 'New Game', 4, 2, 'gameboard'),
|
||||
('my-games', 'My Games', 4, 4, 'gameboard'),
|
||||
('game-kit', 'Game Kit', 4, 2, 'gameboard'),
|
||||
]:
|
||||
Applet.objects.get_or_create(
|
||||
slug=slug,
|
||||
defaults={'name': name, 'grid_cols': cols, 'grid_rows': rows, 'context': context},
|
||||
)
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
dependencies = [
|
||||
('applets', '0001_initial')
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RunPython(seed_applets, migrations.RunPython.noop)
|
||||
]
|
||||
0
src/apps/applets/migrations/__init__.py
Normal file
0
src/apps/applets/migrations/__init__.py
Normal file
Reference in New Issue
Block a user