Example #1
0
def privacy(request):
    doc = load_legal_doc('mozilla_privacy_policy', l10n_utils.get_locale(request))

    template_vars = {
        'doc': process_legal_doc(doc['content']),
        'active_locales': doc['active_locales'],
    }

    return l10n_utils.render(request, 'privacy/index.html', template_vars)
Example #2
0
def privacy(request):
    doc = load_legal_doc('mozilla_privacy_policy', l10n_utils.get_locale(request))

    template_vars = {
        'doc': process_legal_doc(doc['content']),
        'active_locales': doc['active_locales'],
    }

    return l10n_utils.render(request, 'privacy/index.html', template_vars)
Example #3
0
 def test_legal_doc_exists_en_locale(self):
     """Should return the content of the en file and say it's en-US."""
     LegalDoc.objects.create(
         name='the_dude_exists',
         locale='en',
         content="You're not wrong Walter...",
     )
     doc = views.load_legal_doc('the_dude_exists', 'en-US')
     self.assertEqual(doc['content'], "You're not wrong Walter...")
     self.assertEqual(doc['active_locales'], ['en-US'])
Example #4
0
 def test_legal_doc_exists_snake_case_convert(self):
     """Should return the content of the file if it exists in snake case."""
     LegalDoc.objects.create(
         name="the_dude_exists",
         locale="en-US",
         content="You're not wrong Walter...",
     )
     doc = views.load_legal_doc("The-Dude-Exists", "de")
     self.assertEqual(doc["content"], "You're not wrong Walter...")
     self.assertEqual(doc["active_locales"], ["en-US"])
Example #5
0
 def test_legal_doc_exists_en_locale__pocket_mode(self):
     """Should return the content of the "en" file and say the active locale is "en" if in Pocket Mode"""
     LegalDoc.objects.create(
         name="the_dude_exists",
         locale="en",
         content="You're not wrong Walter...",
     )
     doc = views.load_legal_doc("the_dude_exists", "en")
     self.assertEqual(doc["content"], "You're not wrong Walter...")
     self.assertEqual(doc["active_locales"], ["en"])
Example #6
0
 def test_legal_doc_exists_en_locale(self):
     """Should return the content of the en file and say it's en-US."""
     LegalDoc.objects.create(
         name="the_dude_exists",
         locale="en",
         content="You're not wrong Walter...",
     )
     doc = views.load_legal_doc("the_dude_exists", "en-US")
     self.assertEqual(doc["content"], "You're not wrong Walter...")
     self.assertEqual(doc["active_locales"], ["en-US"])
Example #7
0
 def test_legal_doc_exists_snake_case_convert(self):
     """Should return the content of the file if it exists in snake case."""
     LegalDoc.objects.create(
         name='the_dude_exists',
         locale='en-US',
         content="You're not wrong Walter...",
     )
     doc = views.load_legal_doc('The-Dude-Exists', 'de')
     self.assertEqual(doc['content'], "You're not wrong Walter...")
     self.assertEqual(doc['active_locales'], ['en-US'])
Example #8
0
def privacy(request):
    doc = load_legal_doc("mozilla_privacy_policy", l10n_utils.get_locale(request))

    template_vars = {
        "doc": process_legal_doc(doc["content"]),
        "localized": doc["localized"],
        "translations": doc["translations"],
    }

    return l10n_utils.render(request, "privacy/index.html", template_vars)
Example #9
0
 def test_localized_legal_doc_exists(self, md_mock, sio_mock, listdir_mock, exists_mock):
     sio_mock.StringIO.return_value.getvalue.return_value = "You're not wrong Walter..."
     exists_mock.return_value = True
     listdir_mock.return_value = ['.mkdir', 'de.md', 'en-US.md']
     doc = views.load_legal_doc('the_dude_exists', 'de')
     good_path = join(views.LEGAL_DOCS_PATH, 'the_dude_exists', 'de.md')
     md_mock.markdownFromFile.assert_called_with(
         input=good_path, output=ANY, extensions=ANY)
     self.assertEqual(doc['content'], "You're not wrong Walter...")
     self.assertTrue(doc['localized'])
     self.assertDictEqual(doc['translations'], {'de': 'Deutsch', 'en-US': 'English (US)'})
