Browse Source

Merge branch 'feature/member-refactor' into development

feature/python-error-tracking
Drew Larson 8 years ago
parent
commit
9e6e776a40
  1. 2
      bikeshop_project/bikeshop/settings/base.py
  2. 16
      bikeshop_project/bikeshop/utils/member_import.py
  3. 37
      bikeshop_project/core/migrations/0001_initial.py
  4. 25
      bikeshop_project/core/migrations/0002_payment.py
  5. 27
      bikeshop_project/core/migrations/0003_visit.py
  6. 31
      bikeshop_project/core/migrations/0004_auto_20160405_0354.py
  7. 30
      bikeshop_project/core/migrations/0004_auto_20160410_1816.py
  8. 16
      bikeshop_project/core/migrations/0005_merge.py
  9. 35
      bikeshop_project/core/migrations/0006_auto_20160410_1833.py
  10. 31
      bikeshop_project/core/migrations/0007_auto_20160501_2253.py
  11. 25
      bikeshop_project/core/migrations/0008_auto_20160526_0059.py
  12. 19
      bikeshop_project/core/migrations/0009_remove_membership_member.py
  13. 23
      bikeshop_project/core/migrations/0010_membership_member.py
  14. 22
      bikeshop_project/core/migrations/0011_auto_20160531_0233.py
  15. 25
      bikeshop_project/core/migrations/0012_auto_20160531_0234.py
  16. 25
      bikeshop_project/core/migrations/0013_auto_20160531_0236.py
  17. 20
      bikeshop_project/core/migrations/0014_payment_paid.py
  18. 20
      bikeshop_project/core/migrations/0015_auto_20160531_0413.py
  19. 24
      bikeshop_project/core/migrations/0016_auto_20160531_0416.py
  20. 20
      bikeshop_project/core/migrations/0017_auto_20160626_1842.py
  21. 20
      bikeshop_project/core/migrations/0018_auto_20160626_1844.py
  22. 28
      bikeshop_project/registration/admin.py
  23. 33
      bikeshop_project/registration/migrations/0001_initial.py
  24. 20
      bikeshop_project/registration/migrations/0002_member_email_consent.py
  25. 25
      bikeshop_project/registration/migrations/0003_auto_20160327_0620.py
  26. 32
      bikeshop_project/registration/migrations/0004_auto_20160410_1816.py
  27. 22
      bikeshop_project/registration/migrations/0005_member_membership.py
  28. 19
      bikeshop_project/registration/migrations/0006_remove_member_membership.py
  29. 64
      bikeshop_project/registration/models.py

2
bikeshop_project/bikeshop/settings/base.py

