users_api package

Module contents

Created on Aug 10, 2016

@author: lubo

class users_api.models.VerificationPath(id, path, user)[source]

Bases: django.db.models.base.Model

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

objects = <django.db.models.manager.Manager object>
path

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

user

Accessor to the related object on the forward side of a one-to-one relation.

In the example:

class Restaurant(Model):
    place = OneToOneField(Place, related_name='restaurant')

Restaurant.place is a ForwardOneToOneDescriptor instance.

user_id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

class users_api.models.WdaeUser(id, password, last_login, is_superuser, name, email, is_staff, is_active, date_joined)[source]

Bases: django.contrib.auth.base_user.AbstractBaseUser, django.contrib.auth.models.PermissionsMixin

DEFAULT_GROUPS_FOR_USER = ('any_user',)
exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

REQUIRED_FIELDS = ['name']
SUPERUSER_GROUP = 'admin'
UMLIMITTED_DOWNLOAD_GROUP = 'unlimitted'
USERNAME_FIELD = 'email'
add_obj_perm(perm, obj)
property allowed_datasets
app_label = 'api'
auth_token

Accessor to the related object on the reverse side of a one-to-one relation.

In the example:

class Restaurant(Model):
    place = OneToOneField(Place, related_name='restaurant')

Place.restaurant is a ReverseOneToOneDescriptor instance.

static change_password(verification_path, new_password)[source]
date_joined

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

deauthenticate()[source]
del_obj_perm(perm, obj)
email

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

email_user(subject, message, from_email=None)[source]
evict_obj_perms_cache()
static get_anonymous()
get_full_name()[source]
get_protected_group_names()[source]
get_short_name()[source]

Returns the short name for the user.

groups

Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.

In the example:

class Pizza(Model):
    toppings = ManyToManyField(Topping, related_name='pizzas')

Pizza.toppings and Topping.pizzas are ManyToManyDescriptor instances.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

property has_unlimitted_download
id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

is_staff

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

logentry_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

name

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

objects = <users_api.models.WdaeUserManager object>
property protected_groups
register_preexisting_user(name)[source]
reset_password(by_admin=False)[source]
set_password(raw_password)[source]
set_unusable_password()[source]
user_permissions

Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.

In the example:

class Pizza(Model):
    toppings = ManyToManyField(Topping, related_name='pizzas')

Pizza.toppings and Topping.pizzas are ManyToManyDescriptor instances.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

userobjectpermission_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

userquery_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

verificationpath

Accessor to the related object on the reverse side of a one-to-one relation.

In the example:

class Restaurant(Model):
    place = OneToOneField(Place, related_name='restaurant')

Place.restaurant is a ReverseOneToOneDescriptor instance.

class users_api.models.WdaeUserManager(*args, **kwargs)[source]

Bases: django.contrib.auth.base_user.BaseUserManager

create(**kwargs)[source]

Create a new object with the given kwargs, saving it to the database and returning the created object.

create_superuser(email, password, **kwargs)[source]
create_user(email, password=None, **kwargs)[source]
get_or_create(**kwargs)[source]

Look up an object with the given kwargs, creating one if necessary. Return a tuple of (object, created), where created is a boolean specifying whether an object was created.

users_api.models.get_anonymous_user_instance(CurrentUserModel)[source]
users_api.models.group_post_delete(sender, **kwargs)[source]
users_api.models.group_pre_delete(sender, **kwargs)[source]
users_api.models.send_already_existing_email(user)[source]
users_api.models.send_reset_email(user, verif_path, by_admin=False)[source]

Returns dict - subject and message of the email

users_api.models.send_reset_inactive_acc_email(user)[source]
users_api.models.send_verif_email(user, verif_path)[source]
users_api.models.staff_update(sender, **kwargs)[source]
class users_api.views.UserViewSet(**kwargs)[source]

Bases: rest_framework.viewsets.ModelViewSet