Example #10
0
 def test_localized_legal_doc_exists(self, md_mock, bio_mock, listdir_mock, exists_mock):
     """Localization works, and list of translations doesn't include non .md files and non-prod locales."""
     bio_mock().getvalue.return_value = b"You're not wrong Walter..."
     exists_mock.return_value = True
     listdir_mock.return_value = ['.mkdir', 'de.md', 'en-US.md', 'sw.md']
     doc = views.load_legal_doc('the_dude_exists', 'de')
     good_path = join(views.LEGAL_DOCS_PATH, 'the_dude_exists', 'de.md')
     md_mock.markdownFromFile.assert_called_with(
         input=good_path, output=ANY, extensions=ANY)
     self.assertEqual(doc['content'], "You're not wrong Walter...")
     self.assertEqual(doc['active_locales'], ['de', 'en-US'])
Example #11
0
 def test_legal_doc_exists(self, md_mock, bio_mock, listdir_mock, exists_mock):
     """Should return the content of the en-US file if it exists."""
     bio_mock().getvalue.return_value = b"You're not wrong Walter..."
     exists_mock.return_value = False
     listdir_mock.return_value = ['.mkdir', 'de.md', 'en-US.md']
     doc = views.load_legal_doc('the_dude_exists', 'de')
     good_path = join(views.LEGAL_DOCS_PATH, 'the_dude_exists', 'en-US.md')
     md_mock.markdownFromFile.assert_called_with(
         input=good_path, output=ANY, extensions=ANY)
     self.assertEqual(doc['content'], "You're not wrong Walter...")
     self.assertEqual(doc['active_locales'], ['de', 'en-US'])
Example #12
0
 def test_legal_doc_exists(self, md_mock, sio_mock, listdir_mock, exists_mock):
     """Should return the content of the en-US file if it exists."""
     sio_mock.StringIO.return_value.getvalue.return_value = "You're not wrong Walter..."
     exists_mock.return_value = False
     listdir_mock.return_value = ['.mkdir', 'de.md', 'en-US.md']
     doc = views.load_legal_doc('the_dude_exists', 'de')
     good_path = join(views.LEGAL_DOCS_PATH, 'the_dude_exists', 'en-US.md')
     md_mock.markdownFromFile.assert_called_with(
         input=good_path, output=ANY, extensions=ANY)
     self.assertEqual(doc['content'], "You're not wrong Walter...")
     self.assertEqual(doc['active_locales'], ['de', 'en-US'])
Example #13
0
 def test_localized_legal_doc_exists(self, md_mock, sio_mock, listdir_mock, exists_mock):
     """Localization works, and list of translations doesn't include non .md files and non-prod locales."""
     sio_mock.StringIO.return_value.getvalue.return_value = "You're not wrong Walter..."
     exists_mock.return_value = True
     listdir_mock.return_value = ['.mkdir', 'de.md', 'en-US.md', 'sw.md']
     doc = views.load_legal_doc('the_dude_exists', 'de')
     good_path = join(views.LEGAL_DOCS_PATH, 'the_dude_exists', 'de.md')
     md_mock.markdownFromFile.assert_called_with(
         input=good_path, output=ANY, extensions=ANY)
     self.assertEqual(doc['content'], "You're not wrong Walter...")
     self.assertEqual(doc['active_locales'], ['de', 'en-US'])
Example #14
0
 def test_legal_doc_exists(self, md_mock, sio_mock, listdir_mock, exists_mock):
     """Should return the content of the en-US file if it exists."""
     sio_mock.StringIO.return_value.getvalue.return_value = "You're not wrong Walter..."
     exists_mock.return_value = False
     listdir_mock.return_value = ['.mkdir', 'de.md', 'en-US.md']
     doc = views.load_legal_doc('the_dude_exists', 'de')
     good_path = join(views.LEGAL_DOCS_PATH, 'the_dude_exists', 'en-US.md')
     md_mock.markdownFromFile.assert_called_with(
         input=good_path, output=ANY, extensions=ANY)
     self.assertEqual(doc['content'], "You're not wrong Walter...")
     self.assertFalse(doc['localized'])
     self.assertDictEqual(doc['translations'], {'de': 'Deutsch', 'en-US': 'English (US)'})
