kopia lustrzana https://github.com/wagtail/wagtail
Set a related_name of wagtail_userprofile on wagtailusers.UserProfile
This prevents it from clashing with other userprofile models defined elsewhere in the project. Fixes #3025pull/3037/merge
rodzic
3833b0cba8
commit
f45181764b
|
@ -31,6 +31,7 @@ Changelog
|
||||||
* Fix: Disabled use of escape key to revert content of rich text fields, which could cause accidental data loss (Matt Westcott)
|
* Fix: Disabled use of escape key to revert content of rich text fields, which could cause accidental data loss (Matt Westcott)
|
||||||
* Fix: Setting `USE_THOUSAND_SEPARATOR = True` no longer breaks the rendering of numbers in JS code for InlinePanel (Mattias Loverot, Matt Westcott)
|
* Fix: Setting `USE_THOUSAND_SEPARATOR = True` no longer breaks the rendering of numbers in JS code for InlinePanel (Mattias Loverot, Matt Westcott)
|
||||||
* Fix: Images / documents pagination now preserves GET parameters (Bojan Mihelac)
|
* Fix: Images / documents pagination now preserves GET parameters (Bojan Mihelac)
|
||||||
|
* Fix: Wagtail's UserProfile model now sets a related_name of ``wagtail_userprofile`` to avoid naming collisions with other user profile models (Matt Westcott)
|
||||||
|
|
||||||
|
|
||||||
1.6.3 (30.09.2016)
|
1.6.3 (30.09.2016)
|
||||||
|
|
|
@ -66,6 +66,7 @@ Bug fixes
|
||||||
* Disabled use of escape key to revert content of rich text fields, which could cause accidental data loss (Matt Westcott)
|
* Disabled use of escape key to revert content of rich text fields, which could cause accidental data loss (Matt Westcott)
|
||||||
* Setting ``USE_THOUSAND_SEPARATOR = True`` no longer breaks the rendering of numbers in JS code for InlinePanel (Mattias Loverot, Matt Westcott)
|
* Setting ``USE_THOUSAND_SEPARATOR = True`` no longer breaks the rendering of numbers in JS code for InlinePanel (Mattias Loverot, Matt Westcott)
|
||||||
* Images / documents pagination now preserves GET parameters (Bojan Mihelac)
|
* Images / documents pagination now preserves GET parameters (Bojan Mihelac)
|
||||||
|
* Wagtail's UserProfile model now sets a related_name of ``wagtail_userprofile`` to avoid naming collisions with other user profile models (Matt Westcott)
|
||||||
|
|
||||||
|
|
||||||
Upgrade considerations
|
Upgrade considerations
|
||||||
|
|
|
@ -0,0 +1,26 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Generated by Django 1.10.1 on 2016-09-28 23:49
|
||||||
|
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),
|
||||||
|
('tests', '0010_auto_20160823_1056'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='UserProfile',
|
||||||
|
fields=[
|
||||||
|
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('favourite_colour', models.CharField(max_length=255)),
|
||||||
|
('user', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
]
|
|
@ -875,3 +875,9 @@ class InlineStreamPage(Page):
|
||||||
FieldPanel('title', classname="full title"),
|
FieldPanel('title', classname="full title"),
|
||||||
InlinePanel('sections')
|
InlinePanel('sections')
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
class UserProfile(models.Model):
|
||||||
|
# Wagtail's schema must be able to coexist alongside a custom UserProfile model
|
||||||
|
user = models.OneToOneField(settings.AUTH_USER_MODEL, on_delete=models.CASCADE)
|
||||||
|
favourite_colour = models.CharField(max_length=255)
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Generated by Django 1.10.1 on 2016-09-28 23:49
|
||||||
|
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 = [
|
||||||
|
('wagtailusers', '0004_capitalizeverbose'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='userprofile',
|
||||||
|
name='user',
|
||||||
|
field=models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name='wagtail_userprofile', to=settings.AUTH_USER_MODEL),
|
||||||
|
),
|
||||||
|
]
|
|
@ -8,7 +8,9 @@ from django.utils.translation import ugettext_lazy as _
|
||||||
|
|
||||||
@python_2_unicode_compatible
|
@python_2_unicode_compatible
|
||||||
class UserProfile(models.Model):
|
class UserProfile(models.Model):
|
||||||
user = models.OneToOneField(settings.AUTH_USER_MODEL, on_delete=models.CASCADE)
|
user = models.OneToOneField(
|
||||||
|
settings.AUTH_USER_MODEL, on_delete=models.CASCADE, related_name='wagtail_userprofile'
|
||||||
|
)
|
||||||
|
|
||||||
submitted_notifications = models.BooleanField(
|
submitted_notifications = models.BooleanField(
|
||||||
verbose_name=_('submitted notifications'),
|
verbose_name=_('submitted notifications'),
|
||||||
|
|
|
@ -400,7 +400,7 @@ class TestUserProfileCreation(TestCase, WagtailTestUtils):
|
||||||
def test_user_created_without_profile(self):
|
def test_user_created_without_profile(self):
|
||||||
self.assertEqual(UserProfile.objects.filter(user=self.test_user).count(), 0)
|
self.assertEqual(UserProfile.objects.filter(user=self.test_user).count(), 0)
|
||||||
with self.assertRaises(UserProfile.DoesNotExist):
|
with self.assertRaises(UserProfile.DoesNotExist):
|
||||||
self.test_user.userprofile
|
self.test_user.wagtail_userprofile
|
||||||
|
|
||||||
def test_user_profile_created_when_method_called(self):
|
def test_user_profile_created_when_method_called(self):
|
||||||
self.assertIsInstance(UserProfile.get_for_user(self.test_user), UserProfile)
|
self.assertIsInstance(UserProfile.get_for_user(self.test_user), UserProfile)
|
||||||
|
|
Ładowanie…
Reference in New Issue