diff --git a/app/demo/profile/__init__.py b/app/demo/profile/__init__.py new file mode 100644 index 00000000..e017cac8 --- /dev/null +++ b/app/demo/profile/__init__.py @@ -0,0 +1 @@ +default_app_config = 'demo.profile.apps.ProfileConfig' \ No newline at end of file diff --git a/app/demo/profile/admin.py b/app/demo/profile/admin.py new file mode 100644 index 00000000..82894282 --- /dev/null +++ b/app/demo/profile/admin.py @@ -0,0 +1,23 @@ +from django.contrib import admin + +from demo.profile.model import UserProfile +from material.admin import MaterialUserAdmin +from material.decorators import register +from material.sites import site + +from django.contrib.auth.models import User + + +site.unregister(User) + + +class UserPictureInline(admin.TabularInline): + model = UserProfile + extra = 0 + + +@register(User) +class MaterialUserPictureAdmin(MaterialUserAdmin): + """Register User model with material styles""" + inlines = [UserPictureInline] + diff --git a/app/demo/profile/apps.py b/app/demo/profile/apps.py new file mode 100644 index 00000000..6c73dacd --- /dev/null +++ b/app/demo/profile/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class ProfileConfig(AppConfig): + name = 'demo.profile' + icon_name = 'layers' diff --git a/app/demo/profile/migrations/0001_initial.py b/app/demo/profile/migrations/0001_initial.py new file mode 100644 index 00000000..d8a5f580 --- /dev/null +++ b/app/demo/profile/migrations/0001_initial.py @@ -0,0 +1,30 @@ +# Generated by Django 2.2.3 on 2019-07-06 12:03 + +from django.conf import settings +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + migrations.swappable_dependency(settings.AUTH_USER_MODEL), + ] + + operations = [ + migrations.CreateModel( + name='UserProfile', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('picture', models.FileField(blank=True, null=True, upload_to='', verbose_name='User Picture')), + ('user', models.OneToOneField(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='profile', to=settings.AUTH_USER_MODEL)), + ], + options={ + 'verbose_name': 'Picture', + 'verbose_name_plural': 'Picture', + 'db_table': 'user_pictures', + }, + ), + ] diff --git a/app/demo/profile/migrations/__init__.py b/app/demo/profile/migrations/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/app/demo/profile/model.py b/app/demo/profile/model.py new file mode 100644 index 00000000..36629a52 --- /dev/null +++ b/app/demo/profile/model.py @@ -0,0 +1,23 @@ +from django.conf import settings +from django.db import models +from django.utils.translation import gettext_lazy as _ + + +class UserProfile(models.Model): + user = models.OneToOneField( + settings.AUTH_USER_MODEL, + on_delete=models.CASCADE, + related_name='profile', + null=True, + blank=True + ) + picture = models.FileField( + _('User Picture'), + null=True, + blank=True + ) + + class Meta: + verbose_name = _('Picture') + verbose_name_plural = _('Picture') + db_table = 'user_pictures' diff --git a/app/demo/settings.py b/app/demo/settings.py index 009d4015..f7ccfdda 100644 --- a/app/demo/settings.py +++ b/app/demo/settings.py @@ -40,6 +40,7 @@ 'django.contrib.staticfiles', 'django.contrib.sites', + 'demo.profile', 'demo.countries', 'demo.documents', 'demo.relations', diff --git a/material/templates/material/side_nav.html b/material/templates/material/side_nav.html index ab998d8c..154d44a1 100644 --- a/material/templates/material/side_nav.html +++ b/material/templates/material/side_nav.html @@ -6,7 +6,9 @@