stages/invitation: fix optional field being required

This commit is contained in:
Jens Langhammer 2020-12-25 23:41:34 +01:00
parent cd8157ea08
commit 49636f8fa0
4 changed files with 32 additions and 7 deletions

View File

@ -37,8 +37,9 @@
<table class="pf-c-table pf-m-compact pf-m-grid-xl" role="grid"> <table class="pf-c-table pf-m-compact pf-m-grid-xl" role="grid">
<thead> <thead>
<tr role="row"> <tr role="row">
<th role="columnheader" scope="col">{% trans 'ID' %}</th>
<th role="columnheader" scope="col">{% trans 'Created by' %}</th>
<th role="columnheader" scope="col">{% trans 'Expiry' %}</th> <th role="columnheader" scope="col">{% trans 'Expiry' %}</th>
<th role="columnheader" scope="col">{% trans 'Link' %}</th>
<th role="cell"></th> <th role="cell"></th>
</tr> </tr>
</thead> </thead>
@ -47,12 +48,17 @@
<tr role="row"> <tr role="row">
<td role="cell"> <td role="cell">
<span> <span>
{{ invitation.expiry }} {{ invitation.invite_uuid }}
</span> </span>
</td> </td>
<td role="cell"> <td role="cell">
<span> <span>
{{ invitation.Link }} {{ invitation.created_by }}
</span>
</td>
<td role="cell">
<span>
{{ invitation.expiry|default:"-" }}
</span> </span>
</td> </td>
<td> <td>

View File

@ -25,8 +25,5 @@ class InvitationForm(forms.ModelForm):
model = Invitation model = Invitation
fields = ["expires", "fixed_data"] fields = ["expires", "fixed_data"]
labels = {
"fixed_data": _("Optional fixed data to enforce on user enrollment."),
}
widgets = {"fixed_data": CodeMirrorWidget()} widgets = {"fixed_data": CodeMirrorWidget()}
field_classes = {"fixed_data": YAMLField} field_classes = {"fixed_data": YAMLField}

View File

@ -0,0 +1,18 @@
# Generated by Django 3.1.4 on 2020-12-25 21:43
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("authentik_stages_invitation", "0001_initial"),
]
operations = [
migrations.AlterField(
model_name="invitation",
name="fixed_data",
field=models.JSONField(blank=True, default=dict),
),
]

View File

@ -61,7 +61,11 @@ class Invitation(models.Model):
created_by = models.ForeignKey(User, on_delete=models.CASCADE) created_by = models.ForeignKey(User, on_delete=models.CASCADE)
expires = models.DateTimeField(default=None, blank=True, null=True) expires = models.DateTimeField(default=None, blank=True, null=True)
fixed_data = models.JSONField(default=dict) fixed_data = models.JSONField(
default=dict,
blank=True,
help_text=_("Optional fixed data to enforce on user enrollment."),
)
def __str__(self): def __str__(self):
return f"Invitation {self.invite_uuid.hex} created by {self.created_by}" return f"Invitation {self.invite_uuid.hex} created by {self.created_by}"