Commit a48f76a2 authored by Stephen Finucane's avatar Stephen Finucane Committed by Jeremy Kerr
Browse files

Resolve removed 'AUTH_PROFILE_MODULE' setting

The 'AUTH_PROFILE_MODULE' setting, and the 'get_profile()' method on
the 'User' model are removed in Django 1.7. This causes errors when
using Patchwork with Django 1.7+.

There are three changes necessary:

 * Replace profile model's 'ForeignKey' with a 'OneToOneField'
 * Remove all 'get_profile()' calls
 * Delete 'AUTH_PROFILE_MODULE' settings from 'settings.py'

These changes are discussed here:

    http://deathofagremmie.com/2014/05/24/retiring-get-profile-and-auth-profile-module/



Django 1.6 also introduces two other notable changes:

 * The 'XViewMiddleware' module has been moved
 * A new test runner has been introduced

It is not possible to fix these issues without breaking compatibility
with Django 1.5. As a result they have been ignored and must be
resolved in a future release.
Signed-off-by: default avatarStephen Finucane <stephenfinucane@hotmail.com>
Signed-off-by: default avatarJeremy Kerr <jk@ozlabs.org>
parent 3d74843a
......@@ -350,11 +350,11 @@ class DelegateFilter(Filter):
def condition(self):
if self.delegate:
return self.delegate.get_profile().name()
return self.delegate.profile.name()
return self.no_delegate_str
def _form(self):
delegates = User.objects.filter(userprofile__maintainer_projects =
delegates = User.objects.filter(profile__maintainer_projects =
self.filters.project)
str = '<select name="delegate">'
......@@ -378,7 +378,7 @@ class DelegateFilter(Filter):
selected = ' selected'
str += '<option %s value="%s">%s</option>' % (selected,
d.id, d.get_profile().name())
d.id, d.profile.name())
str += '</select>'
return mark_safe(str)
......
......@@ -89,7 +89,7 @@ class DeleteBundleForm(forms.Form):
class DelegateField(forms.ModelChoiceField):
def __init__(self, project, *args, **kwargs):
queryset = User.objects.filter(userprofile__in = \
queryset = User.objects.filter(profile__in = \
UserProfile.objects \
.filter(maintainer_projects = project) \
.values('pk').query)
......
......@@ -41,7 +41,7 @@ class Person(models.Model):
return self.email
def link_to_user(self, user):
self.name = user.get_profile().name()
self.name = user.profile.name()
self.user = user
class Meta:
......@@ -63,14 +63,14 @@ class Project(models.Model):
def is_editable(self, user):
if not user.is_authenticated():
return False
return self in user.get_profile().maintainer_projects.all()
return self in user.profile.maintainer_projects.all()
class Meta:
ordering = ['linkname']
class UserProfile(models.Model):
user = models.ForeignKey(User, unique = True)
user = models.OneToOneField(User, unique = True, related_name='profile')
primary_project = models.ForeignKey(Project, null = True, blank = True)
maintainer_projects = models.ManyToManyField(Project,
related_name = 'maintainer_project')
......@@ -94,7 +94,6 @@ class UserProfile(models.Model):
submitter__in = submitters)
.values('project_id').query)
def sync_person(self):
pass
......@@ -121,7 +120,7 @@ class UserProfile(models.Model):
def _user_saved_callback(sender, created, instance, **kwargs):
try:
profile = instance.get_profile()
profile = instance.profile
except UserProfile.DoesNotExist:
profile = UserProfile(user = instance)
profile.save()
......
......@@ -37,7 +37,7 @@ class Paginator(paginator.Paginator):
patches_per_page = settings.DEFAULT_PATCHES_PER_PAGE
if request.user.is_authenticated():
patches_per_page = request.user.get_profile().patches_per_page
patches_per_page = request.user.profile.patches_per_page
n = request.META.get('ppp')
if n:
......
......@@ -193,7 +193,7 @@ class BundleMaintainerUpdateTest(BundleUpdateTest):
def setUp(self):
super(BundleMaintainerUpdateTest, self).setUp()
profile = self.user.get_profile()
profile = self.user.profile
profile.maintainer_projects.add(defaults.project)
profile.save()
......
......@@ -79,7 +79,7 @@ def create_user():
def create_maintainer(project):
user = create_user()
profile = user.get_profile()
profile = user.profile
profile.maintainer_projects.add(project)
profile.save()
return user
......
......@@ -29,7 +29,7 @@ def project(request, project_id):
context.project = project
context['maintainers'] = User.objects.filter( \
userprofile__maintainer_projects = project)
profile__maintainer_projects = project)
context['n_patches'] = Patch.objects.filter(project = project,
archived = False).count()
context['n_archived_patches'] = Patch.objects.filter(project = project,
......
......@@ -86,7 +86,7 @@ def register_confirm(request, conf):
person = Person.objects.get(email__iexact = conf.user.email)
except Person.DoesNotExist:
person = Person(email = conf.user.email,
name = conf.user.get_profile().name())
name = conf.user.profile.name())
person.user = conf.user
person.save()
......@@ -97,14 +97,14 @@ def profile(request):
context = PatchworkRequestContext(request)
if request.method == 'POST':
form = UserProfileForm(instance = request.user.get_profile(),
form = UserProfileForm(instance = request.user.profile,
data = request.POST)
if form.is_valid():
form.save()
else:
form = UserProfileForm(instance = request.user.get_profile())
form = UserProfileForm(instance = request.user.profile)
context.project = request.user.get_profile().primary_project
context.project = request.user.profile.primary_project
context['bundles'] = Bundle.objects.filter(owner = request.user)
context['profileform'] = form
......@@ -184,7 +184,7 @@ def todo_lists(request):
todo_lists = []
for project in Project.objects.all():
patches = request.user.get_profile().todo_patches(project = project)
patches = request.user.profile.todo_patches(project = project)
if not patches.count():
continue
......@@ -195,13 +195,13 @@ def todo_lists(request):
context = PatchworkRequestContext(request)
context['todo_lists'] = todo_lists
context.project = request.user.get_profile().primary_project
context.project = request.user.profile.primary_project
return render_to_response('patchwork/todo-lists.html', context)
@login_required
def todo_list(request, project_id):
project = get_object_or_404(Project, linkname = project_id)
patches = request.user.get_profile().todo_patches(project = project)
patches = request.user.profile.todo_patches(project = project)
filter_settings = [(DelegateFilter,
{'delegate': request.user})]
......
......@@ -86,8 +86,6 @@ TEMPLATE_CONTEXT_PROCESSORS = (
"django.core.context_processors.i18n",
"django.core.context_processors.media")
AUTH_PROFILE_MODULE = "patchwork.userprofile"
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
......
......@@ -22,7 +22,7 @@
><strong>{{ user.username }}</strong></a>
<br/>
<a href="{% url 'patchwork.views.user.todo_lists' %}">todo
({{ user.get_profile.n_todo_patches }})</a> ::
({{ user.profile.n_todo_patches }})</a> ::
<a href="{% url 'patchwork.views.bundle.bundles' %}">bundles</a>
<br/>
<a href="{% url 'patchwork.views.user.profile' %}">profile</a> ::
......
......@@ -68,7 +68,7 @@ function toggle_headers(link_id, headers_id)
{% if patch.delegate %}
<tr>
<th>Delegated to:</th>
<td>{{ patch.delegate.get_profile.name }}</td>
<td>{{ patch.delegate.profile.name }}</td>
</tr>
{% endif %}
<tr>
......
......@@ -7,16 +7,16 @@
{% block body %}
<p>
{% if user.get_profile.maintainer_projects.count %}
{% if user.profile.maintainer_projects.count %}
Maintainer of
{% for project in user.get_profile.maintainer_projects.all %}
{% for project in user.profile.maintainer_projects.all %}
<a href="{% url 'patchwork.views.patch.list' project_id=project.linkname %}"
>{{ project.linkname }}</a>{% if not forloop.last %},{% endif %}{% endfor %}.
{% endif %}
{% if user.get_profile.contributor_projects.count %}
{% if user.profile.contributor_projects.count %}
Contributor to
{% for project in user.get_profile.contributor_projects.all %}
{% for project in user.profile.contributor_projects.all %}
<a href="{% url 'patchwork.views.patch.list' project_id=project.linkname %}"
>{{ project.linkname }}</a>{% if not forloop.last %},{% endif %}{% endfor %}.
{% endif %}
......@@ -25,10 +25,10 @@ Contributor to
<div class="leftcol">
<div class="box">
<h2>Todo</h2>
{% if user.get_profile.n_todo_patches %}
{% if user.profile.n_todo_patches %}
<p>Your <a href="{% url 'patchwork.views.user.todo_lists' %}">todo
list</a> contains {{ user.get_profile.n_todo_patches }}
patch{{ user.get_profile.n_todo_patches|pluralize:"es" }}.</p>
list</a> contains {{ user.profile.n_todo_patches }}
patch{{ user.profile.n_todo_patches|pluralize:"es" }}.</p>
{% else %}
<p>Your todo list contains patches that have been delegated to you. You
have no items in your todo list at present.</p>
......
......@@ -18,7 +18,7 @@
<th>Maintainer{{maintainers|length|pluralize}}</th>
<td>
{% for maintainer in maintainers %}
{{ maintainer.get_profile.name }}
{{ maintainer.profile.name }}
&lt;<a href="mailto:{{maintainer.email}}">{{maintainer.email}}</a>&gt;
<br />
{% endfor %}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment