Add & Remove
User App
Django web framework features a very useful user identification and permission infrastructure. In this context, it includes Users for user identification, Permissions for assigning users the permission to undertake certain jobs, and Groups for grouping the permission(s) to be assigned to multiple users.
In Omnitron, this infrastructure provided by Django has been inherited and expanded, and the “Users” application has been developed for all user operations: from creating users to defining roles and permissions for users. The application contains the models listed below.
UserProfile -> The model for defining users.
BEPermissionNamespace -> The namespace model for backend user permissions.
BEPermission -> The model for defining backend permissions.
FEPermissionGroup -> The model for defining the general permission groups of users.
FEPermission -> The model for defining frontend permissions.
CatalogGroup -> The model for defining the permission groups of users on the catalog(s).
ChannelGroup -> The model for defining the permission groups of users on the channel(s).
Storing user information, UserProfile is used by expanding on the User and AbstractUser classes of Django. The AbstractUser model inherits from the PermissionMixin and AbstractBaseUser models. PermissionMixin permits the defining of user-specific permissions with the user_permission field. In addition, the User’s current status can be defined by fields such as is_active, is_superuser, and is_staff. These are the features that Django offers as part of user management.
User Screens
User information can be accessed, new users can be added and the properties of existing users can be changed from Settings> Users on Omnitron V2.
In the general permission groups section, permission groups can be defined for existing users. Outside of general permission groups, the user access permission breakdown can also be increased with catalog permission groups (permissions for access to the catalogs application) and channel permission groups (permission for access to the channels application). ViewSet Users application includes UserViewSet, ActiveUserViewSet, BEPermissionViewSet, FEPermissionViewSet, FEPermissionGroupViewSet, BEPermissionNamespaceViewSet, GroupViewSet, CatalogGroupViewSet, and ChannelGroupViewSet. Below are the endpoints of these viewsets and sample request-response information for some of them.
UserViewSet
Endpoints
/api/v1/users/
{"/api/v1/users/{pk}/"}
GET
All Users
GET
All UsersPath: /api/v1/users/
Returns all objects in the User table paged.
Response
POST
Create a New User
POST
Create a New UserPath: /api/v1/users/
Records new objects in the User table. Uses the UserSerializer class defined at omnitron.users.resources.serializers for data verification.
Field
Type
Mandatory
Default
username
string
Yes
N/A
password
string*
Yes
N/A
string
Yes
N/A
groups
list(integer)
Yes
N/A
first_name
string
No
None
last_name
string
No
None
is_active
boolean
No
True
is_staff
boolean
No
False
is_superuser
boolean
No
False
Note: Password is required to have at least eight characters, including a capital letter, a number, and a special character.
Response
GET
User Detail
GET
User DetailPath: /api/v1/users/{pk}/
Returns the object specified with the primary key in the User table by serializing it with the UserSerializer class defined at omnitron.users.resources.serializers.
Response
PATCH
Update User
PATCH
Update UserPath: /api/v1/users/{pk}/
Updates the object of the relevant primary key in the User table. Updates the provided parameters.
Field
Type
Mandatory
Default
username
string
No
N/A
password
string*
No
N/A
string
No
N/A
groups
list(integer)
No
N/A
first_name
string
No
None
last_name
string
No
None
is_active
boolean
No
true
is_staff
boolean
No
false
is_superuser
boolean
No
false
Note: password is required to have at least eight characters, including a capital letter, a number, and a special character.
Response / 200 Serialized version of the object. Example response of the POST method can be observed.
Response / 400 When a request is made with an incorrect PK, the following response is returned. Here, the HTTP code in the response to the HTTP request will be 404.
PUT
Update User
PUT
Update UserPath: /api/v1/users/{pk}/
Updates the object of the relevant primary key in the User table. Updates all fields of the object. All required fields in the body of this method must be sent. The POST method can be examined for the fields that can be sent.
Response / 200 Serialized version of the object. Sample response of the POST method can be observed.
Response / 400 When a request is made with an incorrect PK, the following response is returned. Here, the HTTP code in the response to the HTTP request will be 404.
DELETE
User
DELETE
UserPath: /api/v1/users/{pk}/
Permits the removal of the object specified by the primary key from the User table.
Response
Response / 204 When a deletion request is completed.
Response / 400 When a request is made with an incorrect PK, the following response is returned. Here, the HTTP code in the response to the HTTP request will be 404.
Other Viewsets and Endpoints
ActiveUserViewSet
This ViewSet always uses the current user which is determined by the request as a resource.
Endpoints
/api/v1/active_user/
/api/v1/active_user/change_password/
GET
Active User
GET
Active UserPath: /api/v1/active_user/
Returns current user object as paged response.
Response
PUT
Update Active User
PUT
Update Active UserPath: /api/v1/active_user/
Updates current user in the User table. Uses the ActiveUserSerializer class defined at omnitron.users.resources.serializers for data verification.
Field
Type
Mandatory
Default
username
string
Yes
N/A
string
No
N/A
first_name
string
No
N/A
last_name
string
No
N/A
userprofile
{`Dict{ Avatar, Phone Number }`}
Yes
N/A
Response
PATCH
Partially Update Active User
PATCH
Partially Update Active UserPath: /api/v1/active_user/
Partially updates current user in the User table. Uses the ActiveUserSerializer class defined at omnitron.users.resources.serializers for data verification.
Field
Type
Mandatory
Default
username
string
No
N/A
string
No
N/A
first_name
string
No
N/A
last_name
string
No
N/A
userprofile
{`Dict{ Avatar, Phone Number }`}
No
N/A
Response
PUT
Change Active User’s Password
PUT
Change Active User’s PasswordPath: /api/v1/active_user/change_password/
Updates current user in the User table. Uses the ChangePasswordSerializer class defined at omnitron.users.resources.serializers for data verification.
The new password is required to have at least eight characters, including a capital letter, a number, and a special character. Also, it must be different from the last two passwords used. There will be a 400 Bad Request response if the given new password does not match the specified criteria.
Response
BEPermissionNamespaceViewSet
Endpoints
/api/v1/be_permission_namespace/
{`/api/v1/be_permission_namespace/{PK}/`}
{`/api/v1/be_permission_namespace/{PK}/assign-users/`}
{`/api/v1/be_permission_namespace/{PK}/remove-users/`}
GET
User Permission Scope
GET
User Permission ScopePath: /api/v1/be_permission_namespace/
Returns by serializing all records in the BEPermissionNamespace table with the BEPermissionNamespaceSerializer class defined at omnitron.users.resources.serializers.
Response
GET
Detailed User Permission Scope
GET
Detailed User Permission ScopePath: /api/v1/be_permission_namespace/{PK}
Returns by serializing requested records matching the given PK in the BEPermissionNamespace table with the BEPermissionNamespaceSerializer class defined at omnitron.users.resources.serializers.
Response
PATCH
Assign Users to a User Permission Scope
PATCH
Assign Users to a User Permission ScopePath: /api/v1/be_permission_namespace/{PK}/assign-users/
Assigns given users to the record matching the given PK in the BEPermissionNamespace table.
Response
PATCH
Remove Users from a User Permission Scope
PATCH
Remove Users from a User Permission ScopePath: /api/v1/be_permission_namespace/{PK}/remove-users/
Removes given users from the record matching the given PK in the BEPermissionNamespace table.
Response
BEPermissionViewSet
Endpoints
/api/v1/be_permissions/
{`/api/v1/be_permissions/{PK}/`}
{`/api/v1/be_permissions/{PK}/assign-users/`}
{`/api/v1/be_permissions/{PK}/remove-users/`}
GET
User Permissions
GET
User PermissionsPath: /api/v1/be_permissions/
Returns by serializing all records in the BEPermissions table with the BEPermissionSerializer class defined at omnitron.users.resources.serializers.
Response
GET
Detailed User Permission
GET
Detailed User PermissionPath: /api/v1/be_permissions/{PK}/
Returns by serializing requested records matching the given PK in the BEPermission table with the BEPermissionSerializer class defined at omnitron.users.resources.serializers.
Response
PATCH
Assign Users to a User Permission
PATCH
Assign Users to a User PermissionPath: /api/v1/be_permission/{PK}/assign-users/
Assigns given users to the record matching the given PK in the BEPermission table.
Response
PATCH
Remove Users from a User Permission
PATCH
Remove Users from a User PermissionPath: /api/v1/be_permission/{PK}/remove-users/
Removes given users from the record matching the given PK in the BEPermission table.
Response
GroupViewSet
Endpoints
/api/v1/groups/
{`/api/v1/groups/{PK}/`}
GET
User Permission Groups
GET
User Permission GroupsPath: /api/v1/groups/
Retrieves records from the Group table in the django.contrib.auth.models module that comes with Django. User permission groups are saved in this table. The Group table is defined as Foreign Key in the CatalogGroup and ChannelGroup tables on Omnitron.
Response
POST
Create a New Permission Group
POST
Create a New Permission GroupPath: /api/v1/groups/
Adds a record to the Group table in the django.contrib.auth.models module included with Django.
Response
PATCH
-PUT
Update a Permission Group
PATCH
-PUT
Update a Permission GroupPath: /api/v1/groups/{PK}/
Updates the record that matches the given PK value in the Group table in the django.contrib.auth.models module included with Django.
Response
DELETE
Delete a Permission Group
DELETE
Delete a Permission GroupPath: /api/v1/groups/{PK}/
Deletes the record that matches the given PK value in the Group table in the django.contrib.auth.models module included with Django.
Response
Response / 204 When a deletion request is completed.
CatalogGroupViewSet
Endpoints
/api/v1/catalog_groups/
{`/api/v1/catalog_groups/{PK}/`}
GET
Catalog Groups
GET
Catalog GroupsPath: /api/v1/catalog_groups/
Returns the details of all records in the CatalogGroup table via serializing with the CatalogGroupSerializer class defined at omnitron.users.resources.serializers.
Successful Response Example
POST
Add Group to a Catalog
POST
Add Group to a CatalogPath: /api/v1/catalog_groups/
Allows adding new records to the CatalogGroup table. Returns by serializing with the CatalogGroupSerializer class defined at omnitron.users.resources.serializers.
Response
DELETE
Delete a Catalog Group
DELETE
Delete a Catalog GroupPath: /api/v1/catalog_groups/
Deletes the record that matches the given PK value in the CatalogGroup table.
Response
Response / 204 When a deletion request is completed.
ChannelGroupViewSet
Endpoints
/api/v1/channel_groups/
{`/api/v1/channel_groups/{PK}/`}
GET
Channel Groups
GET
Channel GroupsPath: /api/v1/channel_groups/
Returns the details of all records in the ChannelGroup table via serializing with the ChannelGroupSerializer class defined at omnitron.users.resources.serializers.
Response
POST
Add Group to a Channel
POST
Add Group to a ChannelPath: /api/v1/channel_groups/
Allows adding new records to the ChannelGroup table. Returns by serializing with the ChannelGroupSerializer class defined at omnitron.users.resources.serializers.
Response
DELETE
Delete a Catalog Group
DELETE
Delete a Catalog GroupPath: /api/v1/channel_groups/
Deletes the record that matches the given PK value in the ChannelGroup table.
Response
Response / 204 When a deletion request is completed.
FEPermissionGroupViewSet
Endpoints
/api/v1/fe_permission_groups/
{`/api/v1/fe_permission_groups/{PK}/`}
{`/api/v1/fe_permission_groups/{PK}/assign-permissions/`}
{`/api/v1/fe_permission_groups/{PK}/assign-users/`}
{`/api/v1/fe_permission_groups/{PK}/remove-permissions/`}
{`/api/v1/fe_permission_groups/{PK}/remove-users/`}
POST
Create a Permission Group for Omnitron Frontend
POST
Create a Permission Group for Omnitron FrontendPath: /api/v1/fe_permission_groups/
Adds records to the FEPermissionGroup table by serializing with the FEPermissionGroupSerializer class defined at omnitron.users.resources.serializers.
Response
GET
Retrieve Omnitron Frontend Permission Groups
GET
Retrieve Omnitron Frontend Permission GroupsPath: /api/v1/fe_permission_groups/
Returns the details of all records in the FEPermissionGroup table via serializing with the FEPermissionGroupSerializer class defined at omnitron.users.resources.serializers.
Response
GET
Omnitron Frontend Permission Group
GET
Omnitron Frontend Permission GroupPath: /api/v1/fe_permission_groups/{PK}
Returns the details of the record that matches the given PK in the FEPermissionGroup table via serializing with the FEPermissionGroupSerializer class defined at omnitron.users.resources.serializers.
Response
PATCH
Add a New User to Omnitron Frontend Permission Group
PATCH
Add a New User to Omnitron Frontend Permission GroupPath: /api/v1/fe_permission_groups/{PK}/assign-users/
Permits the addition of users to a record in the FEPermissionGroup table.
Response
PATCH
Remove Users from an Omnitron Frontend Permission Group
PATCH
Remove Users from an Omnitron Frontend Permission GroupPath: /api/v1/fe_permission_groups/{PK}/remove-users/
Permits the removal of users to a record in the FEPermissionGroup table.
Response
Following the remove-users request, the relevant record is observed as follows.
PATCH
Add an Omnitron Frontend Permission to Omnitron Frontend Permission Group
PATCH
Add an Omnitron Frontend Permission to Omnitron Frontend Permission GroupPath: /api/v1/fe_permission_groups/{PK}/assign-permissions/
Permits the addition of an Omnitron Frontend Permission to a record in the FEPermissionGroup table.
Response
PATCH
Remove an Omnitron Frontend Permission from an Omnitron Frontend Permission Group
PATCH
Remove an Omnitron Frontend Permission from an Omnitron Frontend Permission GroupPath: /api/v1/fe_permission_groups/{PK}/remove-permissions/
Permits the removal of users from a record in the FEPermissionGroup table.
Response
FEPermissionViewSet
Endpoints
/api/v1/fe_permissions/
{`/api/v1/fe_permissions/{PK}/`}
{`/api/v1/fe_permissions/{PK}/assign-groups/`}
{`/api/v1/fe_permissions/{PK}/assign-users/`}
{`/api/v1/fe_permissions/{PK}/remove-groups/`}
{`/api/v1/fe_permissions/{PK}/remove-users/`}
/api/v1/fe_permissions/detailed_list/
GET
Omnitron Frontend Permissions
GET
Omnitron Frontend PermissionsPath: /api/v1/fe_permissions/
Returns by serializing all records in the FEPermissions table with the FEPermissionSerializer class defined at omnitron.users.resources.serializers.
Response
GET
Omnitron Frontend Permission
GET
Omnitron Frontend PermissionPath: /api/v1/fe_permissions/{PK}/
Returns by serializing requested records matching the given PK in the FEPermission table with the FEPermissionSerializer class defined at omnitron.users.resources.serializers.
Response
PATCH
Assign Users to an Omnitron Frontend Permission
PATCH
Assign Users to an Omnitron Frontend PermissionPath: /api/v1/fe_permission/{PK}/assign-users/
Assigns given users to the record matching the given PK in the FEPermission table.
Response
PATCH
Remove Users from a User Permission
PATCH
Remove Users from a User PermissionPath: /api/v1/fe_permission/{PK}/remove-users/
Removes given users from the record matching the given PK in the FEPermission table.
Response
PATCH
Assign Omnitron Frontend Permission Groups to an Omnitron Frontend Permission
PATCH
Assign Omnitron Frontend Permission Groups to an Omnitron Frontend PermissionPath: /api/v1/fe_permission/{PK}/assign-groups/
Assigns given FEPermissionGroups to the record matching the given PK in the FEPermission table.
Response
PATCH
Remove Users from a User Permission
PATCH
Remove Users from a User PermissionPath: /api/v1/fe_permission/{PK}/remove-groups/
Removes given FEPermissionGroups from the record matching the given PK in the FEPermission table.
Response
Last updated
Was this helpful?