Basic user proerties and user ability for django 1.5.
Project description
# django-userpure
Basic feature set for managing users in Django 1.5.
With the deprecation of user profiles and the growth of
custom user models, the need for a new user management system
was necessary.
## Installation
To install ``django-userpure``, download django-userpure and run:
python setup.py insatll
## Usage
The following is an example of how to use the Activation feature:
``models.py``:
class UserManager(UserpureActivationManager, BaseUserManager):
def create_user(self, email, password, **extra_fields):
now = timezone.now()
if not email:
raise ValueError('The given email must be set')
email = UserManager.normalize_email(email)
user = self.model(email=email, is_active=True, is_superuser=False, last_login=now, **extra_fields)
user.set_password(password)
user.save(using=self._db)
return user
class User(UserpureActivationMixin, PermissionsMixin, AbstractBaseUser):
objects = UserManager()
USERNAME_FIELD = 'email'
REQUIRED_FIELDS = []
``views.py``:
class Activate(View):
"""
Activate a user by activation key.
"""
activation_key = None
user = None
redirect_url = None
def get(self, request):
self.activation_key = request.GET.get('activation_key', None)
if self.activation_key:
self.user = get_user_model().objects.activate(self.activation_key)
if self.user:
messages.success(request, _("User activated successfully."))
else:
messages.error(request, _("Could not activate user."))
return HttpResponseRedirect(self.redirect_url)
## Design
The idea is that any amount of functionality can be mixed into managers or models.
Since there are two types of forms, mixins can be danerous to use with forms.
This is largely why forms are left out of the picture for now.
### Available models
1. ``UserpureActivationMixin`` enables activation of a user.
### Available managers
1. ``UserpureActivationManager`` enables activation of a user through a manager.
Basic feature set for managing users in Django 1.5.
With the deprecation of user profiles and the growth of
custom user models, the need for a new user management system
was necessary.
## Installation
To install ``django-userpure``, download django-userpure and run:
python setup.py insatll
## Usage
The following is an example of how to use the Activation feature:
``models.py``:
class UserManager(UserpureActivationManager, BaseUserManager):
def create_user(self, email, password, **extra_fields):
now = timezone.now()
if not email:
raise ValueError('The given email must be set')
email = UserManager.normalize_email(email)
user = self.model(email=email, is_active=True, is_superuser=False, last_login=now, **extra_fields)
user.set_password(password)
user.save(using=self._db)
return user
class User(UserpureActivationMixin, PermissionsMixin, AbstractBaseUser):
objects = UserManager()
USERNAME_FIELD = 'email'
REQUIRED_FIELDS = []
``views.py``:
class Activate(View):
"""
Activate a user by activation key.
"""
activation_key = None
user = None
redirect_url = None
def get(self, request):
self.activation_key = request.GET.get('activation_key', None)
if self.activation_key:
self.user = get_user_model().objects.activate(self.activation_key)
if self.user:
messages.success(request, _("User activated successfully."))
else:
messages.error(request, _("Could not activate user."))
return HttpResponseRedirect(self.redirect_url)
## Design
The idea is that any amount of functionality can be mixed into managers or models.
Since there are two types of forms, mixins can be danerous to use with forms.
This is largely why forms are left out of the picture for now.
### Available models
1. ``UserpureActivationMixin`` enables activation of a user.
### Available managers
1. ``UserpureActivationManager`` enables activation of a user through a manager.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
django-userpure-0.1.0.tar.gz
(8.2 kB
view details)
File details
Details for the file django-userpure-0.1.0.tar.gz
.
File metadata
- Download URL: django-userpure-0.1.0.tar.gz
- Upload date:
- Size: 8.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b92195ae8b5fd81eddfebbeca281c6e06f2e28fbeb3b13c24220a5c8e01ad3cb |
|
MD5 | 5156cf847c14b478a0b41f9165a1fea8 |
|
BLAKE2b-256 | 9a56985c4eccbb5b6e30957bf5384e13bf1e1be6239fd55e98f12d2765c1f9e8 |