Example #15
0
 def test_localized_legal_doc_mapped_locale_fixed(self, md_mock, bio_mock, listdir_mock, exists_mock):
     """Should fallback to bedrock locale when legal-docs locale changes to match"""
     bedrock_locale = 'hi-IN'
     ld_filename = '%s.md' % bedrock_locale
     bio_mock().getvalue.return_value = b"You're not wrong Walter..."
     exists_mock.side_effect = [False, True]
     listdir_mock.return_value = [ld_filename, 'en-US.md']
     doc = views.load_legal_doc('the_dude_exists', bedrock_locale)
     good_path = join(views.LEGAL_DOCS_PATH, 'the_dude_exists', ld_filename)
     md_mock.markdownFromFile.assert_called_with(
         input=good_path, output=ANY, extensions=ANY)
     self.assertEqual(doc['content'], "You're not wrong Walter...")
     self.assertEqual(doc['active_locales'], ['hi-IN', 'en-US'])
Example #16
0
 def test_localized_legal_doc_mapped_locale_fixed(self, md_mock, sio_mock, listdir_mock, exists_mock):
     """Should fallback to bedrock locale when legal-docs locale changes to match"""
     bedrock_locale = 'hi-IN'
     ld_filename = '%s.md' % bedrock_locale
     sio_mock.StringIO.return_value.getvalue.return_value = "You're not wrong Walter..."
     exists_mock.side_effect = [False, True]
     listdir_mock.return_value = [ld_filename, 'en-US.md']
     doc = views.load_legal_doc('the_dude_exists', bedrock_locale)
     good_path = join(views.LEGAL_DOCS_PATH, 'the_dude_exists', ld_filename)
     md_mock.markdownFromFile.assert_called_with(
         input=good_path, output=ANY, extensions=ANY)
     self.assertEqual(doc['content'], "You're not wrong Walter...")
     self.assertEqual(doc['active_locales'], ['hi-IN', 'en-US'])
Example #17
0
def privacy(request):
    doc = load_legal_doc("mozilla_privacy_policy",
                         l10n_utils.get_locale(request))

    template_vars = {
        "doc": process_legal_doc(doc["content"]),
        "active_locales": doc["active_locales"],
    }

    return l10n_utils.render(request,
                             "privacy/index.html",
                             template_vars,
                             ftl_files="privacy/index")
Example #18
0
 def test_localized_legal_doc_mapped_locale(self, md_mock, sio_mock, listdir_mock, exists_mock):
     """Should output bedrock locale when legal-docs locale exists"""
     bedrock_locale = 'hi-IN'
     ld_locale = 'hi'
     ld_filename = '%s.md' % ld_locale
     sio_mock.StringIO.return_value.getvalue.return_value = "You're not wrong Walter..."
     exists_mock.return_value = True
     listdir_mock.return_value = [ld_filename, 'en-US.md']
     doc = views.load_legal_doc('the_dude_exists', bedrock_locale)
     good_path = join(views.LEGAL_DOCS_PATH, 'the_dude_exists', ld_filename)
     md_mock.markdownFromFile.assert_called_with(
         input=good_path, output=ANY, extensions=ANY)
     self.assertEqual(doc['content'], "You're not wrong Walter...")
     self.assertEqual(doc['active_locales'], ['hi-IN', 'en-US'])
Example #19
0
 def test_localized_legal_doc_exists(self):
     """Localization works, and list of translations doesn't include non .md files and non-prod locales."""
     LegalDoc.objects.create(
         name="the_dude_exists",
         locale="en",
         content="You're not wrong Walter...",
     )
     LegalDoc.objects.create(
         name="the_dude_exists",
         locale="de",
         content="You're in German Walter...",
     )
     doc = views.load_legal_doc("the_dude_exists", "de")
     self.assertEqual(doc["content"], "You're in German Walter...")
     self.assertEqual(set(doc["active_locales"]), {"de", "en-US"})
Example #20
0
 def test_localized_legal_doc_exists(self):
     """Localization works, and list of translations doesn't include non .md files and non-prod locales."""
     LegalDoc.objects.create(
         name='the_dude_exists',
         locale='en',
         content="You're not wrong Walter...",
     )
     LegalDoc.objects.create(
         name='the_dude_exists',
         locale='de',
         content="You're in German Walter...",
     )
     doc = views.load_legal_doc('the_dude_exists', 'de')
     self.assertEqual(doc['content'], "You're in German Walter...")
     self.assertEqual(set(doc['active_locales']), {'de', 'en-US'})
