- Built using Mongoengine for MongoDB
- Supports Python 3.x
To use this Models, it is necessary to have an instance of MongoDB running.
- Python 3.x
- MongoDB
This ORM can be used as a library in other Python projects. The models are located in the my_orm/models folder, and can be imported like any other Python module. To install this orm as a library you need to execute the following command:
pip install git+https://github.com/CIAT-DAPA/melisa_ormIf you want to download a specific version of orm you can do so by indicating the version tag (@v0.0.0) at the end of the install command
pip install git+https://github.com/CIAT-DAPA/melisa_orm@v0.2.0python -m unittest discover -s ./src/tests/ -p 'test_*.py'Represents a Action in the database.
Attributes:
- form:
ObjectIdReference to Form. - name:
strname of the action. - call_url:
strcall url. - request:
enumrestrict the values of the request field. - track:
classclass that handles traceability.
name = StringField(required=True) call_url = StringField(required=True) request = EnumField(ActionRequestEnum, required=True) track = EmbeddedDocumentField(Track, required=True)
Represents a chat entry in the database.
Attributes:
- thread:
ReferenceFieldReference to Thread. Required. - date:
datetimeDate of the received message. Required. - original:
strOriginal text received from the message. Required. - text:
strCleaned text received from the message. Required. - slots:
dictDictionary for storing slots. - tags:
dictDictionary for storing tags. - ext_id:
strExternal ID with a maximum length of 200 characters. - status:
enumRepresents the status of the chat. Required. ChatStatusEnum - whom:
enumRepresents who wrote the message. Required. ChatWhomEnum - values:
listList for storing values. - kind_msg:
enumRepresents the type of message. Required. ChatKindEnum
Methods:
save(): Saves the Chat object to the database.delete(): Deletes the Chat object from the database.
Enums:
Represents the status of the chat.
- OK: 'ok'
- ERROR: 'error'
Represents who wrote the message.
- USER: 'user'
- SYSTEM: 'system'
Represents the type of entry.
- TEXT: 'text'
- IMAGE: 'img'
Represents a form in the database.
Attributes:
- name:
strName of the Melisa where the user registered. Required. - command:
strGroup of the intent. Required. - track:
classClass that handles traceability. Required. Track
Methods:
save(): Saves the Form object to the database.delete(): Deletes the Form object from the database.
Embedded Class:
Class that handles traceability.
user:strUser associated with the track.created:datetimeDate and time of creation.updated:datetimeDate and time of the last update.enable:boolIndicates if the track is enable
Represents an intent in the database.
Attributes:
- name:
strName of the Melisa where the user registered. Required. - group:
enumGroup of the intent. Required. IntentEnum
Methods:
save(): Saves the Intent object to the database.delete(): Deletes the Intent object from the database.
Enums:
Represents the group of intent.
- QA: 'qa'
- COMMAND: 'command'
- FORM: 'form'
Represents the Melisa in the database.
Attributes:
- name:
strName of Melisa. Required. Limited to a maximum length of 50 characters. - url_post:
strURL to return the message. Required. - token:
strToken or password to validate the melisa. Required. Limited to a maximum length of 50 characters. - say_hi:
boolIndicates if Melisa should say "hi". Required. - say_wait:
boolIndicates if Melisa should say "wait" when receiving a request. Required. - countries:
arrayArray with the aclimate's countries ID where the melisa is enabled. Required.
Methods:
save(): Saves the Melisa object to the database.delete(): Deletes the Melisa object from the database.
Represents a Question in the database.
Attributes:
- form:
ReferenceFieldForm to which it belongs. Required. - name:
strName of the variable. Required. - description:
strDescription of the question. Required. - kind:
enumType of variable to ask. Required. QuestionKindEnum - order:
intSet the order to ask the questions to users. Optional. - validations:
arrayList of validations to apply to the question. Required. Validation - track:
classTrack record. Required. Track
Methods:
save(): Saves the Question object to the database.delete(): Deletes the Question object from the database.
Enums:
Represents the type of question.
- STRING: 'str'
- IMAGE: 'img'
- NUMBER: 'number'
Embedded Class:
Represents a validation rule.
name:strName of the validation rule. Required.exp:strExpression or rule to validate. Required.error_msg:strError message to display on validation failure. Required.
Class that handles traceab
Represents a thread of chat with a user in the database.
Attributes:
- user:
ReferenceFieldMelisa where the user registered. Required. - intent:
ReferenceFieldIntent discovered. Required. - status:
enumStatus of the current thread. Required. ThreadEnum
Methods:
save(): Saves the Thread object to the database.delete(): Deletes the Thread object from the database.
Enums:
Represents the status of the thread.
- OPENED: 'opened'
- CLOSED: 'closed'
Represents a User in the database.
Attributes:
- melisa:
ReferenceFieldMelisa where the user registered. Required. - user_id:
strID of the user in the Melisa. Required. - tags:
DictFieldExtra information of the user required by the Melisa. Optional.
Methods:
save(): Saves the User object to the database.delete(): Deletes the User object from the database.