onadata.apps.api.viewsets.user_profile_viewset module

Module contents

UserProfileViewSet module.

class onadata.apps.api.viewsets.user_profile_viewset.UserProfileViewSet(**kwargs)

Bases: AuthenticateHeaderMixin, CacheControlMixin, ETagsMixin, ObjectLookupMixin, DefaultBaseViewset, ModelViewSet

List, Retrieve, Update, Create/Register users.

change_password(request, *args, **kwargs)

Change user’s password.

create(request, *args, **kwargs)

Create and cache user profile

filter_backends = (<class 'onadata.libs.filters.UserProfileFilter'>, <class 'rest_framework.filters.OrderingFilter'>)
get_object(queryset=None)

Lookup user profile by pk or username

lookup_field = 'user'
monthly_submissions(request, *args, **kwargs)

Get the total number of submissions for a user

ordering = ('user__username',)
partial_update(request, *args, **kwargs)

Allows for partial update of the user profile data.

permission_classes = [<class 'onadata.apps.api.permissions.UserProfilePermissions'>]
queryset
retrieve(request, *args, **kwargs)

Get user profile from cache or db

send_verification_email(request, *args, **kwargs)

Sends verification email on user profile registration.

serializer_class

alias of UserProfileSerializer

update(request, *args, **kwargs)

Update user in cache and db

verify_email(request, *args, **kwargs)

Accpet’s email verification token and marks the profile as verified.

onadata.apps.api.viewsets.user_profile_viewset.change_password_attempts(request)

Track number of login attempts made by user within a specified amount of time

onadata.apps.api.viewsets.user_profile_viewset.check_if_key_exists(a_key, expected_dict)

Return True or False if a_key exists in the expected_dict dictionary.

onadata.apps.api.viewsets.user_profile_viewset.check_user_lockout(request)

Returns the error object with lockout error message.

onadata.apps.api.viewsets.user_profile_viewset.replace_key_value(lookup, new_value, expected_dict)

Replaces the value matching the key ‘lookup’ in the ‘expected_dict’ with the new value ‘new_value’.

onadata.apps.api.viewsets.user_profile_viewset.serializer_from_settings()

Return a serilizer class configured in settings.PROFILE_SERIALIZER or default to UserProfileSerializer.

onadata.apps.api.viewsets.user_profile_viewset.set_is_email_verified(profile, is_email_verified)

Sets is_email_verified value in the profile’s metadata object.