move modules out

This commit is contained in:
bakatrouble 2019-01-19 05:50:16 +03:00
parent e7d9324df8
commit b0d651ee92
6 changed files with 38 additions and 15 deletions

View File

@ -1,7 +1,7 @@
from django.contrib import admin from django.contrib import admin
from .models import Feed, EchoFeedModuleConfig from .models import Feed
from feeds.modules.echo import EchoFeedModuleConfig
admin.site.register(Feed) admin.site.register(Feed)
admin.site.register(EchoFeedModuleConfig) admin.site.register(EchoFeedModuleConfig)

View File

@ -0,0 +1,18 @@
# Generated by Django 2.1.5 on 2019-01-19 02:49
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('feeds', '0002_feed_lock'),
]
operations = [
migrations.AlterField(
model_name='feed',
name='check_interval',
field=models.DurationField(help_text='in seconds'),
),
]

View File

@ -54,15 +54,3 @@ class FeedModuleConfig(models.Model):
class Meta: class Meta:
abstract = True abstract = True
class EchoFeedModuleConfig(FeedModuleConfig):
message = models.TextField()
MODULE_NAME = 'Echo'
def execute(self, bot: TeleBot, chat_id, last_id):
bot.send_message(chat_id, self.message)
FEED_MODULES = [EchoFeedModuleConfig]

View File

@ -0,0 +1,3 @@
from .echo import EchoFeedModuleConfig
FEED_MODULES = [EchoFeedModuleConfig]

13
feeds/modules/echo.py Normal file
View File

@ -0,0 +1,13 @@
from django.db import models
from telebot import TeleBot
from feeds.models import FeedModuleConfig
class EchoFeedModuleConfig(FeedModuleConfig):
message = models.TextField()
MODULE_NAME = 'Echo'
def execute(self, bot: TeleBot, chat_id, last_id):
bot.send_message(chat_id, self.message)

View File

@ -7,7 +7,8 @@ from django.views.generic import ListView
from django.views.generic.detail import SingleObjectMixin from django.views.generic.detail import SingleObjectMixin
from cabinet.utils import CabinetViewMixin from cabinet.utils import CabinetViewMixin
from feeds.models import Feed, FEED_MODULES from feeds.models import Feed
from feeds.modules import *
from feeds.utils import BaseFeedConfigView from feeds.utils import BaseFeedConfigView