diff --git a/cookbook/admin.py b/cookbook/admin.py index e9613ec0..3d52ac2b 100644 --- a/cookbook/admin.py +++ b/cookbook/admin.py @@ -166,7 +166,7 @@ admin.site.register(ViewLog, ViewLogAdmin) class InviteLinkAdmin(admin.ModelAdmin): list_display = ( - 'username', 'group', 'valid_until', + 'group', 'valid_until', 'created_by', 'created_at', 'used_by' ) diff --git a/cookbook/forms.py b/cookbook/forms.py index 71d664e7..d96ba164 100644 --- a/cookbook/forms.py +++ b/cookbook/forms.py @@ -413,19 +413,11 @@ class InviteLinkForm(forms.ModelForm): return email - def clean_username(self): - username = self.cleaned_data['username'] - with scopes_disabled(): - if username != '' and (User.objects.filter(username=username).exists() or InviteLink.objects.filter(username=username).exists()): - raise ValidationError(_('Username already taken!')) - return username - class Meta: model = InviteLink - fields = ('username', 'email', 'group', 'valid_until', 'space') + fields = ('email', 'group', 'valid_until', 'space') help_texts = { - 'username': _('A username is not required, if left blank the new user can choose one.'), - 'email': _('An email address is not required but if present the invite link will be send to the user.') + 'email': _('An email address is not required but if present the invite link will be send to the user.'), } field_classes = { 'space': SafeModelChoiceField, diff --git a/cookbook/helper/scope_middleware.py b/cookbook/helper/scope_middleware.py index c7de19dd..809a7eb1 100644 --- a/cookbook/helper/scope_middleware.py +++ b/cookbook/helper/scope_middleware.py @@ -16,7 +16,10 @@ class ScopeMiddleware: with scopes_disabled(): return self.get_response(request) - if request.path.startswith('/signup/'): + if request.path.startswith('/signup/') or request.path.startswith('/invite/'): + return self.get_response(request) + + if request.path.startswith('/accounts/'): return self.get_response(request) with scopes_disabled(): diff --git a/cookbook/migrations/0127_remove_invitelink_username.py b/cookbook/migrations/0127_remove_invitelink_username.py new file mode 100644 index 00000000..ffb25260 --- /dev/null +++ b/cookbook/migrations/0127_remove_invitelink_username.py @@ -0,0 +1,17 @@ +# Generated by Django 3.2.3 on 2021-06-07 14:21 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('cookbook', '0126_alter_userpreference_theme'), + ] + + operations = [ + migrations.RemoveField( + model_name='invitelink', + name='username', + ), + ] diff --git a/cookbook/models.py b/cookbook/models.py index 3a7997e8..3f198e64 100644 --- a/cookbook/models.py +++ b/cookbook/models.py @@ -612,7 +612,6 @@ def default_valid_until(): class InviteLink(ExportModelOperationsMixin('invite_link'), models.Model, PermissionModelMixin): uuid = models.UUIDField(default=uuid.uuid4) - username = models.CharField(blank=True, max_length=64) email = models.EmailField(blank=True) group = models.ForeignKey(Group, on_delete=models.CASCADE) valid_until = models.DateField(default=default_valid_until) diff --git a/cookbook/tables.py b/cookbook/tables.py index 3872ea13..2adf47a7 100644 --- a/cookbook/tables.py +++ b/cookbook/tables.py @@ -141,7 +141,7 @@ class ShoppingListTable(tables.Table): class InviteLinkTable(tables.Table): link = tables.TemplateColumn( - "" + "" ) delete_link = tables.TemplateColumn( "" + _('Delete') + "", verbose_name=_('Delete') diff --git a/cookbook/templates/account/signup.html b/cookbook/templates/account/signup.html index f124621b..e6785b7d 100644 --- a/cookbook/templates/account/signup.html +++ b/cookbook/templates/account/signup.html @@ -25,6 +25,9 @@