Coder Social home page Coder Social logo

mgaller / djpl-users Goto Github PK

View Code? Open in Web Editor NEW

This project forked from tonimichel/djpl-users

0.0 2.0 0.0 132 KB

If you need non-admin users with all the signup, confirmation email and password reset stuff

License: MIT License

Python 66.85% CSS 14.49% HTML 18.66%

djpl-users's Introduction

djpl-users

A django-productline feature to enable user functionality for non-admin multiuser scenarios. Builds upon django.auth and provides signup, confirmation email, and password reset functionality.

This is a django-productline feature: https://django-productline.readthedocs.org/en/latest/

Installation

pip install -e git+https://github.com/tonimichel/djpl-users.git#egg=djpl-users

Usage

users provides an abstract model and urlpatterns to enable custom user models featuring:

  • confirmation emails when a user is created
  • password reset process when a user forgot his password
  • admin actions to manually send confirmation emails

The users feature is designed for scenarios where you have a user base and dont want to set or reset each user's password manually. You can use it in admin scenarios or non-admin scenarios.

Integrating djpl-users can be accomplished in 4 steps:

  1. Add users to your settings.INSTALLED_APPS or add the feature to your product
  2. Create your own user model extending AbstractUser
  3. Register your custom user model users.register(modelclass, config)
  4. Add the urlpatterns (usermodel.get_urlpatterns)

As the feature sends emails, be sure to introduce the necessary email server configuration in your settings.

Your models

Just extend AbstractUser and register your new model.

from django.db import models
from users.models import AbstractUser
import users

class FooUser(AbstractUser):

    someadditionalfield = models.CharField(max_length=255)

users.register(FooUser, dict(
    APP_LABEL = 'myappname', # used for prefixing the urlnames
    URL_PREFIX = 'myurlprefix', # all users urls are prefixed with that string
    FROM_EMAIL = '[email protected]', # your from email
    CONFIRM_EMAIL_SUBJECT = 'your new FooApp account', # the subject of the email
    LOGIN_URL = 'login/', # the login url relative to the URL_PREFIX
    LOGIN_REDIRECT_URL = '/',
    LOGOUT_REDIRECT_URL = '/ciao/',
    USE_USER_EMAIL = False, # indicate whether to use the email of this user or not; for debugging set to false;
    ADDITIONALLY_SEND_TO = [], # additionally send these emails to
))

Your urlpatterns

from foo.models import FooUser

...

urlpatterns += FooUser.get_urlpatterns()

admin.py

from django.contrib import admin
from users.admin import UserAdmin
from foo.models import FooUser

class FooUserAdmin(UserAdmin):
    pass


admin.site.register(FooUser, FooUserAdmin)

License

MIT

djpl-users's People

Contributors

tonimichel avatar henzk avatar wirai avatar

Watchers

James Cloos avatar Michael Galler avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.