accounts package

Subpackages

Submodules

accounts.admin module

accounts.apps module

class accounts.apps.AccountsConfig(app_name, app_module)[source]

Bases: AppConfig

default_auto_field = 'django.db.models.BigAutoField'
name = 'accounts'

accounts.models module

class accounts.models.User(id, password, last_login, is_superuser, username, first_name, last_name, is_staff, is_active, date_joined, email, phone_number, gstin, company_name, address, user_role)[source]

Bases: AbstractUser

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

USER_ROLE_CHOICES = [('procurement_officer', 'Procurement Officer'), ('vendor', 'Vendor')]
address

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

company_name

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

date_joined

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

email

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

first_name

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

get_next_by_date_joined(*, field=<django.db.models.fields.DateTimeField: date_joined>, is_next=True, **kwargs)
get_previous_by_date_joined(*, field=<django.db.models.fields.DateTimeField: date_joined>, is_next=False, **kwargs)
get_user_role_display(*, field=<django.db.models.fields.CharField: user_role>)
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.

gstin

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

gstin_validator = <django.core.validators.RegexValidator object>
id

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

inventory_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.

is_active

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.

is_superuser

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

last_login

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

last_name

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.

outstandingtoken_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.

password

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

phone_number

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

phone_number_regex = <django.core.validators.RegexValidator object>
supplierbid_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.

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.

user_role

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

username

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

vendor

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 accounts.models.Vendor(id, vendor_certified, vendor_type, contract_expiry_date, vendor_rating, total_ratings, user)[source]

Bases: Model

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

VENDOR_TYPE_CHOICES = [('supplier', 'Supplier'), ('manufacturer', 'Manufacturer'), ('service_provider', 'Service Provider')]
contract_expiry_date

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

get_next_by_contract_expiry_date(*, field=<django.db.models.fields.DateField: contract_expiry_date>, is_next=True, **kwargs)
get_previous_by_contract_expiry_date(*, field=<django.db.models.fields.DateField: contract_expiry_date>, is_next=False, **kwargs)
get_vendor_type_display(*, field=<django.db.models.fields.CharField: vendor_type>)
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>
total_ratings

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
vendor_certified

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

vendor_rating

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

vendor_type

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

accounts.permissions module

class accounts.permissions.IsProcurementOfficer[source]

Bases: BasePermission

has_permission(request, view)[source]

Return True if permission is granted, False otherwise.

class accounts.permissions.IsVendor[source]

Bases: BasePermission

has_permission(request, view)[source]

Return True if permission is granted, False otherwise.

accounts.serializers module

class accounts.serializers.ChangePasswordSerializer(*args, **kwargs)[source]

Bases: Serializer

update(instance, validated_data)[source]
validate(attrs)[source]
validate_old_password(value)[source]
class accounts.serializers.MyTokenObtainPairSerializer(*args, **kwargs)[source]

Bases: TokenObtainPairSerializer

classmethod get_token(user)[source]
class accounts.serializers.PasswordResetConfirmSerializer(*args, **kwargs)[source]

Bases: Serializer

validate(value)[source]
class accounts.serializers.PasswordResetSerializer(*args, **kwargs)[source]

Bases: Serializer

validate_email(value)[source]
class accounts.serializers.ProcurementOfficerRegisterSerializer(*args, **kwargs)[source]

Bases: ModelSerializer

class Meta[source]

Bases: object

fields = ('first_name', 'last_name', 'username', 'email', 'phone_number', 'gstin', 'company_name', 'address', 'password1', 'password2')
model

alias of User

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.

validate(attrs)[source]
class accounts.serializers.ProfileSerializer(*args, **kwargs)[source]

Bases: ModelSerializer

class Meta[source]

Bases: object

fields = ('first_name', 'last_name', 'username', 'email', 'phone_number', 'gstin', 'company_name', 'address', 'vendor')
model

alias of User

to_representation(instance)[source]

Object instance -> Dict of primitive datatypes.

update(instance, validated_data)[source]
class accounts.serializers.VendorInfoSerializer(*args, **kwargs)[source]

Bases: ModelSerializer

class Meta[source]

Bases: object

fields = ('vendor_certified', 'vendor_type')
model

alias of Vendor

class accounts.serializers.VendorRegisterSerializer(*args, **kwargs)[source]

Bases: ModelSerializer

class Meta[source]

Bases: object

fields = ('first_name', 'last_name', 'username', 'email', 'phone_number', 'gstin', 'company_name', 'address', 'password1', 'password2', 'vendor_info')
model

