Skip to content

Users App

Models

InstitutionProfile

InstitutionProfile(id, user, name, description, website, accreditation_proof, is_trusted, created_at)

Fields

  • id (BigAutoField) - blank allowed
  • user (OneToOneField)
  • name (CharField)
  • description (TextField) - nullable - blank allowed
  • website (URLField) - nullable - blank allowed
  • accreditation_proof (FileField) - nullable - blank allowed
  • is_trusted (BooleanField)
  • created_at (DateTimeField)

Methods

  • adelete(self, using=None, keep_parents=False)
  • arefresh_from_db(self, using=None, fields=None, from_queryset=None)
  • asave(self, *args, force_insert=False, force_update=False, using=None, update_fields=None)
  • clean(self)

Hook for doing any extra model-wide validation after clean() has been called on every field by self.clean_fields. Any ValidationError raised by this method will not be associated with a particular field; it will have a special-case association with the field defined by NON_FIELD_ERRORS.

  • clean_fields(self, exclude=None)

Clean all fields and raise a ValidationError containing a dict of all validation errors if any occur.

  • date_error_message(self, lookup_type, field_name, unique_for)
  • delete(self, using=None, keep_parents=False)
  • full_clean(self, exclude=None, validate_unique=True, validate_constraints=True)

Call clean_fields(), clean(), validate_unique(), and validate_constraints() on the model. Raise a ValidationError for any errors that occur.

  • get_constraints(self)
  • get_deferred_fields(self)

Return a set containing names of deferred fields for this instance.

  • get_next_by_created_at(self, , field=, is_next=True, *kwargs)
  • get_previous_by_created_at(self, , field=, is_next=False, *kwargs)
  • prepare_database_save(self, field)
  • refresh_from_db(self, using=None, fields=None, from_queryset=None)

Reload field values from the database.

By default, the reloading happens from the database this instance was loaded from, or by the read router if this instance wasn't loaded from any database. The using parameter will override the default.

Fields can be used to specify which fields to reload. The fields should be an iterable of field attnames. If fields is None, then all non-deferred fields are reloaded.

When accessing deferred fields of an instance, the deferred loading of the field will call this method.

  • save(self, *args, force_insert=False, force_update=False, using=None, update_fields=None)

Save the current instance. Override this in a subclass if you want to control the saving process.

The 'force_insert' and 'force_update' parameters can be used to insist that the "save" must be an SQL insert or update (or equivalent for non-SQL backends), respectively. Normally, they should not be set.

  • save_base(self, raw=False, force_insert=False, force_update=False, using=None, update_fields=None)

Handle the parts of saving which should be done only once per save, yet need to be done in raw saves, too. This includes some sanity checks and signal sending.

The 'raw' argument is telling save_base not to save any parent models and not to do any changes to the values before save. This is used by fixture loading.

  • serializable_value(self, field_name)

Return the value of the field name for this instance. If the field is a foreign key, return the id value instead of the object. If there's no Field object with this name on the model, return the model attribute's value.

Used to serialize a field's value (in the serializer, or form output, for example). Normally, you would just access the attribute directly and not use this method.

  • unique_error_message(self, model_class, unique_check)
  • validate_constraints(self, exclude=None)
  • validate_unique(self, exclude=None)

Check unique constraints on the model and raise ValidationError if any failed.


User

User(password, last_login, is_superuser, username, first_name, last_name, email, is_staff, is_active, date_joined, id, user_type, did, public_key, created_at, updated_at)

Fields

  • password (CharField)
  • last_login (DateTimeField) - nullable - blank allowed
  • is_superuser (BooleanField) - Designates that this user has all permissions without explicitly assigning them.
  • username (CharField) - Required. 150 characters or fewer. Letters, digits and @/./±/_ only.
  • first_name (CharField) - blank allowed
  • last_name (CharField) - blank allowed
  • email (EmailField) - blank allowed
  • is_staff (BooleanField) - Designates whether the user can log into this admin site.
  • is_active (BooleanField) - Designates whether this user should be treated as active. Unselect this instead of deleting accounts.
  • date_joined (DateTimeField)
  • id (UUIDField)
  • user_type (CharField)
  • did (CharField) - nullable - blank allowed
  • public_key (TextField) - nullable - blank allowed
  • created_at (DateTimeField)
  • updated_at (DateTimeField) - blank allowed

