Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c18fea9
commit e244478
Showing
29 changed files
with
541 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,113 @@ | ||
.. _activation: | ||
|
||
User Activation | ||
*************** | ||
|
||
Many web applications require some form of user activation, usually to verify | ||
user-provided information such as email addresses. django-user-profiles provides | ||
an activation module, implemented as a Django application. | ||
|
||
|
||
Installation | ||
============ | ||
|
||
- In order to enable activation, add the ``activation`` module to your | ||
``INSTALLED_APPS`` setting:: | ||
|
||
INSTALLED_APPS = ( | ||
# ... your other apps here | ||
'user_profiles', | ||
'user_profiles.activation', | ||
) | ||
|
||
- Include the activation URLconf in your ``urls.py``:: | ||
|
||
urlpatterns = patterns('', | ||
# ... your urls here | ||
(r'^user/', include('user_profiles.activation.urls')), | ||
) | ||
|
||
.. note:: | ||
Whenever new user sign up, they will now be sent an activation request via | ||
email. However, if you want to prevent new users from logging in unless they | ||
have activated, you need to set :ref:`USER_PROFILES_USER_SET_ACTIVE_ON_SIGNUP | ||
<user-profiles-user-set-active-on-signup>` to ``False`` in your project's | ||
settings module. Sometimes you also need to re-request activation from users, | ||
for instance when they change their email address. See | ||
:ref:`activation-utility` for more information. | ||
|
||
This application automatically connects to the ``post_signup`` signal dispatched | ||
by django-user-profiles in order send to request activation from new users. | ||
See the :ref:`signals documentation <user-profiles-signals>` for more | ||
information. | ||
|
||
|
||
.. _activation-templates: | ||
|
||
Message templates | ||
================= | ||
|
||
For rendering the activation request email, text templates are used. You are | ||
likely to require your own customized messages. To customize the email text, | ||
simply your own templates with the following names: | ||
|
||
``activation/email/activation_request.subject.txt`` | ||
The subject line of the activation email. | ||
|
||
``activation/email/activation_request.txt`` | ||
The body text of the activation email. This should display the activation | ||
key to the user, plus a link to the activation page and form. Example template:: | ||
Dear {{ recipient }}, please go to {{ url }} to activate your account. | ||
If the above link doesn't work, go to {{ form_url }} and enter the | ||
following key: {{ key }} | ||
|
||
The following context variables are available to both of these templates: | ||
|
||
``url`` | ||
The activation link URL | ||
|
||
``form_url`` | ||
The link to the activation form | ||
|
||
``site_url`` | ||
The link to the website that requires activation | ||
|
||
``site`` | ||
The corresponding ``Site`` object | ||
|
||
``key`` | ||
The activation key | ||
|
||
``user`` | ||
The associated ``User`` object | ||
|
||
``recipient`` | ||
An object that resolves to a string containing the name of the user (i.e. | ||
either the user or the profile object, depending on whether the profile | ||
model has a ``__unicode__`` method). | ||
|
||
``profile`` | ||
The associated user profile object. | ||
|
||
``created`` | ||
If the user was just created, this will ``True``. If the user already | ||
existed, it will be ``False``. You are probably going to want to address | ||
users in a different way if the just signed up. | ||
|
||
|
||
Views | ||
===== | ||
|
||
.. automodule:: user_profiles.activation.views | ||
:members: | ||
|
||
.. _activation-utility: | ||
|
||
Utility functions | ||
================= | ||
|
||
.. autofunction:: user_profiles.activation.utils.require_activation_from_user | ||
|
||
.. autofunction:: user_profiles.activation.utils.accept_activation_code |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
from django.db import models | ||
|
||
class Profile(models.Model): | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,7 @@ | ||
.. _forms: | ||
|
||
User Forms | ||
********** | ||
********** | ||
|
||
.. automodule:: user_profiles.forms | ||
:members: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,40 @@ | ||
Installing django-user-profiles | ||
******************************* | ||
|
||
.. note:: | ||
Please refer to the Django documentation on `storing additional information | ||
about users | ||
<https://docs.djangoproject.com/en/1.3/topics/auth/#storing-additional-information-about-users>`_ | ||
for more information about how Django handles user profiles. | ||
|
||
- Create a user profile model subclassing | ||
``user_profiles.models.UserProfileBase``, and define it in your project | ||
settings (see :ref:`models`):: | ||
|
||
AUTH_PROFILE_MODULE = 'my_app.MyUserProfile' | ||
- Add the ``user_profiles`` module to your ``INSTALLED_APPS`` setting:: | ||
|
||
INSTALLED_APPS = ( | ||
# ... your other apps here | ||
'user_profiles', | ||
) | ||
|
||
- Add ``user_profiles.middleware.CurrentUserMiddleware`` to your ``MIDDLEWARE_CLASSES``:: | ||
|
||
MIDDLEWARE_CLASSES = ( | ||
# ... your other middleware classes here | ||
'user_profiles.middleware.CurrentUserMiddleware', | ||
) | ||
|
||
|
||
- Include the URLconf in your ``urls.py``:: | ||
|
||
urlpatterns = patterns('', | ||
# ... your urls here | ||
(r'^user/', include('user_profiles.urls')), | ||
) | ||
|
||
- If you want to enable user activation, you also need to install that module. | ||
See :ref:`activation`. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,5 @@ | ||
Model Managers | ||
************** | ||
************** | ||
|
||
.. automodule:: user_profiles.managers | ||
:members: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,9 @@ | ||
.. _middleware: | ||
|
||
Middleware | ||
********** | ||
|
||
.. automodule:: user_profiles.middleware | ||
:members: | ||
:members: | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
.. _models: | ||
|
||
User Profile Models | ||
******************* | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,26 @@ | ||
Implementing a multiple-profiles-per-user feature | ||
************************************************* | ||
************************************************* | ||
|
||
This application provides very basic support for implementing a web site where | ||
one user can have several profiles (as in different sets of contact | ||
information), with one being their default profile that is returned by Django's | ||
``user.get_profile()`` method. This is achieved by filtering profile objects | ||
by the ``is_default`` field. Please see the :ref:`user profile base model | ||
<models>` for more information on this subject. | ||
|
||
Currently, django-user-profiles comes without any views for creating, | ||
displaying, updating or deleting additional profiles (although this might change | ||
in the future). You are responsible for creating such views yourself. | ||
|
||
These views can be pretty standard, following the basic CRUD concept as seen in | ||
most Django applications. You can use the standard model form provided by | ||
django-user-profiles, and of course you need to make sure that users can only | ||
edit their own profiles. | ||
|
||
.. warning:: | ||
If you are implementing a multiple-profiles-per-user feature in your project, | ||
you should prevent users from deleting their default profile by checking | ||
first whether ``is_default`` is ``True``. When creating additonal profiles | ||
for a user, you also need to make sure that the ``is_default`` field is | ||
``True`` for exactly one profile object so as not to create any ambiguities | ||
that lead to errors. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,10 @@ | ||
Secondary features | ||
****************** | ||
Secondary features and fixes | ||
**************************** | ||
|
||
.. toctree:: | ||
:maxdepth: 2 | ||
|
||
middleware | ||
admin | ||
managers | ||
patches | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
.. _user-profiles-signals: | ||
|
||
Signals | ||
******* | ||
|
||
django-user-profiles provides the following signals that you can connect to if | ||
you need specific code to be executed on certain events. | ||
|
||
.. automodule:: user_profiles.signals | ||
:members: |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,5 @@ | ||
User Views | ||
********** | ||
|
||
.. automodule:: user_profiles.views | ||
:members: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
from django.conf.urls.defaults import * | ||
|
||
urlpatterns = patterns('', | ||
url(r'^activation/send/$', 'user_profiles.activation.views.current_user_send', name='user_profiles_activation_current_user_send'), | ||
url(r'^activation/([a-z0-9]+)/$', 'user_profiles.activation.views.activate', name='user_profiles_activation_activate'), | ||
url(r'^activation/send/$', 'user_profiles.activation.views.send_activation_code_to_user', name='user_profiles_send_activation_code_to_user'), | ||
url(r'^activation/([a-z0-9]+)/$', 'user_profiles.activation.views.activate', name='user_profiles_activate'), | ||
url(r'^activation/$', 'user_profiles.activation.views.activate', name='user_profiles_activation_form'), | ||
) | ||
|
Oops, something went wrong.