diff --git a/pretalx_musicrate/migrations/0003_musicratesettings_join_token.py b/pretalx_musicrate/migrations/0003_musicratesettings_join_token.py new file mode 100644 index 0000000..3dc3fa9 --- /dev/null +++ b/pretalx_musicrate/migrations/0003_musicratesettings_join_token.py @@ -0,0 +1,21 @@ +# Generated by Django 4.2.8 on 2023-12-15 01:30 + +from django.db import migrations, models + +import pretalx_musicrate.models + + +class Migration(migrations.Migration): + dependencies = [ + ("pretalx_musicrate", "0002_musicratesettings_genre_question_and_more"), + ] + + operations = [ + migrations.AddField( + model_name="musicratesettings", + name="join_token", + field=models.CharField( + default=pretalx_musicrate.models.generate_token, max_length=43 + ), + ), + ] diff --git a/pretalx_musicrate/models.py b/pretalx_musicrate/models.py index fc0e771..39a5d28 100644 --- a/pretalx_musicrate/models.py +++ b/pretalx_musicrate/models.py @@ -1,7 +1,13 @@ +from secrets import token_urlsafe + from django.db import models from django.utils.translation import gettext_lazy as _ +def generate_token(): + return token_urlsafe(32) + + class MusicrateSettings(models.Model): event = models.OneToOneField( to="event.Event", @@ -33,3 +39,4 @@ class MusicrateSettings(models.Model): blank=True, null=True, ) + join_token = models.CharField(max_length=43, default=generate_token)