implement bots
This commit is contained in:
19
bots/forms.py
Normal file
19
bots/forms.py
Normal file
@@ -0,0 +1,19 @@
|
||||
from django.forms import ModelForm
|
||||
|
||||
from bots.models import TelegramBot
|
||||
|
||||
|
||||
class BotForm(ModelForm):
|
||||
prefix = 'bot'
|
||||
|
||||
def __init__(self, *args, module, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
if not hasattr(module, 'rpc_dispatcher'):
|
||||
self.fields.pop('rpc_name')
|
||||
if not hasattr(module, 'periodic_task'):
|
||||
self.fields.pop('periodic_interval')
|
||||
self.fields.pop('periodic_last_run')
|
||||
|
||||
class Meta:
|
||||
model = TelegramBot
|
||||
exclude = 'owner', 'config_type', 'config_id',
|
Reference in New Issue
Block a user