This repository has been archived by the owner on Sep 13, 2021. It is now read-only.
-
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.
Merge pull request #372 from skoleapp/track-issued-codes
Track amount of issued invite codes
- Loading branch information
Showing
3 changed files
with
59 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Generated by Django 3.2 on 2021-04-12 15:46 | ||
# Manually edited to take the default value from settings. | ||
from django.conf import settings | ||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("skole", "0054_fix_sequences"), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name="invitecode", | ||
name="initial_usages", | ||
field=models.PositiveIntegerField( | ||
default=settings.INVITE_CODE_INITIAL_USAGES | ||
), | ||
), | ||
] |
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,32 @@ | ||
from django.apps.registry import Apps | ||
from django.db import migrations | ||
from django.db.backends.base.schema import BaseDatabaseSchemaEditor | ||
|
||
|
||
def forwards_func(apps: Apps, schema_editor: BaseDatabaseSchemaEditor) -> None: | ||
""" | ||
Make sure that the invite code that our 1.0 users used has no initial usages. | ||
This makes it so that we don't end up calculating k-factor so that it would | ||
incorrectly seem that any of those users got *invited* to the platform. | ||
""" | ||
|
||
InviteCode = apps.get_model("skole", "InviteCode") | ||
|
||
code = InviteCode.objects.filter(code="BETAUSER").first() | ||
if code: | ||
code.initial_usages = 0 | ||
code.save(update_fields=("initial_usages",)) | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("skole", "0055_invite_code_initial_usages"), | ||
] | ||
|
||
operations = [ | ||
migrations.RunPython( | ||
code=forwards_func, reverse_code=migrations.RunPython.noop | ||
), | ||
] |
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