diff --git a/opentech/apply/funds/models.py b/opentech/apply/funds/models.py index e665586d4c9840a1263c377c982ba37c4d3fbe76..9f575ea6a3e22748e9fd76da3268daa293cbf0c0 100644 --- a/opentech/apply/funds/models.py +++ b/opentech/apply/funds/models.py @@ -4,6 +4,7 @@ from django.core.exceptions import ValidationError from django.db import models from django.db.models import Q from django.http import Http404 +from django.urls import reverse from django.utils.text import mark_safe from modelcluster.fields import ParentalKey @@ -30,6 +31,10 @@ WORKFLOW_CLASS = { } +def admin_url(page): + return reverse('wagtailadmin_pages:edit', args=(page.id,)) + + class FundType(AbstractStreamForm): parent_page_types = ['apply_home.ApplyHomePage'] subpage_types = ['funds.Round'] @@ -157,7 +162,10 @@ class Round(AbstractStreamForm): if conflicting_rounds.exists(): error_message = mark_safe('Overlaps with the following rounds:<br> {}'.format( - '<br>'.join([f'{round.start_date} - {round.end_date}' for round in conflicting_rounds]) + '<br>'.join([ + f'<a href="{admin_url(round)}">{round.title}</a>: {round.start_date} - {round.end_date}' + for round in conflicting_rounds] + ) )) error = { 'start_date': error_message,