hide mtg fields
This commit is contained in:
@@ -26,6 +26,7 @@ class CyberLinaBotModuleConfig(TelegramBotModuleConfig):
|
||||
welcome_reactions = JSONField(default='[]')
|
||||
inline_reactions = JSONField(default='[]')
|
||||
_mtg_data = JSONField(default={}, blank=True, null=True)
|
||||
_mtg_corpus = models.TextField(null=True, blank=True)
|
||||
mtg_train = models.TextField(null=True, blank=True)
|
||||
|
||||
MODULE_NAME = 'Киберлиночка'
|
||||
@@ -38,7 +39,7 @@ class CyberLinaBotModuleConfig(TelegramBotModuleConfig):
|
||||
'welcome_reactions': JSONEditor(),
|
||||
'inline_reactions': JSONEditor(),
|
||||
}
|
||||
EXCLUDE_FIELDS = '_mtg_data',
|
||||
EXCLUDE_FIELDS = '_mtg_data', '_mtg_corpus',
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
@@ -120,7 +121,9 @@ class CyberLinaBotModuleConfig(TelegramBotModuleConfig):
|
||||
|
||||
def save(self, force_insert=False, force_update=False, using=None, update_fields=None):
|
||||
if self.mtg_train:
|
||||
self._mtg_data = markovify.Text(self.mtg_train).to_dict()
|
||||
self._mtg_corpus += '\n' + self.mtg_train
|
||||
self._mtg_data = markovify.Text(self._mtg_corpus).to_dict()
|
||||
self.mtg_train = None
|
||||
super().save(force_insert, force_update, using, update_fields)
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user