Skip to main content

Usuario

Usuario extends Django’s AbstractUser and is the single user model for the entire SIGEP platform (AUTH_USER_MODEL = "principal.Usuario"). Every other model that references a user points to this model. Authentication uses email as the unique identifier. The separate nombres, apellido_paterno, and apellido_materno fields replace reliance on AbstractUser’s first_name and last_name; those two fields are kept in sync automatically on every save() call so that get_full_name() and third-party integrations continue to work.

Fields

username
string
required
Inherited from AbstractUser. Used as the login identifier alongside email.
email
string
required
Unique email address. Used for authentication and account recovery. Stored as EmailField(unique=True).
nombres
string
Given name(s). Max 120 characters. Defaults to an empty string.
apellido_paterno
string
Paternal surname. Max 80 characters. Defaults to an empty string.
apellido_materno
string
Maternal surname. Max 80 characters. Defaults to an empty string.
telefono
string
Optional phone number. Max 20 characters. Nullable.
foto
file
Optional profile photo. Stored under perfiles/. Accepts image files via ImageField.
rol
string
required
Operational role that controls module routing and permission gates. Indexed. Defaults to PART. See the Rol choices table below.
actualizado_en
datetime
Timestamp updated automatically on every save (auto_now=True).

Rol choices

ValueDisplay labelDescription
ADMINAdministradorFull platform administration access
COORCoordinadorEvent coordination and schedule management
EVALEvaluador/JuradoRubric-based project evaluation
PONPonenteSpeaker submission and document upload
PARTParticipanteProject registration and certificate retrieval

Methods and properties

get_full_name()
string
Returns nombres apellido_paterno apellido_materno, trimmed. Falls back to the inherited AbstractUser.get_full_name() and then to username if all name fields are blank.
nombre_completo
string
Property. Delegates to get_full_name().
Every time you save a Usuario instance, first_name is set to nombres and last_name is set to apellido_paterno apellido_materno. Do not write to first_name or last_name directly — your changes will be overwritten.

SolicitudRecuperacionCuenta

Tracks password-recovery requests. Each request generates a UUID token that is emailed to the user. The token expires at the time stored in expira_en and can only be used once.

Fields

id
UUID
required
Primary key. Auto-generated UUID (uuid4), not editable.
usuario
ForeignKey → Usuario
required
The user who initiated the recovery request. Cascades on user deletion.
token
UUID
required
Unique, auto-generated UUID used in the recovery link. Not editable. Indexed.
creado_en
datetime
required
Timestamp of request creation. Indexed. Defaults to timezone.now.
usado_en
datetime
Timestamp of when the token was consumed. Nullable — null means unused.
activo
boolean
required
Whether the token is still valid. Defaults to True. Set to False by invalidar().
ip_origen
string
IP address from which the recovery was requested. Nullable.
user_agent
string
Browser or client identifier from the request. Max 255 characters. Nullable.
expira_en
datetime
required
Absolute expiry timestamp. Required. Set by the view that creates the request.

Methods

esta_expirada()
boolean
Returns True if timezone.now() >= expira_en. Use this to reject stale tokens without querying the database again.
invalidar()
None
Sets activo = False and stamps usado_en with the current time if it is not already set. Saves only the two changed fields via update_fields.
Always call invalidar() after a successful password reset so the token cannot be replayed. Combine it with esta_expirada() to enforce both expiry and single-use semantics.

Build docs developers (and LLMs) love