django userproperty
Project description
# [django-userproperty](https://github.com/arteria/django-userproperty)
[django-userproperty](https://github.com/arteria/django-userproperty) is a pluggable/reusable Django app that manages per user and global properties. In addition,
[django-userproperty](https://github.com/arteria/django-userproperty) provides helper functions to set, get, incerement and decrement these properties.
## Installation
Install the package:
pip install django-userproperty
Add the app in you settings.py:
INSTALLED_APPS = (
'userproperty',
)
And finally sync your db
python manage.py syncdb
## Usage
### Example:
After creating an account on your website, the user needs to do some tasks before he can enter his profile. In this example adding more information and agreeing to the terms and conditions.
When creating the new user you create a new property:
from userproperty.utils import addProperty
addProperty(request, tag='setup')
# if the user is not saved in the request add: anUser=yourNewUser
In your login view you can now have different outcomes based on the UserProperty
from userproperty.utils import getIntegerProperty, setIntegerProperty, removeProperty
#in your login view
setupProperty = getIntegerProperty(request,'setup')
if setupProperty is 1:
#redirect, a form for adding phone number etc
elif setupProperty is 2:
#redirect, accepting the terms and conditions
elif setupProperty:
removeProperty(request, tag='setup')
# stuff when no property was set
The only thing left to do is setting the property to a new value when the respective actions(forms in this case) are done:
from userproperty.utils import setIntegerProperty, removeProperty
#in the view with the form for the phonenumer etc.
form.is_valid():
#do stuff
setIntegerProperty(request, tag='setup', value=2)
#redirect login
#in the view for terms and conditions
form.is_valid():
#do stuff
removeProperty(request, tag='setup')
#redirect login
Other examples: setup tour, saving user specific properties(number of data entries displayed in js datatables), etc.
## PEP8
The functions are available in pep8 (lowercase with _ as separator between words)
setIntegerProperty() ==> set_integer_property()
[django-userproperty](https://github.com/arteria/django-userproperty) is a pluggable/reusable Django app that manages per user and global properties. In addition,
[django-userproperty](https://github.com/arteria/django-userproperty) provides helper functions to set, get, incerement and decrement these properties.
## Installation
Install the package:
pip install django-userproperty
Add the app in you settings.py:
INSTALLED_APPS = (
'userproperty',
)
And finally sync your db
python manage.py syncdb
## Usage
### Example:
After creating an account on your website, the user needs to do some tasks before he can enter his profile. In this example adding more information and agreeing to the terms and conditions.
When creating the new user you create a new property:
from userproperty.utils import addProperty
addProperty(request, tag='setup')
# if the user is not saved in the request add: anUser=yourNewUser
In your login view you can now have different outcomes based on the UserProperty
from userproperty.utils import getIntegerProperty, setIntegerProperty, removeProperty
#in your login view
setupProperty = getIntegerProperty(request,'setup')
if setupProperty is 1:
#redirect, a form for adding phone number etc
elif setupProperty is 2:
#redirect, accepting the terms and conditions
elif setupProperty:
removeProperty(request, tag='setup')
# stuff when no property was set
The only thing left to do is setting the property to a new value when the respective actions(forms in this case) are done:
from userproperty.utils import setIntegerProperty, removeProperty
#in the view with the form for the phonenumer etc.
form.is_valid():
#do stuff
setIntegerProperty(request, tag='setup', value=2)
#redirect login
#in the view for terms and conditions
form.is_valid():
#do stuff
removeProperty(request, tag='setup')
#redirect login
Other examples: setup tour, saving user specific properties(number of data entries displayed in js datatables), etc.
## PEP8
The functions are available in pep8 (lowercase with _ as separator between words)
setIntegerProperty() ==> set_integer_property()
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Close
Hashes for django-userproperty-1.0.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | fa4023639f29bdf05a11482dbf82833a63452ccb427cf2da2c8a7086a5c5a87f |
|
MD5 | 1c8a022946eb1fc60c6946876cfd42e3 |
|
BLAKE2b-256 | d1ab3540e5b71238893a9ba5937b65d395bb1efd045a9888a9ba3c18fc261a0d |