Backend Task: Write a system that stores and validates the following components:
- Document
- Protein
- Comment
- Notification
the 3 first entities require the user who wrote them and the date they were created and the date they were last changed.
the notification simply requires the date it was created, and a text message field. in addition to the fields above, the protein will store the Amino Acid sequence, and its corresponding DNA sequence, both of these fields can be very long strings, up to 10 thousand characters.
also, the DNA field is always 3 times the length of the AA field, and both fields are required.
the document simply contains the content which is a text field, but we must filter out HTML elements from its content to avoid XSS attacks!!, there should be a simple function for this which we need to find.
the comment also contains the content text and should be protected from XSS attacks, and MOST importantly the comment should save which entity it belongs to, which is now a protein or a Document, but we may add more in the future.
the notification also points to an entity (comment, protein, document) and contains the notification type which can be one of "Link, static, or system" (they can be changed in the code in the future).
link notifications contain a link, and all notifications contain a message and a font- awesome icon field (a basic string field).
the requirement is to simply write classes for these entities, and we want validation over them to happen automatically when we simply call Django’s full_clean() function over objects of these models.
Please pay close attention to making the code for these models as concise as possible, try not to repeat fields, and to name variables with clear names, and comment only complex code segments or unclear model fields.
try to create 1 or 2 dummy data objects from these models just to test your syntax and validation.
The only requirement for this code is these classes, their autogenerated migrations, and a main function that instantiates objects from them and simulates different input configuration to show how correct the code is.