add BenchCoach user/profile
This commit is contained in:
5
benchcoach/admin.py
Normal file
5
benchcoach/admin.py
Normal file
@@ -0,0 +1,5 @@
|
||||
from django.contrib import admin
|
||||
from .models import Profile
|
||||
|
||||
# Register your models here.
|
||||
admin.site.register(Profile)
|
||||
24
benchcoach/migrations/0001_initial.py
Normal file
24
benchcoach/migrations/0001_initial.py
Normal file
@@ -0,0 +1,24 @@
|
||||
# Generated by Django 3.2.6 on 2021-12-12 23:36
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
initial = True
|
||||
|
||||
dependencies = [
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='User',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('first_name', models.CharField(max_length=50, null=True)),
|
||||
('last_name', models.CharField(max_length=50, null=True)),
|
||||
('email', models.EmailField(max_length=254)),
|
||||
('teamsnap_access_token', models.CharField(max_length=50, null=True)),
|
||||
],
|
||||
),
|
||||
]
|
||||
20
benchcoach/migrations/0002_user_teamsnap_user.py
Normal file
20
benchcoach/migrations/0002_user_teamsnap_user.py
Normal file
@@ -0,0 +1,20 @@
|
||||
# Generated by Django 3.2.6 on 2021-12-12 23:37
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('teamsnap', '0016_auto_20211212_2240'),
|
||||
('benchcoach', '0001_initial'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='user',
|
||||
name='teamsnap_user',
|
||||
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to='teamsnap.user'),
|
||||
),
|
||||
]
|
||||
29
benchcoach/migrations/0003_auto_20211213_0058.py
Normal file
29
benchcoach/migrations/0003_auto_20211213_0058.py
Normal file
@@ -0,0 +1,29 @@
|
||||
# Generated by Django 3.2.6 on 2021-12-13 00:58
|
||||
|
||||
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),
|
||||
('teamsnap', '0018_user_managed_teams'),
|
||||
('benchcoach', '0002_user_teamsnap_user'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='Profile',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('teamsnap_access_token', models.CharField(max_length=50, null=True)),
|
||||
('teamsnap_user', models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to='teamsnap.user')),
|
||||
('user', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
|
||||
],
|
||||
),
|
||||
migrations.DeleteModel(
|
||||
name='User',
|
||||
),
|
||||
]
|
||||
18
benchcoach/migrations/0004_profile_avatar.py
Normal file
18
benchcoach/migrations/0004_profile_avatar.py
Normal file
@@ -0,0 +1,18 @@
|
||||
# Generated by Django 3.2.6 on 2021-12-13 01:13
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('benchcoach', '0003_auto_20211213_0058'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='profile',
|
||||
name='avatar',
|
||||
field=models.ImageField(blank=True, null=True, upload_to='benchcoach/static/user_files/'),
|
||||
),
|
||||
]
|
||||
18
benchcoach/migrations/0005_alter_profile_avatar.py
Normal file
18
benchcoach/migrations/0005_alter_profile_avatar.py
Normal file
@@ -0,0 +1,18 @@
|
||||
# Generated by Django 3.2.6 on 2021-12-13 01:15
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('benchcoach', '0004_profile_avatar'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='profile',
|
||||
name='avatar',
|
||||
field=models.ImageField(blank=True, null=True, upload_to='avatars'),
|
||||
),
|
||||
]
|
||||
18
benchcoach/migrations/0006_alter_profile_avatar.py
Normal file
18
benchcoach/migrations/0006_alter_profile_avatar.py
Normal file
@@ -0,0 +1,18 @@
|
||||
# Generated by Django 3.2.6 on 2021-12-13 01:16
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('benchcoach', '0005_alter_profile_avatar'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='profile',
|
||||
name='avatar',
|
||||
field=models.ImageField(blank=True, null=True, upload_to='avatar'),
|
||||
),
|
||||
]
|
||||
0
benchcoach/migrations/__init__.py
Normal file
0
benchcoach/migrations/__init__.py
Normal file
14
benchcoach/models.py
Normal file
14
benchcoach/models.py
Normal file
@@ -0,0 +1,14 @@
|
||||
from django.db import models
|
||||
from teamsnap.models import User as TeamsnapUser
|
||||
from django.contrib.auth.models import User
|
||||
|
||||
|
||||
def user_directory_path(instance, filename):
|
||||
# file will be uploaded to MEDIA_ROOT / user_<id>/<filename>
|
||||
return 'benchcoach/static/user_files/user_{0}/{1}'.format(instance.user.id, filename)
|
||||
|
||||
class Profile(models.Model):
|
||||
user = models.OneToOneField(User, on_delete=models.CASCADE)
|
||||
teamsnap_access_token = models.CharField(null=True, max_length=50)
|
||||
teamsnap_user = models.ForeignKey(TeamsnapUser, on_delete=models.CASCADE, null=True)
|
||||
avatar = models.ImageField(upload_to="avatar", null=True, blank=True)
|
||||
@@ -67,6 +67,7 @@ TEMPLATES = [
|
||||
'APP_DIRS': True,
|
||||
'OPTIONS': {
|
||||
'context_processors': [
|
||||
'django.template.context_processors.request',
|
||||
'django.template.context_processors.debug',
|
||||
'django.template.context_processors.request',
|
||||
'django.contrib.auth.context_processors.auth',
|
||||
|
||||
Reference in New Issue
Block a user