Django Library Users
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
Dirk Alders 89abad4430 Interface to define additional profile parameters added 1 mês atrás
locale/de/LC_MESSAGES Initial users implementation 4 anos atrás
migrations Password and User settings Form implemented 1 mês atrás
templates/users Interface to define additional profile parameters added 1 mês atrás
.gitignore Initial commit 4 anos atrás
LICENSE Initial commit 4 anos atrás
README.md Interface to define additional profile parameters added 1 mês atrás
__init__.py Initial users implementation 4 anos atrás
admin.py Initial users implementation 4 anos atrás
apps.py Initial users implementation 4 anos atrás
context.py Self registration with mail validation and admin activation implemented 1 mês atrás
emails.py Self registration with mail validation and admin activation implemented 1 mês atrás
forms.py Password and User settings Form implemented 1 mês atrás
middleware.py Initial users implementation 4 anos atrás
models.py Password and User settings Form implemented 1 mês atrás
parameter.py Interface to define additional profile parameters added 1 mês atrás
signals.py Logger creation simplified 2 meses atrás
tests.py Initial users implementation 4 anos atrás
tokens.py Self registration with mail validation and admin activation implemented 1 mês atrás
urls.py Self registration with mail validation and admin activation implemented 1 mês atrás
views.py Interface to define additional profile parameters added 1 mês atrás

README.md

users

With the django library users, you are abel to register users, add users, login, logout and do some basic adjustments for the user. This library includes some pages for that based on the extension theme.

Requirements

Python

You need to ensure that pytz is available in your python environment.

Django libs

You need to integrate the themes library as well.

Integration

Clone the library in your django application.

Configurations in your settings.py

Add the following line to the list INSTALLED_APPS:

    'users.apps.UsersConfig',

and this line to let django know the login url

LOGIN_URL = 'users-login'

Configurations in your urls.py

and add the following line to the list urlpatterns:

    path('users/', include('users.urls')),

Parameter

All parameters can be added in the django settings.py or in a config.py in the root django folder. The definitions in the config.py will be used before the definitions in settings.py.

USERS_SELF_REGISTRATION

This parameter can be True or False. It enables or disables the self registration.

USERS_MAIL_VALIDATION

This parameter can be True or False. It enables or disables the mail validation after self registration.

USERS_ADMIN_ACTIVATION

This parameter can be True or False. It enables or disables the activation by an admin after mail validation.

USERS_PROFILE_ADDITIONS

With the USER_PROFILE_ADDITIONS, you can define additional profile parameters for a user. You need to define a model:

# USERPROFILE Model
#
class YourUserProfile(models.Model):
    user = models.OneToOneField(User, unique=True, on_delete=models.CASCADE)
    your_parameter = models.IntegerField(default=10)

and a form (called with only one parameter request):

class YourUserProfileForm(forms.ModelForm):
    class Meta:
        model = YourUserProfile
        fields = ['your_parameter', ]
    def __init__(self, request):
        if request.POST:
            super().__init__(data=request.POST, instance=get_pattuserprofile(request.user))
        else:
            super().__init__(instance=get_pattuserprofile(request.user))

The USER_PROFILE_ADDITIONS is a dictionary where the key is the Heading and the value is the Form to be used. It shall be defined in settings.py like this:

USERS_PROFILE_ADDITIONS = {"Your Profile": 'your.forms.YourUserProfileForm'}

Usage

Actionabr

You might want to add the user actions by calling users.context.menubar(bar, request) with bar as menubar. See theme dosumentation for more details.