From c49fe5a176c6f730f8779ba9ea54fab17b7f76e9 Mon Sep 17 00:00:00 2001 From: Drew Larson Date: Wed, 28 Jun 2017 19:24:14 -0600 Subject: [PATCH 1/3] Upgrade base requirements. --- requirements/base.txt | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/requirements/base.txt b/requirements/base.txt index 90a0ad5..89dd120 100644 --- a/requirements/base.txt +++ b/requirements/base.txt @@ -1,16 +1,16 @@ -Django==1.10.4 -pytz==2015.7 +Django==1.11.2 +pytz==2017.2 # Updated from 2015.7 django-widget-tweaks==1.4.1 -psycopg2==2.6.1 -django-libsass==0.6 -django_compressor==2.0 -python-dateutil==2.5.3 +psycopg2==2.7.1 # Updated from 2.6.1 +django-libsass==0.7 # Updated from 0.6 +django_compressor==2.1.1 # Updated from 2.0 +python-dateutil==2.6.0 # Updated from 2.5.3 whoosh==2.7.4 -django-haystack==2.5.1 +django-haystack==2.6.1 # Updated from 2.5.1 djangorestframework django-webpack-loader requests PyYAML -djangorestframework-jwt==1.9.0 -django-multiselectfield==0.1.4 -mailchimp3==2.0.11 +djangorestframework-jwt==1.11.0 # Updated from 1.9.0 +django-multiselectfield==0.1.7 # Updated from 0.1.4 +mailchimp3==2.0.14 # Updated from 2.0.11 From f8902152b82804656be31b8adcb4df2b8f97faac Mon Sep 17 00:00:00 2001 From: Drew Larson Date: Wed, 28 Jun 2017 19:24:56 -0600 Subject: [PATCH 2/3] Add property. --- bikeshop_project/registration/models.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/bikeshop_project/registration/models.py b/bikeshop_project/registration/models.py index 4780846..9eec538 100644 --- a/bikeshop_project/registration/models.py +++ b/bikeshop_project/registration/models.py @@ -109,6 +109,10 @@ class Member(models.Model): modified_at = models.DateTimeField(auto_now=True) involvement = MultiSelectField(choices=involvement_choices, null=True, blank=True) + @property + def full_name(self): + return self.get_full_name() + def get_full_name(self): # The user is identified by their email address return '{0} {1}'.format(self.first_name, self.last_name) From 8a1fcda9a1a7a1e2b5708aadbe83a8b09898dcda Mon Sep 17 00:00:00 2001 From: Drew Larson Date: Wed, 28 Jun 2017 19:25:18 -0600 Subject: [PATCH 3/3] Better search, filtering, and display. --- bikeshop_project/core/admin.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/bikeshop_project/core/admin.py b/bikeshop_project/core/admin.py index d4610b4..a7ee821 100644 --- a/bikeshop_project/core/admin.py +++ b/bikeshop_project/core/admin.py @@ -7,5 +7,17 @@ admin.site.register([Membership, Payment]) @admin.register(Visit) class VisitAdmin(admin.ModelAdmin): + list_select_related = ('member',) + fields = ('member', 'purpose', 'created_at') ordering = ('created_at',) - list_display = ('member', 'purpose', 'created_at') + list_display = ('full_name', 'purpose', 'created_at') + list_filter = ( + ('purpose', admin.ChoicesFieldListFilter), + ) + + search_fields = ['member__email', 'member__last_name', 'member__first_name'] + + def full_name(self, obj): + return obj.member.full_name + + full_name.admin_order_field = 'member__last_name'