Skip to content

Commit

Permalink
Fix: CMS plugin for open tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
fsbraun committed Jan 17, 2022
1 parent 83fbbe8 commit 98f4dc8
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 12 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@
/pkg/
/.coverage
/htmlcov/
/src/django_automations.egg-info/
10 changes: 3 additions & 7 deletions src/automations/cms_automations/cms_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
logger = logging.getLogger(__name__)


@plugin_pool.register_plugin
class AutomationTaskList(CMSPluginBase):
name = _("Task list")
module = _("Automations")
Expand All @@ -32,9 +33,7 @@ def render(self, context, instance, placeholder):
return context


plugin_pool.register_plugin(AutomationTaskList)


@plugin_pool.register_plugin
class AutomationDashboard(CMSPluginBase):
name = _("Dashboard")
module = _("Automations")
Expand All @@ -48,9 +47,6 @@ def render(self, context, instance, placeholder):
return context


plugin_pool.register_plugin(AutomationDashboard)


def get_task_choices(pattern, convert, subclass=None):
status_choices = []
for cls_name, verbose_name in flow.get_automations():
Expand Down Expand Up @@ -132,7 +128,7 @@ class Meta:

def clean_name(self):
choices = {}
for _, chapter in get_task_status_choices():
for __, chapter in get_task_status_choices():
choices.update({key: value for key, value in chapter})
return choices.get(self.data["template"], "")

Expand Down
18 changes: 13 additions & 5 deletions src/automations/templates/automations/includes/task_list.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
{% load i18n %}{% spaceless %}
<div class="row row-cols-1 row-cols-md-3 row-cols-lg-4">
{% for task in tasks %}
<div class="col mb-3">{% include "automations/includes/task_item.html" with task=task %}</div>
{% endfor %}
</div>
{% if count %}
<div class="row row-cols-1 row-cols-md-3 row-cols-lg-4">
{% for task in tasks %}
<div class="col mb-3">{% include "automations/includes/task_item.html" with task=task %}</div>
{% endfor %}
</div>
{% else %}
{% if always_inform %}
<div class="alert alert-success">
{% trans "Currently no tasks for you" %}
</div>
{% endif %}
{% endif %}
{% endspaceless %}
2 changes: 2 additions & 0 deletions src/automations/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ def form_valid(self, form):
self.node._automation.run(self.task.previous, self.node)
if hasattr(self.node, "_success_url"):
return redirect(self.node._success_url)
elif "next" in self.request.GET:
return redirect(self.request.GET.get("next"))
return super().form_valid(form)

def get_success_url(self):
Expand Down

0 comments on commit 98f4dc8

Please sign in to comment.