diff --git a/profile/__init__.py b/profile/__init__.py deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/profile/admin.py b/profile/admin.py deleted file mode 100644 index 9efa339d9bc35d25a636300bb1619474cfb05d17..0000000000000000000000000000000000000000 --- a/profile/admin.py +++ /dev/null @@ -1,69 +0,0 @@ -# -# steering, Programme/schedule management for AURA -# -# Copyright (C) 2017-2018, Ingo Leindecker -# -# This program is free software: you can redistribute it and/or modify it under -# the terms of the GNU Affero General Public License as published by the Free -# Software Foundation, either version 3 of the License, or (at your option) any -# later version. -# -# This program is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -# FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more -# details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. -# - -from django.contrib import admin -from django.contrib.auth.admin import UserAdmin -from django.contrib.auth.models import User - -from .models import Profile - - -class ProfileInline(admin.StackedInline): - model = Profile - fields = ("cba_username", "cba_user_token") - can_delete = False - verbose_name_plural = "Profile" - fk_name = "user" - - -class ProfileUserAdmin(UserAdmin): - inlines = (ProfileInline,) - - def get_queryset(self, request): - """Let common users only edit their own profile""" - if not request.user.is_superuser: - return super(UserAdmin, self).get_queryset(request).filter(pk=request.user.id) - - return super(UserAdmin, self).get_queryset(request) - - def get_readonly_fields(self, request, obj=None): - """Limit field access for common users""" - if not request.user.is_superuser: - return ( - "username", - "is_staff", - "is_superuser", - "is_active", - "date_joined", - "last_login", - "groups", - "user_permissions", - ) - return list() - - def get_inline_instances(self, request, obj=None): - """Append profile fields to UserAdmin""" - if not obj: - return list() - - return super(ProfileUserAdmin, self).get_inline_instances(request, obj) - - -admin.site.unregister(User) -admin.site.register(User, ProfileUserAdmin) diff --git a/profile/migrations/0001_initial.py b/profile/migrations/0001_initial.py deleted file mode 100644 index ad7c45b8559e5f0f484406bfd52958667e21d2cc..0000000000000000000000000000000000000000 --- a/profile/migrations/0001_initial.py +++ /dev/null @@ -1,122 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by Django 1.11.3 on 2017-11-09 18:42 -from __future__ import unicode_literals - -import versatileimagefield.fields - -import django.db.models.deletion -from django.conf import settings -from django.db import migrations, models - - -class Migration(migrations.Migration): - - initial = True - - dependencies = [ - migrations.swappable_dependency(settings.AUTH_USER_MODEL), - ] - - operations = [ - migrations.CreateModel( - name="Profile", - fields=[ - ( - "id", - models.AutoField( - auto_created=True, - primary_key=True, - serialize=False, - verbose_name="ID", - ), - ), - ( - "biography", - models.TextField(blank=True, null=True, verbose_name="Biography"), - ), - ("website", models.URLField(blank=True, verbose_name="Website")), - ( - "googleplus_url", - models.URLField(blank=True, verbose_name="Google+ URL"), - ), - ( - "facebook_url", - models.URLField(blank=True, verbose_name="Facebook URL"), - ), - ( - "twitter_url", - models.URLField(blank=True, verbose_name="Twitter URL"), - ), - ( - "linkedin_url", - models.URLField(blank=True, verbose_name="LinkedIn URL"), - ), - ( - "youtube_url", - models.URLField(blank=True, verbose_name="Youtube URL"), - ), - ("dorftv_url", models.URLField(blank=True, verbose_name="DorfTV URL")), - ("cba_url", models.URLField(blank=True, verbose_name="CBA URL")), - ( - "cba_username", - models.CharField( - blank=True, max_length=60, verbose_name="CBA Username" - ), - ), - ( - "cba_user_token", - models.CharField( - blank=True, max_length=255, verbose_name="CBA Token" - ), - ), - ( - "ppoi", - versatileimagefield.fields.PPOIField( - default="0.5x0.5", - editable=False, - max_length=20, - verbose_name="Image PPOI", - ), - ), - ( - "height", - models.PositiveIntegerField( - blank=True, - editable=False, - null=True, - verbose_name="Image Height", - ), - ), - ( - "width", - models.PositiveIntegerField( - blank=True, - editable=False, - null=True, - verbose_name="Image Width", - ), - ), - ( - "image", - versatileimagefield.fields.VersatileImageField( - blank=True, - height_field="height", - null=True, - upload_to="user_images", - verbose_name="Profile picture", - width_field="width", - ), - ), - ( - "user", - models.OneToOneField( - on_delete=django.db.models.deletion.CASCADE, - to=settings.AUTH_USER_MODEL, - ), - ), - ], - options={ - "db_table": "profile", - }, - ), - ] diff --git a/profile/migrations/0001_squashed.py b/profile/migrations/0001_squashed.py deleted file mode 100644 index 1313caa100beedfb221a769bf81943e0f62e0541..0000000000000000000000000000000000000000 --- a/profile/migrations/0001_squashed.py +++ /dev/null @@ -1,69 +0,0 @@ -# Generated by Django 2.2.12 on 2020-11-21 01:34 - -import django.db.models.deletion -from django.conf import settings -from django.db import migrations, models - - -class Migration(migrations.Migration): - - replaces = [ - ("profile", "0001_initial"), - ("profile", "0002_auto_20171129_1828"), - ("profile", "0003_auto_20171213_1737"), - ] - - initial = True - - dependencies = [ - migrations.swappable_dependency(settings.AUTH_USER_MODEL), - ] - - operations = [ - migrations.CreateModel( - name="Profile", - fields=[ - ( - "id", - models.AutoField( - auto_created=True, - primary_key=True, - serialize=False, - verbose_name="ID", - ), - ), - ( - "cba_username", - models.CharField( - blank=True, - help_text="Your username in CBA. This is necessary for uploading files to" - " your account.", - max_length=60, - verbose_name="CBA Username", - ), - ), - ( - "cba_user_token", - models.CharField( - blank=True, - help_text="The CBA upload token for your account. This is NOT your" - " password which you use to log into CBA!", - max_length=255, - verbose_name="CBA Token", - ), - ), - ( - "user", - models.OneToOneField( - editable=False, - on_delete=django.db.models.deletion.CASCADE, - related_name="profile", - to=settings.AUTH_USER_MODEL, - ), - ), - ], - options={ - "db_table": "profile", - }, - ), - ] diff --git a/profile/migrations/0002_auto_20171129_1828.py b/profile/migrations/0002_auto_20171129_1828.py deleted file mode 100644 index 389554246f612dd8ce7674c8f2e7722fac746b21..0000000000000000000000000000000000000000 --- a/profile/migrations/0002_auto_20171129_1828.py +++ /dev/null @@ -1,146 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by Django 1.11.3 on 2017-11-29 18:28 -from __future__ import unicode_literals - -import versatileimagefield.fields - -import django.db.models.deletion -from django.conf import settings -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ("profile", "0001_initial"), - ] - - operations = [ - migrations.AlterField( - model_name="profile", - name="biography", - field=models.TextField( - blank=True, - help_text="Describe yourself and your fields of interest in a few sentences.", - null=True, - verbose_name="Biography", - ), - ), - migrations.AlterField( - model_name="profile", - name="cba_url", - field=models.URLField( - blank=True, help_text="URL to your CBA profile.", verbose_name="CBA URL" - ), - ), - migrations.AlterField( - model_name="profile", - name="cba_user_token", - field=models.CharField( - blank=True, - help_text="The CBA upload token for your account. This is NOT your password which" - " you use to log into CBA!", - max_length=255, - verbose_name="CBA Token", - ), - ), - migrations.AlterField( - model_name="profile", - name="cba_username", - field=models.CharField( - blank=True, - help_text="Your username in CBA. This is necessary for uploading files to your" - " account.", - max_length=60, - verbose_name="CBA Username", - ), - ), - migrations.AlterField( - model_name="profile", - name="dorftv_url", - field=models.URLField( - blank=True, - help_text="URL to your dorfTV channel.", - verbose_name="DorfTV URL", - ), - ), - migrations.AlterField( - model_name="profile", - name="facebook_url", - field=models.URLField( - blank=True, - help_text="URL to your Facebook profile.", - verbose_name="Facebook URL", - ), - ), - migrations.AlterField( - model_name="profile", - name="googleplus_url", - field=models.URLField( - blank=True, - help_text="URL to your Google+ profile.", - verbose_name="Google+ URL", - ), - ), - migrations.AlterField( - model_name="profile", - name="image", - field=versatileimagefield.fields.VersatileImageField( - blank=True, - height_field="height", - help_text="Upload a picture of yourself. Images are automatically cropped around" - " the 'Primary Point of Interest'. Click in the image to change it and" - " press Save.", - null=True, - upload_to="user_images", - verbose_name="Profile picture", - width_field="width", - ), - ), - migrations.AlterField( - model_name="profile", - name="linkedin_url", - field=models.URLField( - blank=True, - help_text="URL to your LinkedIn profile.", - verbose_name="LinkedIn URL", - ), - ), - migrations.AlterField( - model_name="profile", - name="twitter_url", - field=models.URLField( - blank=True, - help_text="URL to your Twitter profile.", - verbose_name="Twitter URL", - ), - ), - migrations.AlterField( - model_name="profile", - name="user", - field=models.OneToOneField( - editable=False, - on_delete=django.db.models.deletion.CASCADE, - related_name="profile", - to=settings.AUTH_USER_MODEL, - ), - ), - migrations.AlterField( - model_name="profile", - name="website", - field=models.URLField( - blank=True, - help_text="URL to your personal website.", - verbose_name="Website", - ), - ), - migrations.AlterField( - model_name="profile", - name="youtube_url", - field=models.URLField( - blank=True, - help_text="URL to your Youtube channel.", - verbose_name="Youtube URL", - ), - ), - ] diff --git a/profile/migrations/0002_auto_20220117_1721.py b/profile/migrations/0002_auto_20220117_1721.py deleted file mode 100644 index e209efdea852e921a271540fe56c4e686a9c7f75..0000000000000000000000000000000000000000 --- a/profile/migrations/0002_auto_20220117_1721.py +++ /dev/null @@ -1,27 +0,0 @@ -# Generated by Django 2.2.25 on 2022-01-17 16:21 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ("profile", "0001_squashed"), - ] - - operations = [ - migrations.AlterField( - model_name="profile", - name="cba_user_token", - field=models.CharField( - blank=True, max_length=255, verbose_name="CBA Token" - ), - ), - migrations.AlterField( - model_name="profile", - name="cba_username", - field=models.CharField( - blank=True, max_length=60, verbose_name="CBA Username" - ), - ), - ] diff --git a/profile/migrations/0003_auto_20171213_1737.py b/profile/migrations/0003_auto_20171213_1737.py deleted file mode 100644 index 8a4b11031e742c40aec3dd314efbf7e8018c19c0..0000000000000000000000000000000000000000 --- a/profile/migrations/0003_auto_20171213_1737.py +++ /dev/null @@ -1,67 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by Django 1.11.3 on 2017-12-13 17:37 -from __future__ import unicode_literals - -from django.db import migrations - - -class Migration(migrations.Migration): - - dependencies = [ - ("profile", "0002_auto_20171129_1828"), - ] - - operations = [ - migrations.RemoveField( - model_name="profile", - name="biography", - ), - migrations.RemoveField( - model_name="profile", - name="cba_url", - ), - migrations.RemoveField( - model_name="profile", - name="dorftv_url", - ), - migrations.RemoveField( - model_name="profile", - name="facebook_url", - ), - migrations.RemoveField( - model_name="profile", - name="googleplus_url", - ), - migrations.RemoveField( - model_name="profile", - name="height", - ), - migrations.RemoveField( - model_name="profile", - name="image", - ), - migrations.RemoveField( - model_name="profile", - name="linkedin_url", - ), - migrations.RemoveField( - model_name="profile", - name="ppoi", - ), - migrations.RemoveField( - model_name="profile", - name="twitter_url", - ), - migrations.RemoveField( - model_name="profile", - name="website", - ), - migrations.RemoveField( - model_name="profile", - name="width", - ), - migrations.RemoveField( - model_name="profile", - name="youtube_url", - ), - ] diff --git a/profile/migrations/0003_auto_20220728_1807.py b/profile/migrations/0003_auto_20220728_1807.py deleted file mode 100644 index 78009bea8471399b03d392970482fd2d4caa2d41..0000000000000000000000000000000000000000 --- a/profile/migrations/0003_auto_20220728_1807.py +++ /dev/null @@ -1,39 +0,0 @@ -# Generated by Django 3.2.14 on 2022-07-28 16:07 - -import django.utils.timezone -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ("profile", "0002_auto_20220117_1721"), - ] - - operations = [ - migrations.AddField( - model_name="profile", - name="created_at", - field=models.DateTimeField( - auto_now_add=True, default=django.utils.timezone.now - ), - preserve_default=False, - ), - migrations.AddField( - model_name="profile", - name="created_by", - field=models.CharField(default="root", max_length=150), - preserve_default=False, - ), - migrations.AddField( - model_name="profile", - name="updated_at", - field=models.DateTimeField(auto_now=True), - ), - migrations.AddField( - model_name="profile", - name="updated_by", - field=models.CharField(default="root", max_length=150), - preserve_default=False, - ), - ] diff --git a/profile/migrations/0004_auto_20221011_2217.py b/profile/migrations/0004_auto_20221011_2217.py deleted file mode 100644 index b3d6d05b0f7ce735fd9b5dc3ad4b597474047eee..0000000000000000000000000000000000000000 --- a/profile/migrations/0004_auto_20221011_2217.py +++ /dev/null @@ -1,23 +0,0 @@ -# Generated by Django 3.2.16 on 2022-10-11 20:17 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ("profile", "0003_auto_20220728_1807"), - ] - - operations = [ - migrations.AlterField( - model_name="profile", - name="updated_at", - field=models.DateTimeField(auto_now=True, null=True), - ), - migrations.AlterField( - model_name="profile", - name="updated_by", - field=models.CharField(blank=True, max_length=150, null=True), - ), - ] diff --git a/profile/migrations/__init__.py b/profile/migrations/__init__.py deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/profile/models.py b/profile/models.py deleted file mode 100644 index 2faa9788b14c36984e6638757fb2ad0df2675894..0000000000000000000000000000000000000000 --- a/profile/models.py +++ /dev/null @@ -1,40 +0,0 @@ -# -# steering, Programme/schedule management for AURA -# -# Copyright (C) 2017-2018, Ingo Leindecker -# -# This program is free software: you can redistribute it and/or modify it under -# the terms of the GNU Affero General Public License as published by the Free -# Software Foundation, either version 3 of the License, or (at your option) any -# later version. -# -# This program is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -# FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more -# details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. -# - -from django.contrib.auth.models import User -from django.db import models -from django.utils.translation import gettext_lazy as _ -from program.models import ModelWithCreatedUpdatedFields - - -class Profile(ModelWithCreatedUpdatedFields, models.Model): - user = models.OneToOneField( - User, on_delete=models.CASCADE, related_name="profile", editable=False - ) - cba_username = models.CharField(_("CBA Username"), blank=True, max_length=60) - cba_user_token = models.CharField(_("CBA Token"), blank=True, max_length=255) - - def __str__(self): - return self.user.username - - class Meta: - db_table = "profile" - - def save(self, *args, **kwargs): - super(Profile, self).save(*args, **kwargs) diff --git a/profile/serializers.py b/profile/serializers.py deleted file mode 100644 index 4d4d6adec0fed4755a529cc391ae5ec8cb8cc500..0000000000000000000000000000000000000000 --- a/profile/serializers.py +++ /dev/null @@ -1,42 +0,0 @@ -# -# steering, Programme/schedule management for AURA -# -# Copyright (C) 2017-2018, Ingo Leindecker -# -# This program is free software: you can redistribute it and/or modify it under -# the terms of the GNU Affero General Public License as published by the Free -# Software Foundation, either version 3 of the License, or (at your option) any -# later version. -# -# This program is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -# FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more -# details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. -# - -from profile.models import Profile - -from rest_framework import serializers - - -class ProfileSerializer(serializers.ModelSerializer): - class Meta: - model = Profile - fields = ( - "user", - "cba_username", - "cba_user_token", - "created_at", - "created_by", - "updated_at", - "updated_by", - ) - read_only_fields = ( - "created_at", - "created_by", - "updated_at", - "updated_by", - ) diff --git a/program/models.py b/program/models.py index 08146fbbf6eb45d34cff820188b7e8ad43b019b2..e7a76ded8be7aab1438f92cdaf7c858c245c9504 100644 --- a/program/models.py +++ b/program/models.py @@ -1168,3 +1168,14 @@ class Note(ModelWithImageFields, ModelWithCreatedUpdatedFields): class NoteLink(Link): note = models.ForeignKey(Note, on_delete=models.CASCADE, related_name="links") + + +class UserProfile(ModelWithCreatedUpdatedFields, models.Model): + user = models.OneToOneField( + User, on_delete=models.CASCADE, related_name="profile", editable=False + ) + cba_username = models.CharField("CBA Username", blank=True, max_length=60) + cba_user_token = models.CharField("CBA Token", blank=True, max_length=255) + + def __str__(self): + return self.user.username