allow to run feed task from interface
This commit is contained in:
parent
71d7ea7147
commit
f52621a267
@ -34,7 +34,10 @@
|
|||||||
{% bootstrap_form config_form layout='horizontal' %}
|
{% bootstrap_form config_form layout='horizontal' %}
|
||||||
</div>
|
</div>
|
||||||
<footer class="card-footer text-right">
|
<footer class="card-footer text-right">
|
||||||
{% if feed %}<a href="#delete-modal" class="modal-basic btn btn-danger">Delete</a>{% endif %}
|
{% if feed %}
|
||||||
|
<a href="#delete-modal" class="modal-basic btn btn-danger">Delete</a>
|
||||||
|
<button type="submit" name="run" class="btn btn-secondary">Run now</button>
|
||||||
|
{% endif %}
|
||||||
<button type="submit" class="btn btn-primary">Save</button>
|
<button type="submit" class="btn btn-primary">Save</button>
|
||||||
</footer>
|
</footer>
|
||||||
</form>
|
</form>
|
||||||
|
@ -10,6 +10,7 @@ from django.views.generic.detail import SingleObjectMixin
|
|||||||
from cabinet.utils import CabinetViewMixin
|
from cabinet.utils import CabinetViewMixin
|
||||||
from feeds.models import Feed
|
from feeds.models import Feed
|
||||||
from feeds.modules import *
|
from feeds.modules import *
|
||||||
|
from feeds.tasks import execute_feed
|
||||||
from feeds.utils import BaseFeedConfigView
|
from feeds.utils import BaseFeedConfigView
|
||||||
|
|
||||||
|
|
||||||
@ -32,9 +33,12 @@ class FeedConfigEditView(BaseFeedConfigView, SingleObjectMixin):
|
|||||||
sidebar_section = 'feeds'
|
sidebar_section = 'feeds'
|
||||||
|
|
||||||
def form_valid(self, feed_form, config_form):
|
def form_valid(self, feed_form, config_form):
|
||||||
feed_form.save()
|
feed = feed_form.save()
|
||||||
config_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('')
|
return HttpResponseRedirect('')
|
||||||
|
|
||||||
def get_content_type(self):
|
def get_content_type(self):
|
||||||
|
Loading…
Reference in New Issue
Block a user