-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Make level moderation proactive (#1773)
* feat: Make level moderation proactive * Clean * Migration * Remove icon and fix redirect * Fix tests * Reuse variable * Student can only access approved levels * Approval needed by default, set exceptions and constraints * Logic fixes * Notify teacher on creation
- Loading branch information
1 parent
d8e9cc7
commit 42196e2
Showing
20 changed files
with
684 additions
and
550 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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,18 @@ | ||
# Generated by Django 4.2.18 on 2025-02-10 20:18 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("game", "0112_worksheet_locked_classes"), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name="level", | ||
name="needs_approval", | ||
field=models.BooleanField(default=True), | ||
), | ||
] |
31 changes: 31 additions & 0 deletions
31
game/migrations/0114_default_and_non_student_levels_no_approval.py
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,31 @@ | ||
from django.apps.registry import Apps | ||
from django.db import migrations | ||
from django.db.models import Q | ||
|
||
|
||
def mark_default_and_non_student_levels_as_not_needing_approval(apps: Apps, *args): | ||
Level = apps.get_model("game", "Level") | ||
|
||
Level.objects.filter(Q(default=True) | Q(owner__user__email__isnull=False)).update( | ||
needs_approval=False | ||
) | ||
|
||
|
||
def unmark_default_and_non_student_levels_as_not_needing_approval(apps: Apps, *args): | ||
Level = apps.get_model("game", "Level") | ||
|
||
Level.objects.filter(Q(default=True) | Q(owner__user__email__isnull=False)).update( | ||
needs_approval=True | ||
) | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [("game", "0113_level_needs_approval")] | ||
|
||
operations = [ | ||
migrations.RunPython( | ||
code=mark_default_and_non_student_levels_as_not_needing_approval, | ||
reverse_code=unmark_default_and_non_student_levels_as_not_needing_approval, | ||
) | ||
] |
22 changes: 22 additions & 0 deletions
22
game/migrations/0115_level_level__default_does_not_need_approval.py
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,22 @@ | ||
# Generated by Django 4.2.18 on 2025-02-14 15:40 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("game", "0114_default_and_non_student_levels_no_approval"), | ||
] | ||
|
||
operations = [ | ||
migrations.AddConstraint( | ||
model_name="level", | ||
constraint=models.CheckConstraint( | ||
check=models.Q( | ||
("default", True), ("needs_approval", True), _negated=True | ||
), | ||
name="level__default_does_not_need_approval", | ||
), | ||
), | ||
] |
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
Large diffs are not rendered by default.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,5 +1,6 @@ | ||
.tableWrapper { | ||
width: 100%; | ||
.tableWrapper, | ||
#moderateTable { | ||
width: 100% !important; | ||
} | ||
|
||
div.DTFC_LeftBodyLiner, | ||
|
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
Oops, something went wrong.