@ -129,7 +129,7 @@ STATICFILES_DIRS = [
STATIC_ROOT = 'static'
STATIC_URL = '/static/'
AUTH_USER_MODEL = 'registration.Member'
AUTH_USER_MODEL = 'registration.CustomUser'
COMPRESS_PRECOMPILERS = (
('text/x-scss', 'django_libsass.SassCompiler'),

16
bikeshop_project/bikeshop/utils/member_import.py

@ -23,12 +23,12 @@ def email_generator():
return '{0}.{1}@example.com'.format(*local)
def payment_type(pt):
types = Payment.payment_choices
def get_payment_type(pt):
payment_types = Payment.payment_choices
try:
return [type for type in types if type[1].lower() == pt.lower()][0]
return [payment_type for payment_type in payment_types if payment_type[1].lower() == pt.lower()][0]
except IndexError:
return ('UNKNOWN', 'Unknown')
return 'UNKNOWN', 'Unknown'
def member_import():
@ -44,7 +44,7 @@ def member_import():
try:
waiver = dateutil.parser.parse(row.get('signed', None))
except ValueError:
dob = None
waiver = None
try:
renewed_at = dateutil.parser.parse(row.get('timestamp', None))
@ -53,7 +53,7 @@ def member_import():
try:
new_member = Member.objects.create(
email=row.get('email', None) or email_generator(),
email=row.get('email', None),
email_consent=row.get('email_consent', False),
first_name=row.get('first_name'),
last_name=row.get('last_name'),
@ -70,10 +70,10 @@ def member_import():
)
payment = Payment.objects.create(
type=payment_type(row.get('payment'))[0],
type=get_payment_type(row.get('payment'))[0],
)
membership = Membership.objects.create(
Membership.objects.create(
renewed_at=renewed_at,
self_identification=row.get('self_identification', None),
gender=row.get('gender', None),

37
bikeshop_project/core/migrations/0001_initial.py

@ -1,8 +1,7 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.4 on 2016-03-23 02:01
# Generated by Django 1.9.4 on 2016-07-04 22:08
from __future__ import unicode_literals
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
import django.utils.timezone
@ -13,7 +12,7 @@ class Migration(migrations.Migration):
initial = True
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('registration', '0001_initial'),
]
operations = [
@ -24,12 +23,32 @@ class Migration(migrations.Migration):
('created_at', models.DateTimeField(auto_now_add=True)),
('modified_at', models.DateTimeField(auto_now=True)),
('renewed_at', models.DateTimeField(default=django.utils.timezone.now)),
('safe_space', models.BooleanField(default=False)),
('community', models.BooleanField(default=False)),
('space', models.BooleanField(default=False)),
('give_back', models.BooleanField(default=False)),
('acknowledgement', models.BooleanField(default=False)),
('member', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name='membership', to=settings.AUTH_USER_MODEL)),
('self_identification', models.CharField(blank=True, max_length=255, null=True)),
('gender', models.CharField(blank=True, max_length=255, null=True)),
('involvement', models.CharField(blank=True, max_length=255, null=True)),
('member', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='memberships', to='registration.Member')),
],
),
migrations.CreateModel(
name='Payment',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('type', models.CharField(choices=[('NONE', 'None'), ('CASH', 'Cash'), ('CHEQUE', 'Cheque'), ('VOLUNTEERING', 'Volunteering'), ('SQUARE', 'Square'), ('PAYPAL', 'PayPal'), ('UNKNOWN', 'Unknown')], default='NONE', max_length=12)),
('created_at', models.DateTimeField(auto_now_add=True)),
],
),
migrations.CreateModel(
name='Visit',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('created_at', models.DateTimeField(auto_now_add=True)),
('purpose', models.CharField(choices=[('VOLUNTEER', 'volunteer'), ('FIX', 'fix bike'), ('WORKSHOP', 'workshop'), ('VISIT', 'visit'), ('DONATE', 'donate'), ('STAFF', 'staff')], max_length=50)),
('member', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='registration.Member')),
],
),
migrations.AddField(
model_name='membership',
name='payment',
field=models.OneToOneField(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='membership', to='core.Payment'),
),
]

25
bikeshop_project/core/migrations/0002_payment.py

@ -1,25 +0,0 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.4 on 2016-03-23 02:27
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('core', '0001_initial'),
]
operations = [
migrations.CreateModel(
name='Payment',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('type', models.CharField(choices=[('CASH', 'cash'), ('CHEQUE', 'cheque'), ('VOLUNTEERING', 'volunteering'), ('STRIPE', 'stripe'), ('PAYPAL', 'paypal')], max_length=12)),
('created_at', models.DateTimeField(auto_now_add=True)),
('membership', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='core.Membership')),
],
),
]

27
bikeshop_project/core/migrations/0003_visit.py

@ -1,27 +0,0 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.4 on 2016-03-23 02:34
from __future__ import unicode_literals
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('core', '0002_payment'),
]
operations = [
migrations.CreateModel(
name='Visit',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('created_at', models.DateTimeField(auto_now_add=True)),
('purpose', models.CharField(choices=[('VOLUNTEER', 'volunteer'), ('WORK', 'work on bike'), ('WORKSHOP', 'workshop')], max_length=50)),
('member', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
],
),
]

31
bikeshop_project/core/migrations/0004_auto_20160405_0354.py

@ -1,31 +0,0 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.4 on 2016-04-05 03:54
from __future__ import unicode_literals
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('core', '0003_visit'),
]
operations = [
migrations.RemoveField(
model_name='membership',
name='acknowledgement',
),
migrations.RemoveField(
model_name='membership',
name='community',
),
migrations.RemoveField(
model_name='membership',
name='safe_space',
),
migrations.RemoveField(
model_name='membership',
name='space',
),
]

