diff --git a/bikeshop_project/bikeshop/settings/base.py b/bikeshop_project/bikeshop/settings/base.py index cf9818b..f765bec 100644 --- a/bikeshop_project/bikeshop/settings/base.py +++ b/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'), diff --git a/bikeshop_project/bikeshop/utils/member_import.py b/bikeshop_project/bikeshop/utils/member_import.py index 2428220..967ad5e 100644 --- a/bikeshop_project/bikeshop/utils/member_import.py +++ b/bikeshop_project/bikeshop/utils/member_import.py @@ -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'), diff --git a/bikeshop_project/core/migrations/0001_initial.py b/bikeshop_project/core/migrations/0001_initial.py index 7c6d0f5..f00fc7b 100644 --- a/bikeshop_project/core/migrations/0001_initial.py +++ b/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'), + ), ] diff --git a/bikeshop_project/core/migrations/0002_payment.py b/bikeshop_project/core/migrations/0002_payment.py deleted file mode 100644 index cec9bd3..0000000 --- a/bikeshop_project/core/migrations/0002_payment.py +++ /dev/null @@ -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')), - ], - ), - ] diff --git a/bikeshop_project/core/migrations/0003_visit.py b/bikeshop_project/core/migrations/0003_visit.py deleted file mode 100644 index 503d81d..0000000 --- a/bikeshop_project/core/migrations/0003_visit.py +++ /dev/null @@ -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)), - ], - ), - ] diff --git a/bikeshop_project/core/migrations/0004_auto_20160405_0354.py b/bikeshop_project/core/migrations/0004_auto_20160405_0354.py deleted file mode 100644 index 66807c7..0000000 --- a/bikeshop_project/core/migrations/0004_auto_20160405_0354.py +++ /dev/null @@ -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', - ), - ] diff --git a/bikeshop_project/core/migrations/0004_auto_20160410_1816.py b/bikeshop_project/core/migrations/0004_auto_20160410_1816.py deleted file mode 100644 index 5a71358..0000000 --- a/bikeshop_project/core/migrations/0004_auto_20160410_1816.py +++ /dev/null @@ -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), - ), - ] diff --git a/bikeshop_project/core/migrations/0005_merge.py b/bikeshop_project/core/migrations/0005_merge.py deleted file mode 100644 index a65903c..0000000 --- a/bikeshop_project/core/migrations/0005_merge.py +++ /dev/null @@ -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 = [ - ] diff --git a/bikeshop_project/core/migrations/0006_auto_20160410_1833.py b/bikeshop_project/core/migrations/0006_auto_20160410_1833.py deleted file mode 100644 index f152ad2..0000000 --- a/bikeshop_project/core/migrations/0006_auto_20160410_1833.py +++ /dev/null @@ -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), - ), - ] diff --git a/bikeshop_project/core/migrations/0007_auto_20160501_2253.py b/bikeshop_project/core/migrations/0007_auto_20160501_2253.py deleted file mode 100644 index 1219ac9..0000000 --- a/bikeshop_project/core/migrations/0007_auto_20160501_2253.py +++ /dev/null @@ -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', - ), - ] diff --git a/bikeshop_project/core/migrations/0008_auto_20160526_0059.py b/bikeshop_project/core/migrations/0008_auto_20160526_0059.py deleted file mode 100644 index b980641..0000000 --- a/bikeshop_project/core/migrations/0008_auto_20160526_0059.py +++ /dev/null @@ -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'), - ), - ] diff --git a/bikeshop_project/core/migrations/0009_remove_membership_member.py b/bikeshop_project/core/migrations/0009_remove_membership_member.py deleted file mode 100644 index 6a8d3ba..0000000 --- a/bikeshop_project/core/migrations/0009_remove_membership_member.py +++ /dev/null @@ -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', - ), - ] diff --git a/bikeshop_project/core/migrations/0010_membership_member.py b/bikeshop_project/core/migrations/0010_membership_member.py deleted file mode 100644 index c956f08..0000000 --- a/bikeshop_project/core/migrations/0010_membership_member.py +++ /dev/null @@ -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), - ), - ] diff --git a/bikeshop_project/core/migrations/0011_auto_20160531_0233.py b/bikeshop_project/core/migrations/0011_auto_20160531_0233.py deleted file mode 100644 index b310553..0000000 --- a/bikeshop_project/core/migrations/0011_auto_20160531_0233.py +++ /dev/null @@ -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), - ), - ] diff --git a/bikeshop_project/core/migrations/0012_auto_20160531_0234.py b/bikeshop_project/core/migrations/0012_auto_20160531_0234.py deleted file mode 100644 index d4343da..0000000 --- a/bikeshop_project/core/migrations/0012_auto_20160531_0234.py +++ /dev/null @@ -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'), - ), - ] diff --git a/bikeshop_project/core/migrations/0013_auto_20160531_0236.py b/bikeshop_project/core/migrations/0013_auto_20160531_0236.py deleted file mode 100644 index 5dae435..0000000 --- a/bikeshop_project/core/migrations/0013_auto_20160531_0236.py +++ /dev/null @@ -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'), - ), - ] diff --git a/bikeshop_project/core/migrations/0014_payment_paid.py b/bikeshop_project/core/migrations/0014_payment_paid.py deleted file mode 100644 index 67223fe..0000000 --- a/bikeshop_project/core/migrations/0014_payment_paid.py +++ /dev/null @@ -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), - ), - ] diff --git a/bikeshop_project/core/migrations/0015_auto_20160531_0413.py b/bikeshop_project/core/migrations/0015_auto_20160531_0413.py deleted file mode 100644 index 3e6bdc0..0000000 --- a/bikeshop_project/core/migrations/0015_auto_20160531_0413.py +++ /dev/null @@ -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), - ), - ] diff --git a/bikeshop_project/core/migrations/0016_auto_20160531_0416.py b/bikeshop_project/core/migrations/0016_auto_20160531_0416.py deleted file mode 100644 index 55ee7fc..0000000 --- a/bikeshop_project/core/migrations/0016_auto_20160531_0416.py +++ /dev/null @@ -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), - ), - ] diff --git a/bikeshop_project/core/migrations/0017_auto_20160626_1842.py b/bikeshop_project/core/migrations/0017_auto_20160626_1842.py deleted file mode 100644 index a880362..0000000 --- a/bikeshop_project/core/migrations/0017_auto_20160626_1842.py +++ /dev/null @@ -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), - ), - ] diff --git a/bikeshop_project/core/migrations/0018_auto_20160626_1844.py b/bikeshop_project/core/migrations/0018_auto_20160626_1844.py deleted file mode 100644 index e29f8ed..0000000 --- a/bikeshop_project/core/migrations/0018_auto_20160626_1844.py +++ /dev/null @@ -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), - ), - ] diff --git a/bikeshop_project/registration/admin.py b/bikeshop_project/registration/admin.py index de2620a..bef2f8b 100644 --- a/bikeshop_project/registration/admin.py +++ b/bikeshop_project/registration/admin.py @@ -1,34 +1,34 @@ -from django.contrib import admin -from .models import Member -from django.contrib.auth.admin import UserAdmin -from django.contrib.auth.forms import UserChangeForm - - -class MemberChangeForm(UserChangeForm): - class Meta(UserChangeForm.Meta): - model = Member - -class MemberAdmin(UserAdmin): - form = MemberChangeForm - - fieldsets = fieldsets = ( - (None, {'fields': ('email', 'password')}), - ('Personal info', {'fields': ('first_name', 'last_name')}), - ('Permissions', {'fields': ('is_active', 'is_superuser', - 'groups', 'user_permissions')}), - ('Important dates', {'fields': ('last_login',)}), - ) - add_fieldsets = ( - (None, { - 'classes': ('wide',), - 'fields': ('email', 'password1', 'password2'), - }), - ) - ordering = ('email',) - list_display = ('email', 'first_name', 'last_name') - list_filter = ('is_superuser', 'is_active', 'groups') - search_fields = ('email', 'first_name', 'last_name', 'email') - - -# Register your models here. -admin.site.register(Member, MemberAdmin) +# from django.contrib import admin +# from .models import CustomUser +# from django.contrib.auth.admin import UserAdmin +# from django.contrib.auth.forms import UserChangeForm +# +# +# class CustomUserChangeForm(UserChangeForm): +# class Meta(UserChangeForm.Meta): +# model = CustomUser +# +# +# class CustomUserAdmin(UserAdmin): +# form = CustomUserChangeForm +# +# fieldsets = ( +# (None, {'fields': ('email', 'password')}), +# ('Permissions', {'fields': ('is_active', 'is_superuser', +# 'groups', 'user_permissions')}), +# ('Important dates', {'fields': ('last_login',)}), +# ) +# add_fieldsets = ( +# (None, { +# 'classes': ('wide',), +# 'fields': ('email', 'password1', 'password2'), +# }), +# ) +# ordering = ('email',) +# list_display = ('email',) +# list_filter = ('is_superuser', 'is_active', 'groups') +# search_fields = ('email',) +# +# +# # Register your models here. +# admin.site.register(CustomUser, CustomUserAdmin) diff --git a/bikeshop_project/registration/migrations/0001_initial.py b/bikeshop_project/registration/migrations/0001_initial.py index da6c081..a211a58 100644 --- a/bikeshop_project/registration/migrations/0001_initial.py +++ b/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, - }, ), ] diff --git a/bikeshop_project/registration/migrations/0002_member_email_consent.py b/bikeshop_project/registration/migrations/0002_member_email_consent.py deleted file mode 100644 index 7f18d39..0000000 --- a/bikeshop_project/registration/migrations/0002_member_email_consent.py +++ /dev/null @@ -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), - ), - ] diff --git a/bikeshop_project/registration/migrations/0003_auto_20160327_0620.py b/bikeshop_project/registration/migrations/0003_auto_20160327_0620.py deleted file mode 100644 index de51319..0000000 --- a/bikeshop_project/registration/migrations/0003_auto_20160327_0620.py +++ /dev/null @@ -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), - ), - ] diff --git a/bikeshop_project/registration/migrations/0004_auto_20160410_1816.py b/bikeshop_project/registration/migrations/0004_auto_20160410_1816.py deleted file mode 100644 index 003e3c7..0000000 --- a/bikeshop_project/registration/migrations/0004_auto_20160410_1816.py +++ /dev/null @@ -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), - ), - ] diff --git a/bikeshop_project/registration/migrations/0005_member_membership.py b/bikeshop_project/registration/migrations/0005_member_membership.py deleted file mode 100644 index d6c4c1c..0000000 --- a/bikeshop_project/registration/migrations/0005_member_membership.py +++ /dev/null @@ -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'), - ), - ] diff --git a/bikeshop_project/registration/migrations/0006_remove_member_membership.py b/bikeshop_project/registration/migrations/0006_remove_member_membership.py deleted file mode 100644 index f5d750d..0000000 --- a/bikeshop_project/registration/migrations/0006_remove_member_membership.py +++ /dev/null @@ -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', - ), - ] diff --git a/bikeshop_project/registration/models.py b/bikeshop_project/registration/models.py index b8a5ad0..26cad18 100644 --- a/bikeshop_project/registration/models.py +++ b/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,43 @@ 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 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 +87,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): @@ -78,12 +101,7 @@ class Member(AbstractBaseUser, PermissionsMixin): def get_short_name(self): # The user is identified by their email address - return self.email + return self.user.email 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 + return self.user.email