Browse Source

Add fields to track member creation and edit datetimes (#48)

* Add created and updated fields.
issue52
Drew Larson 8 years ago
committed by GitHub
parent
commit
3ddaed0041
  1. 6
      bikeshop_project/registration/admin.py
  2. 27
      bikeshop_project/registration/migrations/0004_auto_20170518_0332.py
  3. 2
      bikeshop_project/registration/models.py

6
bikeshop_project/registration/admin.py

@ -33,6 +33,6 @@ class CustomUserAdmin(UserAdmin):
@admin.register(Member)
class MemberAdmin(admin.ModelAdmin):
list_display = ('get_full_name',)
ordering = ('last_name',)
search_fields = ('email', 'first_name', 'last_name')
list_display = ('get_full_name', 'created_at',)
ordering = ('last_name', )
search_fields = ('email', 'first_name', 'last_name', 'created_at')

27
bikeshop_project/registration/migrations/0004_auto_20170518_0332.py

@ -0,0 +1,27 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.10.4 on 2017-05-18 03:32
from __future__ import unicode_literals
from django.db import migrations, models
import django.utils.timezone
class Migration(migrations.Migration):
dependencies = [
('registration', '0003_auto_20170215_0308'),
]
operations = [
migrations.AddField(
model_name='member',
name='created_at',
field=models.DateTimeField(auto_now_add=True, default=django.utils.timezone.now),
preserve_default=False,
),
migrations.AddField(
model_name='member',
name='modified_at',
field=models.DateTimeField(auto_now=True),
),
]

2
bikeshop_project/registration/models.py

@ -96,6 +96,8 @@ class Member(models.Model):
notes = models.TextField(null=True, blank=True)
suspended = models.BooleanField(default=False)
banned = models.BooleanField(default=False)
created_at = models.DateTimeField(auto_now_add=True)
modified_at = models.DateTimeField(auto_now=True)
def get_full_name(self):
# The user is identified by their email address

Loading…
Cancel
Save