30
bikeshop_project/core/migrations/0004_auto_20160410_1816.py

@ -1,30 +0,0 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.4 on 2016-04-10 18:16
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('core', '0003_visit'),
]
operations = [
migrations.AddField(
model_name='membership',
name='gender',
field=models.CharField(blank=True, max_length=255, null=True),
),
migrations.AddField(
model_name='membership',
name='involvement',
field=models.CharField(blank=True, max_length=255, null=True),
),
migrations.AddField(
model_name='membership',
name='self_identification',
field=models.CharField(blank=True, max_length=255, null=True),
),
]

16
bikeshop_project/core/migrations/0005_merge.py

@ -1,16 +0,0 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.4 on 2016-04-10 18:33
from __future__ import unicode_literals
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('core', '0004_auto_20160405_0354'),
('core', '0004_auto_20160410_1816'),
]
operations = [
]

35
bikeshop_project/core/migrations/0006_auto_20160410_1833.py

@ -1,35 +0,0 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.4 on 2016-04-10 18:33
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('core', '0005_merge'),
]
operations = [
migrations.AddField(
model_name='membership',
name='acknowledgement',
field=models.BooleanField(default=False),
),
migrations.AddField(
model_name='membership',
name='community',
field=models.BooleanField(default=False),
),
migrations.AddField(
model_name='membership',
name='safe_space',
field=models.BooleanField(default=False),
),
migrations.AlterField(
model_name='visit',
name='purpose',
field=models.CharField(choices=[('VOLUNTEER', 'volunteer'), ('FIX', 'fix bike'), ('WORKSHOP', 'workshop'), ('VISIT', 'visit'), ('DONATE', 'donate'), ('STAFF', 'staff')], max_length=50),
),
]

31
bikeshop_project/core/migrations/0007_auto_20160501_2253.py

@ -1,31 +0,0 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.4 on 2016-05-01 22:53
from __future__ import unicode_literals
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('core', '0006_auto_20160410_1833'),
]
operations = [
migrations.RemoveField(
model_name='membership',
name='acknowledgement',
),
migrations.RemoveField(
model_name='membership',
name='community',
),
migrations.RemoveField(
model_name='membership',
name='give_back',
),
migrations.RemoveField(
model_name='membership',
name='safe_space',
),
]

25
bikeshop_project/core/migrations/0008_auto_20160526_0059.py

@ -1,25 +0,0 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.4 on 2016-05-26 00:59
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('core', '0007_auto_20160501_2253'),
]
operations = [
migrations.RemoveField(
model_name='payment',
name='membership',
),
migrations.AddField(
model_name='membership',
name='payment',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to='core.Payment'),
),
]

19
bikeshop_project/core/migrations/0009_remove_membership_member.py

@ -1,19 +0,0 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.4 on 2016-05-26 01:50
from __future__ import unicode_literals
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('core', '0008_auto_20160526_0059'),
]
operations = [
migrations.RemoveField(
model_name='membership',
name='member',
),
]

23
bikeshop_project/core/migrations/0010_membership_member.py

@ -1,23 +0,0 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.4 on 2016-05-31 02:31
from __future__ import unicode_literals
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('core', '0009_remove_membership_member'),
]
operations = [
migrations.AddField(
model_name='membership',
name='member',
field=models.OneToOneField(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='membership', to=settings.AUTH_USER_MODEL),
),
]

22
bikeshop_project/core/migrations/0011_auto_20160531_0233.py

@ -1,22 +0,0 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.4 on 2016-05-31 02:33
from __future__ import unicode_literals
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('core', '0010_membership_member'),
]
operations = [
migrations.AlterField(
model_name='membership',
name='member',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='memberships', to=settings.AUTH_USER_MODEL),
),
]

25
bikeshop_project/core/migrations/0012_auto_20160531_0234.py

@ -1,25 +0,0 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.4 on 2016-05-31 02:34
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('core', '0011_auto_20160531_0233'),
]
operations = [
migrations.RemoveField(
model_name='membership',
name='payment',
),
migrations.AddField(
model_name='payment',
name='membership',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='payments', to='core.Membership'),
),
]

