Adds site invite created date

This commit is contained in:
Mouse Reeve 2021-01-05 11:37:48 -08:00
parent b861a3025b
commit c8d53ee0df
3 changed files with 23 additions and 1 deletions

View file

@ -0,0 +1,20 @@
# Generated by Django 3.0.7 on 2021-01-05 19:08
from django.db import migrations, models
import django.utils.timezone
class Migration(migrations.Migration):
dependencies = [
('bookwyrm', '0032_auto_20210104_2055'),
]
operations = [
migrations.AddField(
model_name='siteinvite',
name='created_date',
field=models.DateTimeField(auto_now_add=True, default=django.utils.timezone.now),
preserve_default=False,
),
]

View file

@ -50,6 +50,7 @@ def new_access_code():
class SiteInvite(models.Model):
''' gives someone access to create an account on the instance '''
created_date = models.DateTimeField(auto_now_add=True)
code = models.CharField(max_length=32, default=new_access_code)
expiry = models.DateTimeField(blank=True, null=True)
use_limit = models.IntegerField(blank=True, null=True)

View file

@ -399,7 +399,8 @@ def manage_invites(request):
''' invite management page '''
data = {
'title': 'Invitations',
'invites': models.SiteInvite.objects.filter(user=request.user),
'invites': models.SiteInvite.objects.filter(
user=request.user).order_by('-created_date'),
'form': forms.CreateInviteForm(),
}
return TemplateResponse(request, 'manage_invites.html', data)