diff --git a/hypha/apply/todo/options.py b/hypha/apply/todo/options.py index 1fa7cb5f42ad031d0db4efc1182e33488a6e2302..6d8b6a32528d58aa09194253a015cd72799c0694 100644 --- a/hypha/apply/todo/options.py +++ b/hypha/apply/todo/options.py @@ -137,12 +137,16 @@ template_map = { def get_task_template(request, code, related_obj, **kwargs): + # if related_object is none/deleted and task remain there(edge case, avoiding 500) + if not related_obj: + return None + templates = copy.deepcopy(template_map) try: template = templates[code] except KeyError: # Unregistered code - return + return None template_kwargs = { "related": related_obj, "link": link_to(related_obj, request), diff --git a/hypha/apply/todo/views.py b/hypha/apply/todo/views.py index 276b770cb8d77953109abcf8d66c2fa0241eb15a..4ec9f2d0077b30bccc59aafa52c9a6100ce5597c 100644 --- a/hypha/apply/todo/views.py +++ b/hypha/apply/todo/views.py @@ -135,4 +135,5 @@ def render_task_templates_for_user(request, user): get_task_template(request, code=task.code, related_obj=task.related_object) for task in tasks ] - return templates + + return list(filter(None, templates))