25
bikeshop_project/core/migrations/0013_auto_20160531_0236.py

@ -1,25 +0,0 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.4 on 2016-05-31 02:36
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('core', '0012_auto_20160531_0234'),
]
operations = [
migrations.RemoveField(
model_name='payment',
name='membership',
),
migrations.AddField(
model_name='membership',
name='payment',
field=models.OneToOneField(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='membership', to='core.Payment'),
),
]

20
bikeshop_project/core/migrations/0014_payment_paid.py

@ -1,20 +0,0 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.4 on 2016-05-31 02:38
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('core', '0013_auto_20160531_0236'),
]
operations = [
migrations.AddField(
model_name='payment',
name='paid',
field=models.BooleanField(default=False),
),
]

20
bikeshop_project/core/migrations/0015_auto_20160531_0413.py

@ -1,20 +0,0 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.4 on 2016-05-31 04:13
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('core', '0014_payment_paid'),
]
operations = [
migrations.AlterField(
model_name='payment',
name='type',
field=models.CharField(choices=[('CASH', 'cash'), ('CHEQUE', 'cheque'), ('VOLUNTEERING', 'volunteering'), ('STRIPE', 'stripe'), ('PAYPAL', 'paypal')], default='None', max_length=12),
),
]

24
bikeshop_project/core/migrations/0016_auto_20160531_0416.py

@ -1,24 +0,0 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.4 on 2016-05-31 04:16
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('core', '0015_auto_20160531_0413'),
]
operations = [
migrations.RemoveField(
model_name='payment',
name='paid',
),
migrations.AlterField(
model_name='payment',
name='type',
field=models.CharField(choices=[('NONE', 'None'), ('CASH', 'Cash'), ('CHEQUE', 'Cheque'), ('VOLUNTEERING', 'Volunteering'), ('STRIPE', 'Stripe'), ('PAYPAL', 'PayPal')], default='NONE', max_length=12),
),
]

20
bikeshop_project/core/migrations/0017_auto_20160626_1842.py

@ -1,20 +0,0 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.4 on 2016-06-26 18:42
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('core', '0016_auto_20160531_0416'),
]
operations = [
migrations.AlterField(
model_name='payment',
name='type',
field=models.CharField(choices=[('NONE', 'None'), ('CASH', 'Cash'), ('CHEQUE', 'Cheque'), ('VOLUNTEERING', 'Volunteering'), ('SQUARE', 'Square'), ('PAYPAL', 'PayPal')], default='NONE', max_length=12),
),
]

20
bikeshop_project/core/migrations/0018_auto_20160626_1844.py

@ -1,20 +0,0 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.4 on 2016-06-26 18:44
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('core', '0017_auto_20160626_1842'),
]
operations = [
migrations.AlterField(
model_name='payment',
name='type',
field=models.CharField(choices=[('NONE', 'None'), ('CASH', 'Cash'), ('CHEQUE', 'Cheque'), ('VOLUNTEERING', 'Volunteering'), ('SQUARE', 'Square'), ('PAYPAL', 'PayPal'), ('UNKNOWN', 'Unknown')], default='NONE', max_length=12),
),
]

28
bikeshop_project/registration/admin.py

@ -1,21 +1,22 @@
from django.contrib import admin
from .models import Member
from .models import CustomUser, Member
from django.contrib.auth.admin import UserAdmin
from django.contrib.auth.forms import UserChangeForm
class MemberChangeForm(UserChangeForm):
class CustomUserChangeForm(UserChangeForm):
class Meta(UserChangeForm.Meta):
model = Member
model = CustomUser
class MemberAdmin(UserAdmin):
form = MemberChangeForm
fieldsets = fieldsets = (
@admin.register(CustomUser)
class CustomUserAdmin(UserAdmin):
form = CustomUserChangeForm
fieldsets = (
(None, {'fields': ('email', 'password')}),
('Personal info', {'fields': ('first_name', 'last_name')}),
('Permissions', {'fields': ('is_active', 'is_superuser',
'groups', 'user_permissions')}),
'groups', 'user_permissions')}),
('Important dates', {'fields': ('last_login',)}),
)
add_fieldsets = (
@ -25,10 +26,13 @@ class MemberAdmin(UserAdmin):
}),
)
ordering = ('email',)
list_display = ('email', 'first_name', 'last_name')
list_display = ('email',)
list_filter = ('is_superuser', 'is_active', 'groups')
search_fields = ('email', 'first_name', 'last_name', 'email')
search_fields = ('email',)
# Register your models here.
admin.site.register(Member, MemberAdmin)
@admin.register(Member)
class MemberAdmin(admin.ModelAdmin):
list_display = ('get_full_name',)
ordering = ('last_name',)
search_fields = ('email', 'first_name', 'last_name')

