common & Shared Services¶
Author: Zhenyu Yang yangzhenyu@sust.edu.cn
Last updated: Apr 24, 2026
Corresponding API docs: Common Utilities API
common / services Code Entry¶
backend/common/models.pybackend/common/views.pybackend/common/pagination.pybackend/common/middleware/request_timezone.pybackend/services/
System Configuration¶
SystemConfig¶
This is a singleton table, currently storing:
seasonsemester_start_dateupdated_at
Associated endpoints:
GET /api/v1/configPOST /api/v1/config/season
Season switching is only allowed when the current active role is superadmin.
Uploads¶
Entry:
common.views.upload_fileThe current implementation writes files directly to
LOCAL_UPLOAD_DIR.The returned URL is assembled using
LOCAL_UPLOAD_URL_PREFIX.
Caveat:
services/file_storage.pyalready implements a local/S3 dual-backend abstraction.However, the upload endpoint has not yet been integrated with this abstraction; the actual runtime still writes directly to the local filesystem.
Pagination¶
Default pagination class:
common.pagination.DefaultPaginationSupported query parameters:
page_sizesize
Maximum page size is 200.
Middleware¶
RequestTimezoneMiddleware¶
Reads the
X-Timezoneheader.Dynamically activates the request timezone.
Other Cross-Module Middleware¶
Although the code does not reside in common/, these middleware are closely related to shared capabilities:
apps.logs.utils.OperationLogContextMiddlewareapps.accounts.middleware.CurrentRoleMiddleware
services/ Directory¶
This directory currently holds stateless or cross-app reusable services:
wechat.pytotp.pywebauthn.pysm2_crypto.pyfile_storage.py
These services are mostly used indirectly by accounts and common.