users package

Submodules

users.admin module

users.apps module

class users.apps.UsersConfig(app_name, app_module)

Bases: django.apps.config.AppConfig

name = 'users'

users.middleware module

class users.middleware.GetTokenMiddleware(get_response)

Bases: object

Middleware used to get the token from HTTP headers

users.models module

users.models.create_auth_token(sender, instance=None, created=False, **kwargs)

Create token for user

users.models.reset_auth_token(instance)

Method to assign a new token to a user

users.serializers module

class users.serializers.GroupSerializer(instance=None, data=<class 'rest_framework.fields.empty'>, **kwargs)

Bases: rest_framework.serializers.ModelSerializer

Serializer to map the Model instance into JSON format.

class Meta

Bases: object

Meta class to map serializer’s fields with the model fields.

fields = ('name',)
model

alias of django.contrib.auth.models.Group

class users.serializers.LoginUserSerializer(instance=None, data=<class 'rest_framework.fields.empty'>, **kwargs)

Bases: rest_framework.serializers.ModelSerializer

Serializer to map the Model instance into JSON format.

class Meta

Bases: object

Meta class to map serializer’s fields with the model fields.

fields = ('username', 'groups', 'first_name', 'last_name', 'email')
model

alias of django.contrib.auth.models.User

class users.serializers.UserSerializer(instance=None, data=<class 'rest_framework.fields.empty'>, **kwargs)

Bases: rest_framework.serializers.ModelSerializer

Serializer to map the Model instance into JSON format.

class Meta

Bases: object

Meta class to map serializer’s fields with the model fields.

fields = ('username', 'email')
model

alias of django.contrib.auth.models.User

users.urls module

users.views module

class users.views.LoggedObtainAuthToken(**kwargs)

Bases: rest_framework.authtoken.views.ObtainAuthToken

API endpoint to obtain authorization tokens

post(request, *args, **kwargs)

Handle post requests

class users.views.UserViewSet(**kwargs)

Bases: rest_framework.viewsets.ModelViewSet

List, Create, Retrieve, Update and Destroy Users.

allowed_actions(request, pk=None)

Returns a dictionary with users permissions: ack, shelve, unshelve

basename = None
can_ack(request, pk=None)

Check if the user has acknowledge permissions

can_shelve(request, pk=None)

Check if the user has shelve permissions

can_unshelve(request, pk=None)

Check if the user has unshelve permissions

detail = None
filter(request)

Retrieve the list of users filtered by group

get_permissions()

Instantiates and returns the list of permissions that the view requires

queryset = <QuerySet [<User: admin>, <User: operator_on_duty>, <User: timer>]>
serializer_class

alias of users.serializers.UserSerializer

suffix = None
validate_token(request)

Validates the token and returns 2 dictionaries: user data and users permissions (ack, shelve, unshelve)

Module contents