33
bikeshop_project/registration/migrations/0001_initial.py

@ -1,8 +1,10 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.4 on 2016-03-23 01:25
# Generated by Django 1.9.4 on 2016-07-04 22:04
from __future__ import unicode_literals
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
@ -15,13 +17,28 @@ class Migration(migrations.Migration):
operations = [
migrations.CreateModel(
name='Member',
name='CustomUser',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('password', models.CharField(max_length=128, verbose_name='password')),
('last_login', models.DateTimeField(blank=True, null=True, verbose_name='last login')),
('is_superuser', models.BooleanField(default=False, help_text='Designates that this user has all permissions without explicitly assigning them.', verbose_name='superuser status')),
('email', models.EmailField(max_length=255, unique=True, verbose_name='email address')),
('is_admin', models.BooleanField(default=False)),
('is_active', models.BooleanField(default=True)),
('groups', models.ManyToManyField(blank=True, help_text='The groups this user belongs to. A user will get all permissions granted to each of their groups.', related_name='user_set', related_query_name='user', to='auth.Group', verbose_name='groups')),
('user_permissions', models.ManyToManyField(blank=True, help_text='Specific permissions for this user.', related_name='user_set', related_query_name='user', to='auth.Permission', verbose_name='user permissions')),
],
options={
'abstract': False,
},
),
migrations.CreateModel(
name='Member',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('email', models.EmailField(blank=True, max_length=255, null=True, verbose_name='email address')),
('email_consent', models.BooleanField(default=False)),
('first_name', models.CharField(max_length=255)),
('last_name', models.CharField(max_length=255)),
('preferred_name', models.CharField(blank=True, max_length=255, null=True)),
@ -32,18 +49,10 @@ class Migration(migrations.Migration):
('city', models.CharField(blank=True, max_length=255, null=True)),
('province', models.CharField(blank=True, max_length=255, null=True)),
('country', models.CharField(blank=True, max_length=255, null=True)),
('post_code', models.CharField(blank=True, max_length=20, null=True)),
('self_identification', models.CharField(blank=True, max_length=255, null=True)),
('gender', models.CharField(blank=True, max_length=255, null=True)),
('involvement', models.CharField(blank=True, max_length=255, null=True)),
('post_code', models.CharField(max_length=20, null=True)),
('waiver', models.DateTimeField(blank=True, null=True)),
('is_active', models.BooleanField(default=True)),
('is_admin', models.BooleanField(default=False)),
('groups', models.ManyToManyField(blank=True, help_text='The groups this user belongs to. A user will get all permissions granted to each of their groups.', related_name='user_set', related_query_name='user', to='auth.Group', verbose_name='groups')),
('user_permissions', models.ManyToManyField(blank=True, help_text='Specific permissions for this user.', related_name='user_set', related_query_name='user', to='auth.Permission', verbose_name='user permissions')),
('user', models.OneToOneField(null=True, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
],
options={
'abstract': False,
},
),
]

20
bikeshop_project/registration/migrations/0002_member_email_consent.py

@ -1,20 +0,0 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.4 on 2016-03-27 04:50
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('registration', '0001_initial'),
]
operations = [
migrations.AddField(
model_name='member',
name='email_consent',
field=models.BooleanField(default=False),
),
]

25
bikeshop_project/registration/migrations/0003_auto_20160327_0620.py

@ -1,25 +0,0 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.4 on 2016-03-27 06:20
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('registration', '0002_member_email_consent'),
]
operations = [
migrations.AlterField(
model_name='member',
name='date_of_birth',
field=models.DateField(null=True),
),
migrations.AlterField(
model_name='member',
name='post_code',
field=models.CharField(max_length=20, null=True),
),
]

