from .model import model from .proxy import proxy from .field_generator import field_generator from .constants import constants from .validators import validators class attachment(model): """ That model store attachment to the item. Attachment is file, which could be downloaded by the user, like instruction in PDF, or used in frontend like images. Fields ------ name : str Name of the attachment visible for user. description : str Description of the attachment visible for user. """ name = field_generator.name() description = field_generator.description() def _validators(self) -> dict: """ That function return dict of validators which would be used to validate text fields of the model. Returns ------- dict Validators which would be used to validate text fields. """ return { "name": validators.name, "description": validators.description } class attachment_proxy(proxy): """ That class is proxy for the attachment. It could be used to working witch attachments in cleaner and better way. Methods ------- @classmethod create : proxy That create new attachment from that name. """ @classmethod def create(cls, name: str) -> proxy: return cls(attachment( name = name, description = constants.empty_text() )) def set_name(self, target: str) -> None: self._target.name = target def set_description(self, target: str) -> None: self._target.description = target