Example #1
0
    def test_agreement_text(self):
        agreement = Agreement.objects.create(
            type=Agreement.TYPE_PRIVACY,
            text='Lorem ipsum',
            is_active=True,
        )

        result = get_parsed_agreement_text(MockRequest(), agreement)
        self.assertEqual(result, '<p>Lorem ipsum</p>')
Example #2
0
    def test_agreement_no_text(self):
        agreement = Agreement.objects.create(
            type=Agreement.TYPE_PRIVACY,
            link='https://somewhre.com',
            is_active=True,
        )

        result = get_parsed_agreement_text(MockRequest(), agreement)
        self.assertIsNone(result)
def legal_view(request, agreement_type):
    agreement = get_object_or_404(
        Agreement, type=agreement_type, is_active=True
    )

    if agreement.link:
        return redirect(agreement.link)

    template_name = 'misago/{}.html'.format(agreement_type)
    agreement_text = get_parsed_agreement_text(request, agreement)

    return render(
        request,
        template_name,
        {
            'title': agreement.get_final_title(),
            'link': agreement.link,
            'text': agreement_text,
        }
    )