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,
|
'APP_DIRS': True,
|
||||||
'OPTIONS': {
|
'OPTIONS': {
|
||||||
'context_processors': [
|
'context_processors': [
|
||||||
|
'django.template.context_processors.request',
|
||||||
'django.template.context_processors.debug',
|
'django.template.context_processors.debug',
|
||||||
'django.template.context_processors.request',
|
'django.template.context_processors.request',
|
||||||
'django.contrib.auth.context_processors.auth',
|
'django.contrib.auth.context_processors.auth',
|
||||||
|
|||||||
37
teamsnap/migrations/0016_auto_20211212_2240.py
Normal file
37
teamsnap/migrations/0016_auto_20211212_2240.py
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
# Generated by Django 3.2.6 on 2021-12-12 22:40
|
||||||
|
|
||||||
|
from django.db import migrations
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('teamsnap', '0015_auto_20211210_1744'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.RenameField(
|
||||||
|
model_name='availability',
|
||||||
|
old_name='benchcoach_availability',
|
||||||
|
new_name='benchcoach_object',
|
||||||
|
),
|
||||||
|
migrations.RenameField(
|
||||||
|
model_name='event',
|
||||||
|
old_name='benchcoach_event',
|
||||||
|
new_name='benchcoach_object',
|
||||||
|
),
|
||||||
|
migrations.RenameField(
|
||||||
|
model_name='location',
|
||||||
|
old_name='benchcoach_venue',
|
||||||
|
new_name='benchcoach_object',
|
||||||
|
),
|
||||||
|
migrations.RenameField(
|
||||||
|
model_name='member',
|
||||||
|
old_name='benchcoach_player',
|
||||||
|
new_name='benchcoach_object',
|
||||||
|
),
|
||||||
|
migrations.RemoveField(
|
||||||
|
model_name='event',
|
||||||
|
name='name',
|
||||||
|
),
|
||||||
|
]
|
||||||
32
teamsnap/migrations/0017_auto_20211212_2356.py
Normal file
32
teamsnap/migrations/0017_auto_20211212_2356.py
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
# Generated by Django 3.2.6 on 2021-12-12 23:56
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('teamsnap', '0016_auto_20211212_2240'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.RemoveField(
|
||||||
|
model_name='user',
|
||||||
|
name='access_token',
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='user',
|
||||||
|
name='email',
|
||||||
|
field=models.EmailField(max_length=254, null=True),
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='user',
|
||||||
|
name='first_name',
|
||||||
|
field=models.CharField(max_length=50, null=True),
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='user',
|
||||||
|
name='last_name',
|
||||||
|
field=models.CharField(max_length=50, null=True),
|
||||||
|
),
|
||||||
|
]
|
||||||
18
teamsnap/migrations/0018_user_managed_teams.py
Normal file
18
teamsnap/migrations/0018_user_managed_teams.py
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
# Generated by Django 3.2.6 on 2021-12-13 00:30
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('teamsnap', '0017_auto_20211212_2356'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='user',
|
||||||
|
name='managed_teams',
|
||||||
|
field=models.ManyToManyField(to='teamsnap.Team'),
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -36,7 +36,7 @@
|
|||||||
<span class="navbar-text"></span>
|
<span class="navbar-text"></span>
|
||||||
<ul class="navbar-nav mx-2">
|
<ul class="navbar-nav mx-2">
|
||||||
<li class="nav-item dropdown">
|
<li class="nav-item dropdown">
|
||||||
<a class="dropdown-toggle nav-link" aria-expanded="false" data-bs-toggle="dropdown" href="#">User <img class="rounded-circle" height="24" src="{% static 'tommy-lasorda.jpg' %}" width="24" /></a>
|
<a class="dropdown-toggle nav-link" aria-expanded="false" data-bs-toggle="dropdown" href="#">{{ request.user }} <img class="rounded-circle" height="24" src="{{ request.user.profile.avatar.url }}" width="24" /></a>
|
||||||
<div class="dropdown-menu">
|
<div class="dropdown-menu">
|
||||||
<a class="dropdown-item" href="#">Menu Item</a>
|
<a class="dropdown-item" href="#">Menu Item</a>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user