Built-in Profile Models (django_suap_auth.profile)¶
The django_suap_auth.profile submodule provides pre-built Django models to store SUAP profile data out of the box, eliminating the need to manually map fields in your projects.
Models Overview¶
The submodule defines 3 main models:
Perfil: 1-to-1 model linked to the DjangoUsermodel (viauser.suap_profile). Stores personal, academic, and functional data.DadosBrutos: 1-to-1 model linked toUser(viauser.suap_raw_data). Stores the complete JSON response returned by SUAP APIs in aJSONField.Vinculo: 1-to-Many model linked toUser(viauser.suap_vinculos). Stores the list of user affiliations with the institution (e.g. staff, student, intern).
Installation and Setup¶
Add
django_suap_auth.profileto yourINSTALLED_APPSinsettings.py:
INSTALLED_APPS = [
# ...
"django_suap_auth",
"django_suap_auth.profile",
]
Enable the authentication backend with automatic profile synchronization in
settings.py:
AUTHENTICATION_BACKENDS = [
"django_suap_auth.profile.backends.SuapProfileAuthBackend",
"django.contrib.auth.backends.ModelBackend",
]
Run database migrations:
python manage.py migrate
Attributes of Perfil Model by User Type¶
The Perfil model gathers all attributes supported by SUAP APIs into a single table:
1. Common Attributes (Present in All Users)¶
These attributes are shared by Staff/Employees, Students, and External Users:
Field |
Type |
Description |
|---|---|---|
|
IntegerField |
SUAP internal user ID. |
|
CharField |
Functional or academic registration number. |
|
CharField |
Display/usual name in SUAP. |
|
CharField |
Registered social name. |
|
CharField |
Formatted or numeric CPF. |
|
CharField |
ID card number (RG) with issuing body. |
|
JSONField |
List of parent/guardian names. |
|
DateField |
Date of birth. |
|
CharField |
Birth city and state. |
|
CharField |
Blood type (e.g. A+, O-). |
|
CharField |
Sex (“M” or “F”). |
|
CharField |
Passport number (when applicable). |
|
CharField |
Campus code or name. |
|
EmailField |
Personal/secondary email. |
|
EmailField |
Institutional Google Workspace email account. |
|
EmailField |
Institutional email. |
|
EmailField |
Preferred contact email. |
|
URLField |
Profile picture URL (thumbnail). |
|
URLField |
Profile picture URL (medium). |
|
CharField |
User type (e.g. Staff, Student, External User). |
|
CharField |
Primary affiliation (e.g. Teacher, Administrative Staff). |
|
JSONField |
List of contact phone numbers. |
|
CharField |
Lattes CV URL or ID. |
|
JSONField |
Dictionary with user interface and accessibility preferences. |
|
DateTimeField |
Timestamp of first login via SUAP. |
2. Staff-Specific Attributes¶
Filled exclusively when the user is Staff/Employee (Teacher or Administrative):
Field |
Type |
Description |
|---|---|---|
|
CharField |
Functional category (e.g. “Docente”, “Técnico-Administrativo”). |
|
CharField |
Job title (e.g. “Professor EBTT”, “IT Analyst”). |
|
CharField |
SUAP department acronym. |
|
CharField |
SIAPE department code or description. |
|
CharField |
Work schedule regime (e.g. “40 hours”, “Exclusive Dedication”). |
|
CharField |
Entry contest subject/area. |
3. Student-Specific Attributes¶
Filled exclusively when the user is a Student:
Field |
Type |
Description |
|---|---|---|
|
CharField |
Enrolled course name. |
|
CharField |
Student course shift (e.g. “Distance Learning”, “Morning”). |
|
CharField |
Curriculum matrix code/name. |
|
CharField |
Enrollment status (e.g. “Incomplete”, “Enrolled”, “Graduated”). |
|
CharField |
General systemic status in SUAP. |
|
CharField |
Academic Performance Index (IRA). |
|
CharField |
Entry term/period (e.g. “2021.1”). |
|
IntegerField |
Current academic term. |
|
IntegerField |
Total number of course terms. |
|
CharField |
Student record migration date. |
|
BooleanField |
Indicates if fingerprint is registered. |
|
BooleanField |
Indicates if diploma was issued. |
|
BooleanField |
Indicates if student enrollment is regular. |
|
CharField |
Student code in Educacenso / INEP. |
|
CharField |
Sistec quota code. |
|
CharField |
MEC quota code. |
|
CharField |
Student research area (graduate / research). |
4. External Users / Contractors¶
For External Users or third-party contractors:
- Staff and Student attributes remain empty/null.
- tipo_usuario records "Usuário Externo" or "Prestador de Serviço".
- Basic identification, photos, emails, and CPF are synchronized in common attributes.
Automatic Synchronization¶
When using SuapProfileAuthBackend, on every login (or user creation) the following actions run automatically:
A
Perfilinstance is created/updated for the user.The complete JSON response from the SUAP API is saved in
DadosBrutos(accessible viauser.suap_raw_data.data).The affiliation list in
Vinculois synchronized (accessible viauser.suap_vinculos.all()).first_loginis populated with current datetime on first login.
Computed Properties and Accessibility¶
The Perfil model exposes several computed properties:
show_name: Preferred display name (hierarchy:nome_usual>nome_social>nome_registro>user.username).campus_sigla: Campus acronym (e.g."CNAT") or empty string.foto_url: Profile picture URL (prioritizes 150x200 over 75x100).theme_selected: Theme selected insettings(default:"ifrn25").menu_position: Menu position defined insettings(default:"bottom").color_mode: Accessibility color mode (default:"default").zoom_level: Accessibility zoom level as integer (default:100).Accessibility properties (booleans from
settings):dyslexia_friendly,remove_justify,highlight_links,stop_animations,hidden_illustrative_image,big_cursor,vlibras_active(default True),high_line_height.