diff --git a/opentech/apply/funds/templates/funds/includes/actions.html b/opentech/apply/funds/templates/funds/includes/actions.html index 6172da03cf12f72981fae370e20d1b799dbb483f..4898fe36fbf160f283ff3646c600f6ab1b8e634a 100644 --- a/opentech/apply/funds/templates/funds/includes/actions.html +++ b/opentech/apply/funds/templates/funds/includes/actions.html @@ -12,5 +12,5 @@ <a data-fancybox data-src="#assign-lead" class="button button--half-width button--white" href="#">Lead</a> </div> - <a class="button button--white button--full-width button--bottom-space" href="#">Placeholder</a> + <a class="button button--white button--full-width button--bottom-space" href="{% url 'apply:revisions:list' submission_pk=object.id %}">Revisions</a> </div> diff --git a/opentech/apply/funds/views.py b/opentech/apply/funds/views.py index 7eb7feb7308011b46ee8de20d91f4ad12532e35b..2cd33849d101bedc1aa5bbe001e0eb09e3954563 100644 --- a/opentech/apply/funds/views.py +++ b/opentech/apply/funds/views.py @@ -6,6 +6,7 @@ from django.http import HttpResponseRedirect from django.shortcuts import get_object_or_404 from django.urls import reverse_lazy from django.utils.decorators import method_decorator +from django.utils.text import mark_safe from django.views.generic import ListView, TemplateView, UpdateView from django_filters.views import FilterView @@ -266,8 +267,13 @@ class RevisionCompareView(TemplateView): def compare_answer(self, answer_a, answer_b): if not answer_a and not answer_b: + # This catches the case where both results are None and we cant compare return answer_b - diff = SequenceMatcher(answer_a, answer_b) + if isinstance(answer_a, dict) or isinstance(answer_b, dict): + # TODO: handle file dictionaries + return answer_b + + diff = SequenceMatcher(None, answer_a, answer_b) output = [] for opcode, a0, a1, b0, b1 in diff.get_opcodes(): if opcode == 'equal': @@ -277,10 +283,11 @@ class RevisionCompareView(TemplateView): elif opcode == 'delete': output.append('<span class="deleted">' + diff.a[a0:a1] + "</span>") elif opcode == 'replace': - raise NotImplementedError("what to do with 'replace' opcode?") + output.append('<span class="deleted">' + diff.a[a0:a1] + "</span>") + output.append('<span class="added">' + diff.b[b0:b1] + '</span>') else: raise RuntimeError("unexpected opcode") - return ''.join(output) + return mark_safe(''.join(output)) def compare(self, from_data, to_data): diffed_form_data = { diff --git a/opentech/static_src/src/sass/apply/components/_revisions.scss b/opentech/static_src/src/sass/apply/components/_revisions.scss new file mode 100644 index 0000000000000000000000000000000000000000..2bd6b17101266249f55591076527a383524d2270 --- /dev/null +++ b/opentech/static_src/src/sass/apply/components/_revisions.scss @@ -0,0 +1,8 @@ +span { + &.deleted { + background-color: #EE9090; + } + &.added { + background-color: #90EE90; + } +} diff --git a/opentech/static_src/src/sass/apply/main.scss b/opentech/static_src/src/sass/apply/main.scss index e53ac847e4db149e720752f4c5bd44f04694b78f..3f122dd07cd6dfbe816c097559da8ee0477f5b99 100755 --- a/opentech/static_src/src/sass/apply/main.scss +++ b/opentech/static_src/src/sass/apply/main.scss @@ -43,6 +43,7 @@ @import 'components/table'; @import 'components/traffic-light'; @import 'components/wrapper'; +@import 'components/revisions'; // Layout @import 'layout/header';