Skip to content

Commit

Permalink
Fix on profile naming issue in context_processor
Browse files Browse the repository at this point in the history
  • Loading branch information
pydanny committed Aug 15, 2012
1 parent 2d2ab21 commit 21f246c
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 6 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG
Expand Up @@ -2,6 +2,8 @@
CHANGELOG
=========

# 0.1.3 Fixed problem with profile model name differences between projects

# 0.1.2 Improved multi-threading

# 0.1.1 Fixed multi-threading issue on request object
Expand Down
2 changes: 1 addition & 1 deletion README.rst
Expand Up @@ -2,7 +2,7 @@
django-profiletools
===================
:Info: Tools for Profile models in Django.
:Version: 0.1.2
:Version: 0.1.3
:Author: Daniel Greenfeld (http://pydanny.com)

Features
Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Expand Up @@ -50,7 +50,7 @@
# The short X.Y version.
version = '0.1'
# The full version, including alpha/beta/rc tags.
release = '0.1.2'
release = '0.1.3'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
2 changes: 1 addition & 1 deletion profiletools/__init__.py
@@ -1,6 +1,6 @@
__author__ = 'Daniel Greenfeld'

VERSION = (0, 1, 2)
VERSION = (0, 1, 3)


def get_version():
Expand Down
7 changes: 4 additions & 3 deletions profiletools/context_processors.py
Expand Up @@ -6,7 +6,8 @@ def fetch_profile(request):

context = {}
if request.user.is_authenticated():
profile = request.my_profile
if profile:
context[get_my_profile_module_name()] = profile
profile_module_name = get_my_profile_module_name()
profile = getattr(request, profile_module_name, None)
if profile != None:
context[profile_module_name] = profile
return context
7 changes: 7 additions & 0 deletions profiletools/utils.py
Expand Up @@ -17,5 +17,12 @@ def get_profile(user):


def get_my_profile_module_name():
""" Figures out the name of the profile model name from the AUTH_PROFILE_MODULE setting
Examples:
my_profile = profiles.Profile
my_membership = members.Membership
"""
my_profile_module_name = settings.AUTH_PROFILE_MODULE.split('.')[-1].lower()
return "my_{0}".format(my_profile_module_name)

0 comments on commit 21f246c

Please sign in to comment.