alias of User

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.

validate(attrs)[source]
class accounts.serializers.VendorSerializer(*args, **kwargs)[source]

Bases: ModelSerializer

class Meta[source]

Bases: object

fields = '__all__'
model

alias of Vendor

accounts.tasks module

accounts.tests module

class accounts.tests.ChangePasswordViewTests(methodName='runTest')[source]

Bases: SetUpUsers, APITestCase

setUp()[source]

Hook method for setting up the test fixture before exercising it.

test_change_password_successfully()[source]
test_change_password_unauthenticated()[source]
test_change_password_with_invalid_http_authorization_header()[source]
test_change_password_with_invalid_http_method()[source]
test_change_password_with_invalid_old_password()[source]
test_change_password_with_invalid_payload()[source]
test_change_password_with_mismatched_passwords()[source]
test_change_password_without_providing_old_password()[source]
class accounts.tests.PasswordResetConfirmViewTests(methodName='runTest')[source]

Bases: APITestCase

setUp()[source]

Hook method for setting up the test fixture before exercising it.

test_password_reset_confirm_successful()[source]
test_password_reset_confirm_with_authenticated_user()[source]
test_password_reset_confirm_with_invalid_http_method()[source]
test_password_reset_confirm_with_invalid_payload()[source]
test_password_reset_confirm_with_invalid_token()[source]
test_password_reset_confirm_with_invalid_user()[source]
test_password_reset_confirm_with_mismatched_passwords()[source]
class accounts.tests.PasswordResetViewTests(methodName='runTest')[source]

Bases: SetUpUsers, APITestCase

setUp()[source]

Hook method for setting up the test fixture before exercising it.

test_password_reset_successful()[source]
test_password_reset_with_authenticated_user()[source]
test_password_reset_with_invalid_email()[source]
test_password_reset_with_invalid_http_method()[source]
test_password_reset_with_invalid_payload()[source]
test_password_reset_with_missing_email()[source]
test_password_reset_with_unregistered_email()[source]
class accounts.tests.ProcurementOfficerRegisterViewTests(methodName='runTest')[source]

Bases: APITestCase

setUp()[source]

Hook method for setting up the test fixture before exercising it.

test_register_procurement_officer_user()[source]
test_register_user_with_authenticated_user()[source]
test_register_user_with_existing_email()[source]
test_register_user_with_existing_gstin()[source]
test_register_user_with_existing_username()[source]
test_register_user_with_invalid_email()[source]
test_register_user_with_invalid_gstin()[source]
test_register_user_with_invalid_http_method()[source]
test_register_user_with_invalid_payload()[source]
test_register_user_with_invalid_phone_number()[source]
test_register_user_with_password_mismatch()[source]
class accounts.tests.SetUpUsers(methodName='runTest')[source]

Bases: APITestCase

setUp()[source]

Hook method for setting up the test fixture before exercising it.

class accounts.tests.TokenViewTests(methodName='runTest')[source]

Bases: SetUpUsers, APITestCase

setUp()[source]

Hook method for setting up the test fixture before exercising it.

test_obtain_token()[source]
test_obtain_token_with_invalid_credentials()[source]
test_obtain_token_with_missing_credentials()[source]
test_refresh_token()[source]
test_refresh_token_which_was_used_previously()[source]
test_refresh_token_with_blacklisted_token()[source]
test_refresh_token_with_expired_token()[source]
test_refresh_token_with_invalid_token()[source]
class accounts.tests.UserProfileViewTests(methodName='runTest')[source]

Bases: SetUpUsers

setUp()[source]

Hook method for setting up the test fixture before exercising it.

test_delete_procurement_officer_profile()[source]
test_delete_user_profile_unauthenticated()[source]
test_delete_vendor_profile()[source]
test_get_procurement_officer_profile()[source]
test_get_user_profile_unauthenticated()[source]
test_get_vendor_profile()[source]
test_update_procurement_officer_profile()[source]
test_update_user_profile_unauthenticated()[source]
test_update_vendor_profile()[source]
class accounts.tests.VendorListViewTests(methodName='runTest')[source]

Bases: APITestCase

setUp()[source]

Hook method for setting up the test fixture before exercising it.

test_insufficient_permissions_vendor()[source]
test_no_vendors()[source]
test_sufficient_permissions_admin()[source]
test_sufficient_permissions_procurement_officer()[source]
test_vendor_list()[source]
class accounts.tests.VendorRegisterViewTests(methodName='runTest')[source]