Methods

  • acheck_password(self, raw_password) See check_password().
  • adelete(self, using=None, keep_parents=False)
  • aget_all_permissions(self, obj=None)
  • aget_group_permissions(self, obj=None) See get_group_permissions()
  • aget_user_permissions(self, obj=None) See get_user_permissions()
  • ahas_module_perms(self, app_label) See has_module_perms()
  • ahas_perm(self, perm, obj=None) See has_perm()
  • ahas_perms(self, perm_list, obj=None) See has_perms()
  • arefresh_from_db(self, using=None, fields=None, from_queryset=None)
  • asave(self, *args, force_insert=False, force_update=False, using=None, update_fields=None)
  • check_password(self, raw_password)

Return a boolean of whether the raw_password was correct. Handles hashing formats behind the scenes.

  • clean(self)
  • clean_fields(self, exclude=None)

Clean all fields and raise a ValidationError containing a dict of all validation errors if any occur.

  • date_error_message(self, lookup_type, field_name, unique_for)
  • delete(self, using=None, keep_parents=False)
  • email_user(self, subject, message, from_email=None, **kwargs) Send an email to this user.
  • full_clean(self, exclude=None, validate_unique=True, validate_constraints=True)

Call clean_fields(), clean(), validate_unique(), and validate_constraints() on the model. Raise a ValidationError for any errors that occur.

  • get_absolute_url(self)
  • get_all_permissions(self, obj=None)
  • get_constraints(self)
  • get_deferred_fields(self)

Return a set containing names of deferred fields for this instance.

  • get_did(self) Get the DID for the user
  • get_full_name(self)

Return the first_name plus the last_name, with a space in between.

  • get_group_permissions(self, obj=None)

Return a list of permission strings that this user has through their groups. Query all available auth backends. If an object is passed in, return only permissions matching this object.

  • get_next_by_created_at(self, , field=, is_next=True, *kwargs)
  • get_next_by_date_joined(self, , field=, is_next=True, *kwargs)
  • get_next_by_updated_at(self, , field=, is_next=True, *kwargs)
  • get_previous_by_created_at(self, , field=, is_next=False, *kwargs)
  • get_previous_by_date_joined(self, , field=, is_next=False, *kwargs)
  • get_previous_by_updated_at(self, , field=, is_next=False, *kwargs)
  • get_session_auth_fallback_hash(self)
  • get_session_auth_hash(self)

Return an HMAC of the password field.

  • get_short_name(self) Return the short name for the user.
  • get_trust_status(self)
  • get_user_permissions(self, obj=None)

Return a list of permission strings that this user has directly. Query all available auth backends. If an object is passed in, return only permissions matching this object.

  • get_user_type_display(self, *, field=)
  • get_username(self) Return the username for this User.
  • has_module_perms(self, app_label)

Return True if the user has any permissions in the given app label. Use similar logic as has_perm(), above.

  • has_perm(self, perm, obj=None)

Return True if the user has the specified permission. Query all available auth backends, but return immediately if any backend returns True. Thus, a user who has permission from a single auth backend is assumed to have permission in general. If an object is provided, check permissions for that object.

  • has_perms(self, perm_list, obj=None)

Return True if the user has each of the specified permissions. If object is passed, check if the user has all required perms for it.

  • has_usable_password(self)

Return False if set_unusable_password() has been called for this user.

  • is_holder(self)
  • is_issuer(self)
  • is_verifier(self)
  • natural_key(self)
  • prepare_database_save(self, field)
  • refresh_from_db(self, using=None, fields=None, from_queryset=None)

Reload field values from the database.

By default, the reloading happens from the database this instance was loaded from, or by the read router if this instance wasn't loaded from any database. The using parameter will override the default.

Fields can be used to specify which fields to reload. The fields should be an iterable of field attnames. If fields is None, then all non-deferred fields are reloaded.