Example #21
0
 def test_localized_legal_doc_mapped_locale_fixed(self, md_mock, sio_mock, listdir_mock, exists_mock):
     """Should fallback to bedrock locale when legal-docs locale changes to match"""
     bedrock_locale = 'hi-IN'
     ld_filename = '%s.md' % bedrock_locale
     sio_mock.StringIO.return_value.getvalue.return_value = "You're not wrong Walter..."
     exists_mock.side_effect = [False, True]
     listdir_mock.return_value = [ld_filename, 'en-US.md']
     doc = views.load_legal_doc('the_dude_exists', bedrock_locale)
     good_path = join(views.LEGAL_DOCS_PATH, 'the_dude_exists', ld_filename)
     md_mock.markdownFromFile.assert_called_with(
         input=good_path, output=ANY, extensions=ANY)
     self.assertEqual(doc['content'], "You're not wrong Walter...")
     self.assertTrue(doc['localized'])
     self.assertDictEqual(doc['translations'], {
         'hi-IN': u'\u0939\u093f\u0928\u094d\u0926\u0940 (\u092d\u093e\u0930\u0924)',
         'en-US': 'English (US)',
     })
Example #22
0
 def test_localized_legal_doc_mapped_locale(self, md_mock, sio_mock, listdir_mock, exists_mock):
     """Should output bedrock locale when legal-docs locale exists"""
     bedrock_locale = 'hi-IN'
     ld_locale = 'hi'
     ld_filename = '%s.md' % ld_locale
     sio_mock.StringIO.return_value.getvalue.return_value = "You're not wrong Walter..."
     exists_mock.return_value = True
     listdir_mock.return_value = [ld_filename, 'en-US.md']
     doc = views.load_legal_doc('the_dude_exists', bedrock_locale)
     good_path = join(views.LEGAL_DOCS_PATH, 'the_dude_exists', ld_filename)
     md_mock.markdownFromFile.assert_called_with(
         input=good_path, output=ANY, extensions=ANY)
     self.assertEqual(doc['content'], "You're not wrong Walter...")
     self.assertTrue(doc['localized'])
     self.assertDictEqual(doc['translations'], {
         'hi-IN': u'\u0939\u093f\u0928\u094d\u0926\u0940 (\u092d\u093e\u0930\u0924)',
         'en-US': 'English (US)',
     })
Example #23
0
def privacy(request):
    form = PrivacyContactForm()

    form_submitted = False
    form_error = False

    if request.method == 'POST':
        form = PrivacyContactForm(request.POST)
        form_results = submit_form(request, form)

        form_submitted = form_results['form_submitted']
        form_error = form_results['form_error']

    template_vars = {
        'form': form,
        'form_submitted': form_submitted,
        'form_error': form_error,
        'doc': process_legal_doc(load_legal_doc('mozilla_privacy_policy',
                                                l10n_utils.get_locale(request))
        ),
    }

    return l10n_utils.render(request, 'privacy/index.html', template_vars)
Example #24
0
def privacy(request):
    form = PrivacyContactForm()

    form_submitted = False
    form_error = False

    if request.method == 'POST':
        form = PrivacyContactForm(request.POST)
        form_results = submit_form(request, form)

        form_submitted = form_results['form_submitted']
        form_error = form_results['form_error']

    template_vars = {
        'form': form,
        'form_submitted': form_submitted,
        'form_error': form_error,
        'doc': process_legal_doc(load_legal_doc('mozilla_privacy_policy',
                                                l10n_utils.get_locale(request))
        ),
    }

    return l10n_utils.render(request, 'privacy/index.html', template_vars)
Example #25
0
 def test_legal_doc_not_found(self, listdir_mock):
     listdir_mock.return_value = ['en-US.md']
     doc = views.load_legal_doc('the_dude_is_legal', 'de')
     self.assertIsNone(doc['content'])
     self.assertEqual(doc['active_locales'], ['en-US'])
Example #26
0
 def test_legal_doc_not_found(self):
     """Missing doc should be None"""
     doc = views.load_legal_doc('the_dude_is_legal', 'de')
     self.assertIsNone(doc)
Example #27
0
 def test_legal_doc_not_found(self, listdir_mock):
     listdir_mock.return_value = ['en-US.md']
     doc = views.load_legal_doc('the_dude_is_legal', 'de')
     self.assertIsNone(doc['content'])
     self.assertEqual(doc['active_locales'], ['en-US'])
Example #28
0
 def test_legal_doc_not_found(self, listdir_mock):
     listdir_mock.return_value = ['en-US.md']
     doc = views.load_legal_doc('the_dude_is_legal', 'de')
     self.assertIsNone(doc['content'])
     self.assertFalse(doc['localized'])
     self.assertDictEqual(doc['translations'], {'en-US': 'English (US)'})