Bases: APITestCase

setUp()[source]

Hook method for setting up the test fixture before exercising it.

test_register_user_with_authenticated_user()[source]
test_register_user_with_existing_email()[source]
test_register_user_with_existing_gstin()[source]
test_register_user_with_existing_username()[source]
test_register_user_with_invalid_email()[source]
test_register_user_with_invalid_gstin()[source]
test_register_user_with_invalid_http_method()[source]
test_register_user_with_invalid_payload()[source]
test_register_user_with_invalid_phone_number()[source]
test_register_user_with_password_mismatch()[source]
test_register_vendor_user()[source]

accounts.urls module

accounts.views module

class accounts.views.ChangePasswordView(**kwargs)[source]

Bases: UpdateAPIView

get_object()[source]

Returns the object the view is displaying.

You may want to override this if you need to provide non-standard queryset lookups. Eg if objects are referenced using multiple keyword arguments in the url conf.

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

alias of ChangePasswordSerializer

update(request, *args, **kwargs)[source]
class accounts.views.DeleteUserProfileView(**kwargs)[source]

Bases: DestroyAPIView

fields = '__all__'
get_object()[source]

Returns the object the view is displaying.

You may want to override this if you need to provide non-standard queryset lookups. Eg if objects are referenced using multiple keyword arguments in the url conf.

model

alias of User

permission_classes = [<rest_framework.permissions.OperandHolder object>]
queryset = <QuerySet [<User: sahil>, <User: admin>]>
serializer_class

alias of ModelSerializer

class accounts.views.MyTokenObtainPairView(**kwargs)[source]

Bases: TokenObtainPairView

permission_classes = [<class 'rest_framework.permissions.AllowAny'>]
serializer_class

alias of MyTokenObtainPairSerializer

class accounts.views.MyTokenRefreshView(**kwargs)[source]

Bases: TokenRefreshView

permission_classes = [<class 'rest_framework.permissions.AllowAny'>]
class accounts.views.PasswordResetConfirmView(**kwargs)[source]

Bases: UpdateAPIView

get_object()[source]

Returns the object the view is displaying.

You may want to override this if you need to provide non-standard queryset lookups. Eg if objects are referenced using multiple keyword arguments in the url conf.

permission_classes = [<class 'rest_framework.permissions.AllowAny'>]
serializer_class

alias of PasswordResetConfirmSerializer

update(request, *args, **kwargs)[source]
class accounts.views.PasswordResetView(**kwargs)[source]

Bases: CreateAPIView

create(request, *args, **kwargs)[source]
permission_classes = [<class 'rest_framework.permissions.AllowAny'>]
serializer_class

alias of PasswordResetSerializer

class accounts.views.ProcurementOfficerRegisterView(**kwargs)[source]

Bases: CreateAPIView

perform_create(serializer)[source]
permission_classes = [<class 'rest_framework.permissions.AllowAny'>]
queryset = <QuerySet [<User: sahil>, <User: admin>]>
serializer_class

alias of ProcurementOfficerRegisterSerializer

class accounts.views.UpdateUserProfileView(**kwargs)[source]

Bases: UpdateAPIView

get_object()[source]

Returns the object the view is displaying.

You may want to override this if you need to provide non-standard queryset lookups. Eg if objects are referenced using multiple keyword arguments in the url conf.

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

alias of ProfileSerializer

update(request, *args, **kwargs)[source]
class accounts.views.UserProfileView(**kwargs)[source]

Bases: RetrieveAPIView

get_object()[source]

Returns the object the view is displaying.

You may want to override this if you need to provide non-standard queryset lookups. Eg if objects are referenced using multiple keyword arguments in the url conf.

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

alias of ProfileSerializer

class accounts.views.VendorRegisterView(**kwargs)[source]

Bases: CreateAPIView

perform_create(serializer)[source]
permission_classes = [<class 'rest_framework.permissions.AllowAny'>]
queryset = <QuerySet [<User: sahil>, <User: admin>]>
serializer_class

alias of VendorRegisterSerializer

class accounts.views.VendorView(**kwargs)[source]

Bases: ListAPIView

permission_classes = [<class 'rest_framework.permissions.IsAuthenticated'>, <rest_framework.permissions.OperandHolder object>]
queryset = <QuerySet []>
serializer_class

alias of VendorSerializer

accounts.views.getRoutes(request, *args, **kwargs)[source]

Module contents