When accessing deferred fields of an instance, the deferred loading of the field will call this method.

  • save(self, args, *kwargs)
  • save_base(self, raw=False, force_insert=False, force_update=False, using=None, update_fields=None)

Handle the parts of saving which should be done only once per save, yet need to be done in raw saves, too. This includes some sanity checks and signal sending.

The 'raw' argument is telling save_base not to save any parent models and not to do any changes to the values before save. This is used by fixture loading.

  • serializable_value(self, field_name)

Return the value of the field name for this instance. If the field is a foreign key, return the id value instead of the object. If there's no Field object with this name on the model, return the model attribute's value.

Used to serialize a field's value (in the serializer, or form output, for example). Normally, you would just access the attribute directly and not use this method.

  • set_password(self, raw_password)
  • set_unusable_password(self)
  • unique_error_message(self, model_class, unique_check)
  • validate_constraints(self, exclude=None)
  • validate_unique(self, exclude=None)

Check unique constraints on the model and raise ValidationError if any failed.


Views

about_view


admin_dashboard_view

Admin dashboard for superusers to manage institutions and system overview


approve_institution_view

Approve an institution


change_password_view


contact_view


Cookie Policy page


csrf_protect

This decorator adds CSRF protection in exactly the same way as CsrfViewMiddleware, but it can be used on a per view basis. Using both, or using the decorator multiple times, is harmless and efficient.


dashboard_view


delete_account_view


edit_profile_view


Use this decorator to ensure that a view sets a CSRF cookie, whether or not it uses the csrf_token template tag, or the CsrfViewMiddleware is used.


execute_task_with_fallback

Execute a task with fallback mechanism.

First tries to execute via Celery (.delay()), if that fails, falls back to direct execution.

Args: task_func: The Celery task function args: Arguments to pass to the task *kwargs: Keyword arguments to pass to the task

Returns: dict: Result information with keys: - success: bool - method: 'celery' or 'direct' - result: The actual result or error message - task_id: Celery task ID (if using Celery)


generate_key_pair

Generate SECP256k1 key pair in hex format


get_object_or_404

Use get() to return an object, or raise an Http404 exception if the object does not exist.

klass may be a Model, Manager, or QuerySet object. All other passed arguments and keyword arguments are used in the get() query.

Like with QuerySet.get(), MultipleObjectsReturned is raised if more than one object is found.


get_task_status_message

Get a user-friendly message from a task execution result.

Args: result_dict: Result dictionary from execute_task_with_fallback

Returns: str: User-friendly status message


home


institution_settings_view


is_superuser

Check if user is a superuser


login

Persist a user id and a backend in the request. This way a user doesn't have to reauthenticate on every request. Note that data set during the anonymous session is retained when the user logs in.


login_required

Decorator for views that checks that the user is logged in, redirecting to the log-in page if necessary.


login_view


logout

Remove the authenticated user's ID from the request and flush their session data.


logout_view


privacy_policy_view

Privacy Policy page


profile_view


redirect

Return an HttpResponseRedirect to the appropriate URL for the arguments passed.

The arguments could be:

* A model: the model's `get_absolute_url()` function will be called.

* A view name, possibly with arguments: `urls.reverse()` will be used
  to reverse-resolve the name.

* A URL, which will be used as-is for the redirect location.

Issues a temporary redirect by default. Set permanent=True to issue a permanent redirect. Set preserve_request=True to instruct the user agent to preserve the original HTTP method and body when following the redirect.


register_view


reject_institution_view

Reject an institution


render

Return an HttpResponse whose content is filled with the result of calling django.template.loader.render_to_string() with the passed arguments.


reverse


revoke_institution_approval_view

Revoke approval from an institution


terms_of_service_view

Terms of Service page


user_passes_test

Decorator for views that checks that the user passes the given test, redirecting to the log-in page if necessary. The test should be a callable that takes the user object and returns True if the user passes.


Forms

AuthenticationForm

Base class for authenticating users. Extend this to get a form that accepts username/password logins.


ChangePasswordForm


ContactForm


CustomAuthenticationForm


DeleteAccountForm