Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
""" All models in the app inherits from this one.
As of now, this model doesn't have any special fields. It is basically here to have a coherent naming convention. In fact some high level behaviors have been implemented in the corresponding Serializer and viewset. """
# Look at the documentation about config files to know more about this # https://rex-dri.gitlab.utc.fr/rex-dri/documentation/#/Application/Backend/moderation_and_versioning?id=model-level # http://localhost:5000/#/Application/Backend/moderation_and_versioning?id=model-level
""" Serializer to go along the BaseModel model. This serializer make sure some relevant data is always returned. """
# For easier handling on the client side, we force an id field # this is useful when a model has a dedicated primary key
def get_user_related_field(cls, user): """ Generic function to make sure we return only the pseudo and the id". :param user: user associated with object :return: dict """ # In testing env or if data is not perfectly initialised else: "{} {}".format(user.first_name, user.last_name) if user.allow_sharing_personal_info else user.pseudo )
""" Serializer for the `obj_info` *dynamic* field. `obj` is required in the function definition, but it's not used.
For all object return by the backend api, we add a custom `obj_info` field. The default value are chown below.
This methods is overrided in EssentialModuleSerializer for a smarter behavior. """
""" Serializer for the id field. """
""" Function to retrieve the user from the request """
""" Custom default viewset """
DEFAULT_VIEWSET_PERMISSIONS & ReadOnly, ) # ReadOnly or Override
# We store the api endpoint route directly in the viewset classes # so that we can easily access them
""" We override the permission getter to make sure we add the default app viewsets permissions """
# Attribute that lists the fields that are expected to be preset in request.GET
""" Overrides the default list to enable required filterset_fields """ if field_name not in request.GET.keys(): return Response( "Missing get parameter `{}`".format(field_name), status=422 ) |