-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
83 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
from django.contrib import admin | ||
from treebeard.admin import TreeAdmin | ||
from treebeard.forms import movenodeform_factory | ||
from mpicms.personal.models import Group | ||
|
||
class GroupAdmin(TreeAdmin): | ||
form = movenodeform_factory(Group) | ||
pass | ||
|
||
admin.site.register(Group, GroupAdmin) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# Generated by Django 3.1 on 2020-09-18 10:18 | ||
|
||
from django.db import migrations, models | ||
from treebeard.mp_tree import MP_Node | ||
|
||
|
||
def update_path(apps, schema_editor): | ||
|
||
class Node(MP_Node): | ||
# may overwrite, should match new model: | ||
# steplen = 4 | ||
# alphabet = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ' | ||
# node_order_by = [] | ||
pass; | ||
|
||
Group = apps.get_model("personal","Group") | ||
db_alias = schema_editor.connection.alias | ||
|
||
for i, group in enumerate(Group.objects.all(), 1): | ||
group.path = Node._get_path(None, 1, i) | ||
group.save(using=db_alias) | ||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('personal', '0026_auto_20200813_1342'), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name='group', | ||
name='depth', | ||
field=models.PositiveIntegerField(default=1), | ||
preserve_default=False, | ||
), | ||
migrations.AddField( | ||
model_name='group', | ||
name='numchild', | ||
field=models.PositiveIntegerField(default=0), | ||
), | ||
migrations.AddField( | ||
model_name='group', | ||
name='path', | ||
field=models.CharField(default='', max_length=255), | ||
preserve_default=False, | ||
), | ||
migrations.RunPython(update_path, migrations.RunPython.noop), | ||
migrations.AlterField( | ||
model_name='group', | ||
name='path', | ||
field=models.CharField(max_length=255, unique=True), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,3 +12,4 @@ markdown | |
pygments | ||
ics | ||
django-auth-ldap | ||
django-treebeard |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters