diff --git a/feeds/templates/cabinet/feeds/feed_form.html b/feeds/templates/cabinet/feeds/feed_form.html index a625dae..7b373c1 100644 --- a/feeds/templates/cabinet/feeds/feed_form.html +++ b/feeds/templates/cabinet/feeds/feed_form.html @@ -34,7 +34,10 @@ {% bootstrap_form config_form layout='horizontal' %} diff --git a/feeds/views.py b/feeds/views.py index 2c2173e..5687487 100644 --- a/feeds/views.py +++ b/feeds/views.py @@ -10,6 +10,7 @@ from django.views.generic.detail import SingleObjectMixin from cabinet.utils import CabinetViewMixin from feeds.models import Feed from feeds.modules import * +from feeds.tasks import execute_feed from feeds.utils import BaseFeedConfigView @@ -32,9 +33,12 @@ class FeedConfigEditView(BaseFeedConfigView, SingleObjectMixin): sidebar_section = 'feeds' def form_valid(self, feed_form, config_form): - feed_form.save() + feed = feed_form.save() config_form.save() - messages.success(self.request, 'Config was successfully saved') + if 'run' in self.request.POST: + execute_feed.apply_async(args=(feed.pk,), shadow=str(feed)) + else: + messages.success(self.request, 'Config was successfully saved') return HttpResponseRedirect('') def get_content_type(self):