From 300b932daa1c6b3c95f1725a854988262d18ea48 Mon Sep 17 00:00:00 2001 From: Luca Date: Fri, 15 Dec 2023 02:32:20 +0100 Subject: [PATCH] feat(settings): add join token --- .../0003_musicratesettings_join_token.py | 21 +++++++++++++++++++ pretalx_musicrate/models.py | 7 +++++++ 2 files changed, 28 insertions(+) create mode 100644 pretalx_musicrate/migrations/0003_musicratesettings_join_token.py 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)