32
bikeshop_project/registration/migrations/0004_auto_20160410_1816.py

@ -1,32 +0,0 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.4 on 2016-04-10 18:16
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('registration', '0003_auto_20160327_0620'),
]
operations = [
migrations.RemoveField(
model_name='member',
name='gender',
),
migrations.RemoveField(
model_name='member',
name='involvement',
),
migrations.RemoveField(
model_name='member',
name='self_identification',
),
migrations.AlterField(
model_name='member',
name='date_of_birth',
field=models.DateField(blank=True, null=True),
),
]

22
bikeshop_project/registration/migrations/0005_member_membership.py

@ -1,22 +0,0 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.4 on 2016-05-26 01:50
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('core', '0009_remove_membership_member'),
('registration', '0004_auto_20160410_1816'),
]
operations = [
migrations.AddField(
model_name='member',
name='membership',
field=models.OneToOneField(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='member', to='core.Membership'),
),
]

19
bikeshop_project/registration/migrations/0006_remove_member_membership.py

@ -1,19 +0,0 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.4 on 2016-05-31 02:31
from __future__ import unicode_literals
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('registration', '0005_member_membership'),
]
operations = [
migrations.RemoveField(
model_name='member',
name='membership',
),
]

64
bikeshop_project/registration/models.py

@ -2,14 +2,12 @@ from django.contrib.auth.models import AbstractBaseUser, BaseUserManager, Permis
from django.db import models
class CustomMemberManager(BaseUserManager):
def create_user(self, email, first_name, last_name, password=None):
class CustomUserManager(BaseUserManager):
def create_user(self, email, password=None):
"""
Creates and saves a User with the given email and password.
:param email: str
:param password: str
:param first_name: str
:param last_name: str
:return: object `CustomUser`
"""
if not email:
@ -38,12 +36,47 @@ class CustomMemberManager(BaseUserManager):
return user
class Member(AbstractBaseUser, PermissionsMixin):
class CustomUser(AbstractBaseUser, PermissionsMixin):
email = models.EmailField(
verbose_name='email address',
max_length=255,
unique=True,
)
is_admin = models.BooleanField(default=False)
is_active = models.BooleanField(default=True)
objects = CustomUserManager()
USERNAME_FIELD = 'email'
@property
def is_staff(self):
# Simplest possible answer: All admins are staff
return self.is_admin
def get_short_name(self):
return self.email
def get_full_name(self):
return self.email
def __str__(self): # __unicode__ on Python 2
return self.email
class Meta:
verbose_name = 'User'
verbose_name_plural = 'Users'
class Member(models.Model):
user = models.OneToOneField(CustomUser, on_delete=models.CASCADE, null=True)
email = models.EmailField(
verbose_name='email address',
max_length=255,
unique=False,
null=True,
blank=True,
)
email_consent = models.BooleanField(default=False)
first_name = models.CharField(max_length=255, null=False)
last_name = models.CharField(max_length=255, null=False)
@ -58,12 +91,6 @@ class Member(AbstractBaseUser, PermissionsMixin):
post_code = models.CharField(max_length=20, null=True, blank=False)
waiver = models.DateTimeField(null=True, blank=True)
is_active = models.BooleanField(default=True)
is_admin = models.BooleanField(default=False)
objects = CustomMemberManager()
USERNAME_FIELD = 'email'
# REQUIRED_FIELDS = []
@property
def full_name(self):
@ -71,19 +98,14 @@ class Member(AbstractBaseUser, PermissionsMixin):
def get_full_name(self):
# The user is identified by their email address
if self.first_name and self.last_name:
return '{0} {1}'.format(self.first_name, self.last_name)
else:
return self.email
return '{0} {1}'.format(self.first_name, self.last_name)
def get_short_name(self):
# The user is identified by their email address
return self.email
if self.email:
return self.email
else:
return self.last_name
def __str__(self): # __unicode__ on Python 2
return self.email
@property
def is_staff(self):
# Simplest possible answer: All admins are staff
return self.is_admin

Loading…
Cancel
Save