bulk_add_groups(request)[source]
bulk_remove_groups(request)[source]
create(request)[source]
destroy(request, pk=None)[source]
filter_backends = (<class 'rest_framework.filters.SearchFilter'>,)
get_serializer_class()[source]

Return the class to use for the serializer. Defaults to using self.serializer_class.

You may want to override this if you need to provide different serializations depending on the incoming request.

(Eg. admins get full serialization, others get basic serialization)

list(request)[source]
pagination_class = None
partial_update(request, pk=None)[source]
password_reset(request, pk=None)[source]
permission_classes = (<class 'rest_framework.permissions.IsAdminUser'>,)
queryset
retrieve(request, pk=None)[source]
search_fields = ('groups__name', 'email', 'name')
serializer_class

alias of users_api.serializers.UserSerializer

update(request, pk=None, *args, **kwargs)[source]
users_api.views.change_password(self, request, *args, **kwargs)[source]
users_api.views.check_verif_path(self, request, *args, **kwargs)[source]
users_api.views.csrf_clear(view_func)[source]

Skips the CSRF checks by setting the ‘csrf_processing_done’ to true.

users_api.views.get_user_info(self, request, *args, **kwargs)[source]
users_api.views.iterator_to_json(users)[source]
users_api.views.login(self, request, *args, **kwargs)[source]
users_api.views.logout(self, request, *args, **kwargs)[source]
users_api.views.register(self, request, *args, **kwargs)[source]
users_api.views.reset_password(self, request, *args, **kwargs)[source]
class users_api.authentication.SessionAuthenticationWithUnauthenticatedCSRF[source]

Bases: rest_framework.authentication.SessionAuthentication

authenticate(request)[source]

Returns a User if the request session currently has a logged in user. Otherwise returns None.

class users_api.authentication.SessionAuthenticationWithoutCSRF[source]

Bases: rest_framework.authentication.SessionAuthentication

enforce_csrf(request)[source]

Enforce CSRF validation for session based authentication.

class users_api.serializers.BulkGroupOperationSerializer(*args, **kwargs)[source]

Bases: rest_framework.serializers.Serializer

create(validated_data)[source]
to_internal_value(data)[source]

Dict of native values <- Dict of primitive datatypes.

to_representation(instance)[source]

Object instance -> Dict of primitive datatypes.

update(instance, validated_data)[source]
class users_api.serializers.CreatableSlugRelatedField(*args, **kwargs)[source]

Bases: rest_framework.relations.SlugRelatedField

to_internal_value(data)[source]

Transform the incoming primitive data into a native value.

class users_api.serializers.UserSerializer(*args, **kwargs)[source]

Bases: rest_framework.serializers.ModelSerializer

class Meta[source]

Bases: object

fields = ('id', 'email', 'name', 'hasPassword', 'groups', 'allowedDatasets')
model

alias of users_api.models.WdaeUser

create(validated_data)[source]

We have a bit of extra checking around this in order to provide descriptive messages when something goes wrong, but this method is essentially just:

return ExampleModel.objects.create(**validated_data)

If there are many to many fields present on the instance then they cannot be set until the model is instantiated, in which case the implementation is like so:

example_relationship = validated_data.pop(‘example_relationship’) instance = ExampleModel.objects.create(**validated_data) instance.example_relationship = example_relationship return instance

The default implementation also does not handle nested relationships. If you want to support writable nested relationships you’ll need to write an explicit .create() method.

update(instance, validated_data)[source]
validate(data)[source]
class users_api.serializers.UserWithoutEmailSerializer(*args, **kwargs)[source]

Bases: users_api.serializers.UserSerializer

class Meta[source]

Bases: object

fields = ('id', 'name', 'hasPassword', 'groups', 'allowedDatasets')
model

alias of users_api.models.WdaeUser

class users_api.validators.ProtectedGroupsValidator[source]

Bases: object

set_context(serializer_field)[source]
class users_api.validators.SomeSuperuserLeftValidator[source]

Bases: object

set_context(serializer_field)[source]

Created on Aug 10, 2016 @author: lubo