From 8d12fe3d85b02ccc2fa9f06c66d1c3c51e03a9d5 Mon Sep 17 00:00:00 2001 From: James Bennett Date: Thu, 24 Jul 2014 13:07:12 +0200 Subject: [PATCH 01/24] Move wiki app. --- .travis.yml | 2 +- apps/contentflagging/tests.py | 5 +- apps/dashboards/views.py | 16 ++- apps/devmo/helpers.py | 15 +-- apps/kpi/cron.py | 2 +- apps/kpi/tests/test_cron.py | 2 +- apps/search/decorators.py | 2 +- apps/search/models.py | 2 +- apps/search/tests/test_indexes.py | 3 +- apps/search/tests/test_tasks.py | 6 +- apps/search/tests/test_types.py | 3 +- apps/sumo/parser.py | 2 +- apps/sumo/urlresolvers.py | 2 +- kuma/users/models.py | 2 +- kuma/users/tests/test_models.py | 3 +- {apps => kuma}/wiki/__init__.py | 0 {apps => kuma}/wiki/admin.py | 6 +- {apps => kuma}/wiki/badges.py | 5 +- {apps => kuma}/wiki/constants.py | 2 + {apps => kuma}/wiki/content.py | 9 +- {apps => kuma}/wiki/cron.py | 4 +- {apps => kuma}/wiki/decorators.py | 0 {apps => kuma}/wiki/events.py | 6 +- {apps => kuma}/wiki/exceptions.py | 0 {apps => kuma}/wiki/feeds.py | 20 ++-- .../wiki/fixtures/wiki/documents.json | 0 .../wiki/fixtures/wiki/templates.json | 0 .../wiki/fixtures/wiki/toolbars.json | 0 {apps => kuma}/wiki/forms.py | 19 ++-- {apps => kuma}/wiki/helpers.py | 12 +-- {apps => kuma}/wiki/kumascript.py | 10 +- {apps => kuma}/wiki/management/__init__.py | 0 .../wiki/management/commands/__init__.py | 0 .../commands/generate_sphinx_template.py | 10 +- .../management/commands/populate_file_m2m.py | 2 +- .../commands/refresh_wiki_caches.py | 12 +-- .../management/commands/render_document.py | 4 +- .../commands/render_stale_documents.py | 2 +- .../repair_translation_breadcrumbs.py | 4 +- {apps => kuma}/wiki/managers.py | 0 {apps => kuma}/wiki/middleware.py | 0 .../wiki/migrations/0001_initial.py | 0 .../0002_auto__add_editortoolbar.py | 0 ...onfig_file__add_field_editortoolbar_nam.py | 0 ...0004_auto__chg_field_editortoolbar_code.py | 0 ...add_reviewtaggedrevision__add_reviewtag.py | 0 ...revision_title__add_field_revision_slug.py | 0 ...to__add_field_revision_mindtouch_old_id.py | 0 ...uch_page_id__add_field_document_modifie.py | 0 ...dtouch_migration__add_unique_revision_m.py | 0 .../0010_add_locale_slug_uniqueness.py | 0 .../0011_auto__add_field_revision_tags.py | 0 ...to__add_documenttag__add_taggeddocument.py | 0 .../0013_add_permission_edit_template.py | 0 .../migrations/0014_add_show_toc_field.py | 0 .../migrations/0015_add_topical_parent.py | 0 .../wiki/migrations/0016_add_file_storage.py | 0 .../migrations/0017_deferred_rendering.py | 0 .../migrations/0018_clean_documenttags.py | 0 .../0019_disallow_add_attachment.py | 0 .../migrations/0020_revision_created_index.py | 0 .../migrations/0021_add_is_redirect_field.py | 0 .../migrations/0022_populate_is_redirect.py | 0 .../wiki/migrations/0023_attachment_m2m.py | 0 .../migrations/0024_add_toc_depth_field.py | 0 .../wiki/migrations/0025_migrate_toc_depth.py | 0 .../wiki/migrations/0026_remove_show_toc.py | 0 .../0027_auto__add_field_document_json.py | 0 .../0028_auto__add_field_document_team.py | 0 .../migrations/0029_auto__add_documentzone.py | 0 ..._auto__add_unique_documentzone_document.py | 0 .../wiki/migrations/0031_deletable_pages.py | 0 .../wiki/migrations/0032_add_deletion_log.py | 0 ...3_auto__add_field_documentzone_url_root.py | 0 ..._auto__del_unique_documentzone_url_root.py | 0 ...tiontaggedrevision__add_localizationtag.py | 0 ...to__del_field_revision_mindtouch_old_id.py | 0 ..._max_age__add_field_document_render_exp.py | 0 ..._max_age__add_field_revision_render_exp.py | 0 .../0039_auto__add_index_document_deleted.py | 0 ...040_auto__add_fields_for_cached_content.py | 0 ...nique_firefoxversion_item_id_document__.py | 0 .../0042_auto__add_field_document_toc_html.py | 0 ...3_auto__add_field_document_summary_html.py | 0 ...4_auto__add_field_document_summary_text.py | 0 ...n_reviewed__del_field_revision_reviewer.py | 0 {apps => kuma}/wiki/migrations/__init__.py | 0 {apps => kuma}/wiki/models.py | 30 +++--- {apps => kuma}/wiki/queries.py | 0 {apps => kuma}/wiki/signals.py | 0 {apps => kuma}/wiki/tasks.py | 4 +- .../admin/wiki/document/change_list.html | 0 .../admin/wiki/document/load_data_form.html | 0 .../templates/admin/wiki/purge_documents.html | 0 .../templates/wiki/attachment_detail.html | 0 .../templates/wiki/attachment_history.html | 0 .../templates/wiki/attachments/generic.html | 0 {apps => kuma}/wiki/templates/wiki/base.html | 0 .../wiki/templates/wiki/ckeditor_config.js | 0 .../wiki/templates/wiki/code_sample.html | 0 .../templates/wiki/compare_revisions.html | 0 .../wiki/confirm_document_delete.html | 0 .../wiki/confirm_revision_delete.html | 0 .../wiki/confirm_revision_revert.html | 0 .../wiki/templates/wiki/deletion_log.html | 0 .../wiki/templates/wiki/document.html | 0 .../templates/wiki/document_revisions.html | 0 .../wiki/templates/wiki/edit_attachment.html | 0 .../wiki/templates/wiki/edit_document.html | 0 .../wiki/templates/wiki/email/edited.ltxt | 0 .../templates/wiki/includes/ace_scripts.html | 0 .../wiki/includes/attachment_list.html | 0 .../wiki/includes/attachment_row.html | 0 .../includes/attachment_upload_results.html | 0 .../wiki/includes/ckeditor_scripts.html | 0 .../wiki/includes/document_macros.html | 0 .../wiki/includes/document_toc_field.html | 0 .../templates/wiki/includes/guide_links.html | 0 .../wiki/includes/kumascript_errors.html | 0 .../templates/wiki/includes/more_help.html | 0 .../templates/wiki/includes/page_buttons.html | 0 .../templates/wiki/includes/review_tags.html | 0 .../wiki/includes/revision_comment.html | 0 .../wiki/includes/revision_diff.html | 0 .../wiki/includes/revision_diff_table.html | 0 .../wiki/includes/tag_suggestions.html | 0 .../wiki/includes/translate_description.html | 0 .../wiki/includes/wiki_notifier.html | 0 .../wiki/templates/wiki/list_documents.html | 0 .../wiki/list_documents_for_review.html | 0 ...list_documents_with_localization_tags.html | 0 .../wiki/templates/wiki/list_files.html | 0 .../wiki/templates/wiki/list_tags.html | 0 .../wiki/templates/wiki/move_document.html | 0 .../wiki/templates/wiki/move_requested.html | 0 .../wiki/templates/wiki/new_document.html | 0 .../wiki/templates/wiki/preview.html | 0 .../wiki/templates/wiki/revision.html | 0 .../wiki/templates/wiki/select_locale.html | 0 .../wiki/templates/wiki/sitemap.xml | 0 .../wiki/templates/wiki/sphinx.html | 0 .../wiki/templates/wiki/translate.html | 0 .../wiki/templates/wikiparser/hook_video.html | 0 {apps => kuma}/wiki/tests/__init__.py | 6 +- {apps => kuma}/wiki/tests/test_content.py | 100 +++++++++--------- {apps => kuma}/wiki/tests/test_cron.py | 4 +- {apps => kuma}/wiki/tests/test_events.py | 4 +- {apps => kuma}/wiki/tests/test_feeds.py | 6 +- {apps => kuma}/wiki/tests/test_forms.py | 4 +- {apps => kuma}/wiki/tests/test_helpers.py | 8 +- {apps => kuma}/wiki/tests/test_kumascript.py | 3 +- {apps => kuma}/wiki/tests/test_middleware.py | 8 +- {apps => kuma}/wiki/tests/test_models.py | 60 +++++------ {apps => kuma}/wiki/tests/test_templates.py | 30 +++--- {apps => kuma}/wiki/tests/test_views.py | 70 ++++++------ {apps => kuma}/wiki/urls.py | 10 +- {apps => kuma}/wiki/utils.py | 0 {apps => kuma}/wiki/views.py | 42 ++++---- puppet/files/etc/motd | 2 +- settings.py | 10 +- urls.py | 18 ++-- 161 files changed, 299 insertions(+), 314 deletions(-) rename {apps => kuma}/wiki/__init__.py (100%) rename {apps => kuma}/wiki/admin.py (98%) rename {apps => kuma}/wiki/badges.py (98%) rename {apps => kuma}/wiki/constants.py (99%) rename {apps => kuma}/wiki/content.py (99%) rename {apps => kuma}/wiki/cron.py (98%) rename {apps => kuma}/wiki/decorators.py (100%) rename {apps => kuma}/wiki/events.py (97%) rename {apps => kuma}/wiki/exceptions.py (100%) rename {apps => kuma}/wiki/feeds.py (96%) rename {apps => kuma}/wiki/fixtures/wiki/documents.json (100%) rename {apps => kuma}/wiki/fixtures/wiki/templates.json (100%) rename {apps => kuma}/wiki/fixtures/wiki/toolbars.json (100%) rename {apps => kuma}/wiki/forms.py (98%) rename {apps => kuma}/wiki/helpers.py (99%) rename {apps => kuma}/wiki/kumascript.py (99%) rename {apps => kuma}/wiki/management/__init__.py (100%) rename {apps => kuma}/wiki/management/commands/__init__.py (100%) rename {apps => kuma}/wiki/management/commands/generate_sphinx_template.py (98%) rename {apps => kuma}/wiki/management/commands/populate_file_m2m.py (92%) rename {apps => kuma}/wiki/management/commands/refresh_wiki_caches.py (98%) rename {apps => kuma}/wiki/management/commands/render_document.py (97%) rename {apps => kuma}/wiki/management/commands/render_stale_documents.py (92%) rename {apps => kuma}/wiki/management/commands/repair_translation_breadcrumbs.py (97%) rename {apps => kuma}/wiki/managers.py (100%) rename {apps => kuma}/wiki/middleware.py (100%) rename {apps => kuma}/wiki/migrations/0001_initial.py (100%) rename {apps => kuma}/wiki/migrations/0002_auto__add_editortoolbar.py (100%) rename {apps => kuma}/wiki/migrations/0003_auto__del_field_editortoolbar_config_file__add_field_editortoolbar_nam.py (100%) rename {apps => kuma}/wiki/migrations/0004_auto__chg_field_editortoolbar_code.py (100%) rename {apps => kuma}/wiki/migrations/0005_auto__add_reviewtaggedrevision__add_reviewtag.py (100%) rename {apps => kuma}/wiki/migrations/0006_auto__add_field_revision_title__add_field_revision_slug.py (100%) rename {apps => kuma}/wiki/migrations/0007_auto__add_field_revision_mindtouch_old_id.py (100%) rename {apps => kuma}/wiki/migrations/0008_auto__add_field_document_mindtouch_page_id__add_field_document_modifie.py (100%) rename {apps => kuma}/wiki/migrations/0009_auto__add_field_revision_is_mindtouch_migration__add_unique_revision_m.py (100%) rename {apps => kuma}/wiki/migrations/0010_add_locale_slug_uniqueness.py (100%) rename {apps => kuma}/wiki/migrations/0011_auto__add_field_revision_tags.py (100%) rename {apps => kuma}/wiki/migrations/0012_auto__add_documenttag__add_taggeddocument.py (100%) rename {apps => kuma}/wiki/migrations/0013_add_permission_edit_template.py (100%) rename {apps => kuma}/wiki/migrations/0014_add_show_toc_field.py (100%) rename {apps => kuma}/wiki/migrations/0015_add_topical_parent.py (100%) rename {apps => kuma}/wiki/migrations/0016_add_file_storage.py (100%) rename {apps => kuma}/wiki/migrations/0017_deferred_rendering.py (100%) rename {apps => kuma}/wiki/migrations/0018_clean_documenttags.py (100%) rename {apps => kuma}/wiki/migrations/0019_disallow_add_attachment.py (100%) rename {apps => kuma}/wiki/migrations/0020_revision_created_index.py (100%) rename {apps => kuma}/wiki/migrations/0021_add_is_redirect_field.py (100%) rename {apps => kuma}/wiki/migrations/0022_populate_is_redirect.py (100%) rename {apps => kuma}/wiki/migrations/0023_attachment_m2m.py (100%) rename {apps => kuma}/wiki/migrations/0024_add_toc_depth_field.py (100%) rename {apps => kuma}/wiki/migrations/0025_migrate_toc_depth.py (100%) rename {apps => kuma}/wiki/migrations/0026_remove_show_toc.py (100%) rename {apps => kuma}/wiki/migrations/0027_auto__add_field_document_json.py (100%) rename {apps => kuma}/wiki/migrations/0028_auto__add_field_document_team.py (100%) rename {apps => kuma}/wiki/migrations/0029_auto__add_documentzone.py (100%) rename {apps => kuma}/wiki/migrations/0030_auto__add_unique_documentzone_document.py (100%) rename {apps => kuma}/wiki/migrations/0031_deletable_pages.py (100%) rename {apps => kuma}/wiki/migrations/0032_add_deletion_log.py (100%) rename {apps => kuma}/wiki/migrations/0033_auto__add_field_documentzone_url_root.py (100%) rename {apps => kuma}/wiki/migrations/0034_auto__del_unique_documentzone_url_root.py (100%) rename {apps => kuma}/wiki/migrations/0035_auto__add_localizationtaggedrevision__add_localizationtag.py (100%) rename {apps => kuma}/wiki/migrations/0036_auto__del_field_revision_mindtouch_old_id.py (100%) rename {apps => kuma}/wiki/migrations/0037_auto__add_field_document_render_max_age__add_field_document_render_exp.py (100%) rename {apps => kuma}/wiki/migrations/0038_auto__add_field_revision_render_max_age__add_field_revision_render_exp.py (100%) rename {apps => kuma}/wiki/migrations/0039_auto__add_index_document_deleted.py (100%) rename {apps => kuma}/wiki/migrations/0040_auto__add_fields_for_cached_content.py (100%) rename {apps => kuma}/wiki/migrations/0041_auto__del_firefoxversion__del_unique_firefoxversion_item_id_document__.py (100%) rename {apps => kuma}/wiki/migrations/0042_auto__add_field_document_toc_html.py (100%) rename {apps => kuma}/wiki/migrations/0043_auto__add_field_document_summary_html.py (100%) rename {apps => kuma}/wiki/migrations/0044_auto__add_field_document_summary_text.py (100%) rename {apps => kuma}/wiki/migrations/0045_auto__del_field_revision_reviewed__del_field_revision_reviewer.py (100%) rename {apps => kuma}/wiki/migrations/__init__.py (100%) rename {apps => kuma}/wiki/models.py (99%) rename {apps => kuma}/wiki/queries.py (100%) rename {apps => kuma}/wiki/signals.py (100%) rename {apps => kuma}/wiki/tasks.py (100%) rename {apps => kuma}/wiki/templates/admin/wiki/document/change_list.html (100%) rename {apps => kuma}/wiki/templates/admin/wiki/document/load_data_form.html (100%) rename {apps => kuma}/wiki/templates/admin/wiki/purge_documents.html (100%) rename {apps => kuma}/wiki/templates/wiki/attachment_detail.html (100%) rename {apps => kuma}/wiki/templates/wiki/attachment_history.html (100%) rename {apps => kuma}/wiki/templates/wiki/attachments/generic.html (100%) rename {apps => kuma}/wiki/templates/wiki/base.html (100%) rename {apps => kuma}/wiki/templates/wiki/ckeditor_config.js (100%) rename {apps => kuma}/wiki/templates/wiki/code_sample.html (100%) rename {apps => kuma}/wiki/templates/wiki/compare_revisions.html (100%) rename {apps => kuma}/wiki/templates/wiki/confirm_document_delete.html (100%) rename {apps => kuma}/wiki/templates/wiki/confirm_revision_delete.html (100%) rename {apps => kuma}/wiki/templates/wiki/confirm_revision_revert.html (100%) rename {apps => kuma}/wiki/templates/wiki/deletion_log.html (100%) rename {apps => kuma}/wiki/templates/wiki/document.html (100%) rename {apps => kuma}/wiki/templates/wiki/document_revisions.html (100%) rename {apps => kuma}/wiki/templates/wiki/edit_attachment.html (100%) rename {apps => kuma}/wiki/templates/wiki/edit_document.html (100%) rename {apps => kuma}/wiki/templates/wiki/email/edited.ltxt (100%) rename {apps => kuma}/wiki/templates/wiki/includes/ace_scripts.html (100%) rename {apps => kuma}/wiki/templates/wiki/includes/attachment_list.html (100%) rename {apps => kuma}/wiki/templates/wiki/includes/attachment_row.html (100%) rename {apps => kuma}/wiki/templates/wiki/includes/attachment_upload_results.html (100%) rename {apps => kuma}/wiki/templates/wiki/includes/ckeditor_scripts.html (100%) rename {apps => kuma}/wiki/templates/wiki/includes/document_macros.html (100%) rename {apps => kuma}/wiki/templates/wiki/includes/document_toc_field.html (100%) rename {apps => kuma}/wiki/templates/wiki/includes/guide_links.html (100%) rename {apps => kuma}/wiki/templates/wiki/includes/kumascript_errors.html (100%) rename {apps => kuma}/wiki/templates/wiki/includes/more_help.html (100%) rename {apps => kuma}/wiki/templates/wiki/includes/page_buttons.html (100%) rename {apps => kuma}/wiki/templates/wiki/includes/review_tags.html (100%) rename {apps => kuma}/wiki/templates/wiki/includes/revision_comment.html (100%) rename {apps => kuma}/wiki/templates/wiki/includes/revision_diff.html (100%) rename {apps => kuma}/wiki/templates/wiki/includes/revision_diff_table.html (100%) rename {apps => kuma}/wiki/templates/wiki/includes/tag_suggestions.html (100%) rename {apps => kuma}/wiki/templates/wiki/includes/translate_description.html (100%) rename {apps => kuma}/wiki/templates/wiki/includes/wiki_notifier.html (100%) rename {apps => kuma}/wiki/templates/wiki/list_documents.html (100%) rename {apps => kuma}/wiki/templates/wiki/list_documents_for_review.html (100%) rename {apps => kuma}/wiki/templates/wiki/list_documents_with_localization_tags.html (100%) rename {apps => kuma}/wiki/templates/wiki/list_files.html (100%) rename {apps => kuma}/wiki/templates/wiki/list_tags.html (100%) rename {apps => kuma}/wiki/templates/wiki/move_document.html (100%) rename {apps => kuma}/wiki/templates/wiki/move_requested.html (100%) rename {apps => kuma}/wiki/templates/wiki/new_document.html (100%) rename {apps => kuma}/wiki/templates/wiki/preview.html (100%) rename {apps => kuma}/wiki/templates/wiki/revision.html (100%) rename {apps => kuma}/wiki/templates/wiki/select_locale.html (100%) rename {apps => kuma}/wiki/templates/wiki/sitemap.xml (100%) rename {apps => kuma}/wiki/templates/wiki/sphinx.html (100%) rename {apps => kuma}/wiki/templates/wiki/translate.html (100%) rename {apps => kuma}/wiki/templates/wikiparser/hook_video.html (100%) rename {apps => kuma}/wiki/tests/__init__.py (98%) rename {apps => kuma}/wiki/tests/test_content.py (95%) rename {apps => kuma}/wiki/tests/test_cron.py (94%) rename {apps => kuma}/wiki/tests/test_events.py (78%) rename {apps => kuma}/wiki/tests/test_feeds.py (98%) rename {apps => kuma}/wiki/tests/test_forms.py (96%) rename {apps => kuma}/wiki/tests/test_helpers.py (93%) rename {apps => kuma}/wiki/tests/test_kumascript.py (96%) rename {apps => kuma}/wiki/tests/test_middleware.py (97%) rename {apps => kuma}/wiki/tests/test_models.py (98%) rename {apps => kuma}/wiki/tests/test_templates.py (99%) rename {apps => kuma}/wiki/tests/test_views.py (99%) rename {apps => kuma}/wiki/urls.py (94%) rename {apps => kuma}/wiki/utils.py (100%) rename {apps => kuma}/wiki/views.py (99%) diff --git a/.travis.yml b/.travis.yml index fc2c3d6b815..388444f9f4f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -34,7 +34,7 @@ before_script: - mysql -e 'create database kuma;' script: - - python manage.py test --noinput -v2 actioncounters contentflagging dashboards kuma.demos devmo kpi landing search kuma.users wiki kuma.events + - python manage.py test --noinput -v2 actioncounters contentflagging dashboards kuma.demos devmo kpi landing search kuma.users kuma.wiki kuma.events notifications: irc: diff --git a/apps/contentflagging/tests.py b/apps/contentflagging/tests.py index 59fca1d1ec9..f513f1bad5f 100644 --- a/apps/contentflagging/tests.py +++ b/apps/contentflagging/tests.py @@ -21,11 +21,10 @@ from sumo.urlresolvers import reverse +from devmo.tests import LocalizingClient from kuma.demos.models import Submission from kuma.demos.tests.test_models import save_valid_submission -from devmo.tests import LocalizingClient -from wiki.models import Document - +from kuma.wiki.models import Document from .models import ContentFlag from .utils import get_ip, get_unique diff --git a/apps/dashboards/views.py b/apps/dashboards/views.py index 72c6136b8c4..1893d734531 100644 --- a/apps/dashboards/views.py +++ b/apps/dashboards/views.py @@ -1,5 +1,7 @@ -import json import datetime +import json + +from jinja2 import escape from django.contrib.auth.decorators import login_required from django.contrib.auth.models import User @@ -7,17 +9,11 @@ from django.shortcuts import render from django.views.decorators.http import require_GET -from jinja2 import escape - +from kuma.users.helpers import ban_link +from kuma.wiki.models import Document, Revision from sumo.urlresolvers import reverse from sumo.utils import paginate, smart_int - -from kuma.users.helpers import ban_link - -from wiki.models import Document, Revision - -from dashboards.forms import RevisionDashboardForm - +from .forms import RevisionDashboardForm from . import PAGE_SIZE diff --git a/apps/devmo/helpers.py b/apps/devmo/helpers.py index 461591d45b8..ee99c4d6c12 100644 --- a/apps/devmo/helpers.py +++ b/apps/devmo/helpers.py @@ -1,25 +1,26 @@ import datetime +import os import re import urllib -import os + +import bleach +import jinja2 +import pytz from django.conf import settings + +from django.contrib.staticfiles.storage import staticfiles_storage from django.core.cache import cache from django.template import defaultfilters from django.utils.html import strip_tags from django.utils.safestring import mark_safe -import bleach from jingo import register -import jinja2 -import pytz from soapbox.models import Message from statici18n.utils import get_filename -from django.contrib.staticfiles.storage import staticfiles_storage +from kuma.wiki.models import Document from sumo.urlresolvers import split_path, reverse -from wiki.models import Document - from .utils import entity_decode diff --git a/apps/kpi/cron.py b/apps/kpi/cron.py index b3615c9e083..441a3a75a2b 100644 --- a/apps/kpi/cron.py +++ b/apps/kpi/cron.py @@ -3,7 +3,7 @@ import cronjobs from kpi.models import Metric, MetricKind, L10N_METRIC_CODE -from wiki.models import Document +from kuma.wiki.models import Document @cronjobs.register diff --git a/apps/kpi/tests/test_cron.py b/apps/kpi/tests/test_cron.py index a2690f488cf..583f76d568d 100644 --- a/apps/kpi/tests/test_cron.py +++ b/apps/kpi/tests/test_cron.py @@ -6,8 +6,8 @@ from kpi.cron import update_l10n_metric from kpi.models import Metric, L10N_METRIC_CODE from kpi.tests import metric_kind +from kuma.wiki.tests import document, revision from sumo.tests import TestCase -from wiki.tests import document, revision class CronJobTests(TestCase): diff --git a/apps/search/decorators.py b/apps/search/decorators.py index 7402f0cd1fa..160262aa180 100644 --- a/apps/search/decorators.py +++ b/apps/search/decorators.py @@ -2,7 +2,7 @@ from django.db.models.signals import pre_delete from elasticsearch.exceptions import ConnectionError -from wiki.signals import render_done +from kuma.wiki.signals import render_done from .signals import render_done_handler, pre_delete_handler diff --git a/apps/search/models.py b/apps/search/models.py index 8639c641f3a..51e64505ba9 100644 --- a/apps/search/models.py +++ b/apps/search/models.py @@ -15,7 +15,7 @@ from sumo.urlresolvers import reverse -from wiki.models import Document +from kuma.wiki.models import Document from taggit_extras.managers import PrefetchTaggableManager from .decorators import register_mapping_type diff --git a/apps/search/tests/test_indexes.py b/apps/search/tests/test_indexes.py index 8312da98ab7..1b59401cff5 100644 --- a/apps/search/tests/test_indexes.py +++ b/apps/search/tests/test_indexes.py @@ -1,9 +1,10 @@ from nose.tools import eq_, ok_ from django.conf import settings + from elasticsearch.exceptions import RequestError -from wiki.models import Document +from kuma.wiki.models import Document from search.models import Index, DocumentType from search.tests import ElasticTestCase from search.index import get_indexing_es, get_indexes diff --git a/apps/search/tests/test_tasks.py b/apps/search/tests/test_tasks.py index fba9e7f4baf..693c2e4fd57 100644 --- a/apps/search/tests/test_tasks.py +++ b/apps/search/tests/test_tasks.py @@ -1,10 +1,8 @@ from nose.tools import eq_ -from search.tests import ElasticTestCase - -from wiki.tests import revision - +from kuma.wiki.tests import revision from search.models import DocumentType +from search.tests import ElasticTestCase class TestLiveIndexing(ElasticTestCase): diff --git a/apps/search/tests/test_types.py b/apps/search/tests/test_types.py index e4ff9c5a918..8c92b61875f 100644 --- a/apps/search/tests/test_types.py +++ b/apps/search/tests/test_types.py @@ -1,10 +1,9 @@ from nose.tools import ok_, eq_ +from kuma.wiki.models import Document from search.models import DocumentType from search.tests import ElasticTestCase -from wiki.models import Document - class DocumentTypeTests(ElasticTestCase): fixtures = ['test_users.json', 'wiki/documents.json'] diff --git a/apps/sumo/parser.py b/apps/sumo/parser.py index 1ddee5640ae..20aed7d4247 100644 --- a/apps/sumo/parser.py +++ b/apps/sumo/parser.py @@ -92,7 +92,7 @@ def _get_wiki_link(title, locale): found is False if the document does not exist. """ - from wiki.models import Document + from kuma.wiki.models import Document d = get_object_fallback(Document, locale=locale, title=title, is_template=False) if d: diff --git a/apps/sumo/urlresolvers.py b/apps/sumo/urlresolvers.py index ee3cfc167a1..411a4d31d8d 100644 --- a/apps/sumo/urlresolvers.py +++ b/apps/sumo/urlresolvers.py @@ -71,7 +71,7 @@ def reverse(viewname, urlconf=None, args=None, kwargs=None, prefix=None, # See apps/wiki/tests/test_middleware.py for a test exercising this hack. if url.startswith('/docs/'): # HACK: Import here, because otherwise it's a circular reference - from wiki.models import DocumentZone + from kuma.wiki.models import DocumentZone # Work out a current locale, from some source. zone_locale = locale if not zone_locale: diff --git a/kuma/users/models.py b/kuma/users/models.py index 90f95d767f6..5da57bace90 100644 --- a/kuma/users/models.py +++ b/kuma/users/models.py @@ -12,8 +12,8 @@ from tower import ugettext_lazy as _ from devmo.models import ModelBase +from kuma.wiki.models import Revision from sumo.models import LocaleField -from wiki.models import Revision from .helpers import gravatar_url diff --git a/kuma/users/tests/test_models.py b/kuma/users/tests/test_models.py index b6259226db8..6cbca7b78f7 100644 --- a/kuma/users/tests/test_models.py +++ b/kuma/users/tests/test_models.py @@ -4,9 +4,8 @@ from nose.tools import eq_, ok_ from nose.plugins.attrib import attr +from kuma.wiki.tests import revision from sumo.tests import TestCase -from wiki.tests import revision - from ..models import UserBan, UserProfile from . import profile diff --git a/apps/wiki/__init__.py b/kuma/wiki/__init__.py similarity index 100% rename from apps/wiki/__init__.py rename to kuma/wiki/__init__.py diff --git a/apps/wiki/admin.py b/kuma/wiki/admin.py similarity index 98% rename from apps/wiki/admin.py rename to kuma/wiki/admin.py index 7d1dca1e5ca..c4c8401d036 100644 --- a/apps/wiki/admin.py +++ b/kuma/wiki/admin.py @@ -9,9 +9,9 @@ from sumo.urlresolvers import reverse from access.decorators import login_required, permission_required -from wiki.decorators import check_readonly -from wiki.models import (Document, DocumentZone, DocumentTag, Revision, - EditorToolbar, Attachment, AttachmentRevision) +from .decorators import check_readonly +from .models import (Document, DocumentZone, DocumentTag, Revision, + EditorToolbar, Attachment, AttachmentRevision) def dump_selected_documents(self, request, queryset): diff --git a/apps/wiki/badges.py b/kuma/wiki/badges.py similarity index 98% rename from apps/wiki/badges.py rename to kuma/wiki/badges.py index 60b99252822..f5cdca5d6b4 100644 --- a/apps/wiki/badges.py +++ b/kuma/wiki/badges.py @@ -1,10 +1,9 @@ from django.db.models.signals import post_save -import waffle - from badger.utils import get_badge +import waffle -from wiki.models import Revision +from .models import Revision # Machine-awarded badges defined here diff --git a/apps/wiki/constants.py b/kuma/wiki/constants.py similarity index 99% rename from apps/wiki/constants.py rename to kuma/wiki/constants.py index e8d02d83f68..94d2afd2ff6 100644 --- a/apps/wiki/constants.py +++ b/kuma/wiki/constants.py @@ -1,9 +1,11 @@ import re + import bleach from tower import ugettext_lazy as _lazy from django.conf import settings + ALLOWED_TAGS = bleach.ALLOWED_TAGS + [ 'div', 'span', 'p', 'br', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'pre', 'code', 'cite', diff --git a/apps/wiki/content.py b/kuma/wiki/content.py similarity index 99% rename from apps/wiki/content.py rename to kuma/wiki/content.py index 3797bdc2fd8..7d1fb43b4ea 100644 --- a/apps/wiki/content.py +++ b/kuma/wiki/content.py @@ -1,22 +1,19 @@ # coding=utf-8 +from collections import defaultdict import re import urllib from urllib import urlencode from urlparse import urlparse -from collections import defaultdict - from xml.sax.saxutils import quoteattr import html5lib from html5lib.filters._base import Filter as html5lib_Filter -from pyquery import PyQuery as pq - import newrelic.agent +from pyquery import PyQuery as pq from tower import ugettext as _ from sumo.urlresolvers import reverse - from .utils import locale_and_slug_from_path @@ -371,7 +368,7 @@ def __init__(self, source, base_url): self.base_url_parsed = urlparse(base_url) def __iter__(self): - from wiki.models import Document + from kuma.wiki.models import Document input = html5lib_Filter.__iter__(self) diff --git a/apps/wiki/cron.py b/kuma/wiki/cron.py similarity index 98% rename from apps/wiki/cron.py rename to kuma/wiki/cron.py index b2586a20a51..95b242fd6dc 100644 --- a/apps/wiki/cron.py +++ b/kuma/wiki/cron.py @@ -11,8 +11,8 @@ import cronjobs -from wiki import tasks -from wiki.models import Document +from . import tasks +from .models import Document from search.models import DocumentType diff --git a/apps/wiki/decorators.py b/kuma/wiki/decorators.py similarity index 100% rename from apps/wiki/decorators.py rename to kuma/wiki/decorators.py diff --git a/apps/wiki/events.py b/kuma/wiki/events.py similarity index 97% rename from apps/wiki/events.py rename to kuma/wiki/events.py index a82a189d4f7..11e8f879a75 100644 --- a/apps/wiki/events.py +++ b/kuma/wiki/events.py @@ -7,13 +7,13 @@ from django.core.mail import EmailMessage from django.template import Context, loader +from tidings.events import InstanceEvent from tower import ugettext as _ from devmo import email_utils -from tidings.events import InstanceEvent from sumo.urlresolvers import reverse -from wiki.helpers import revisions_unified_diff -from wiki.models import Document +from .helpers import revisions_unified_diff +from .models import Document log = logging.getLogger('mdn.wiki.events') diff --git a/apps/wiki/exceptions.py b/kuma/wiki/exceptions.py similarity index 100% rename from apps/wiki/exceptions.py rename to kuma/wiki/exceptions.py diff --git a/apps/wiki/feeds.py b/kuma/wiki/feeds.py similarity index 96% rename from apps/wiki/feeds.py rename to kuma/wiki/feeds.py index 11e5bf996e4..f7d86ba4aaf 100644 --- a/apps/wiki/feeds.py +++ b/kuma/wiki/feeds.py @@ -3,6 +3,7 @@ import datetime import json import urllib + import validate_jsonp from django.conf import settings @@ -14,9 +15,8 @@ from sumo.urlresolvers import reverse from kuma.users.models import UserProfile - -from wiki.helpers import diff_table, tag_diff_table, compare_url, colorize_diff -from wiki.models import Document, Revision, AttachmentRevision +from .helpers import diff_table, tag_diff_table, compare_url, colorize_diff +from .models import Document, Revision, AttachmentRevision MAX_FEED_ITEMS = getattr(settings, 'MAX_FEED_ITEMS', 500) @@ -64,7 +64,7 @@ def item_author_link(self, document): def item_link(self, document): return self.request.build_absolute_uri( - reverse('wiki.views.document', locale=document.locale, + reverse('kuma.wiki.views.document', locale=document.locale, args=(document.slug,))) def item_categories(self, document): @@ -118,7 +118,7 @@ def write(self, outfile, encoding): # Linkify the tags used in the feed item categories = dict( (x, request.build_absolute_uri( - reverse('wiki.views.list_documents', + reverse('kuma.wiki.views.list_documents', kwargs={'tag': x}))) for x in item['categories'] ) @@ -154,7 +154,7 @@ def get_object(self, request, format, tag=None, category=None): reverse('wiki.tag', args=(tag,))) else: self.link = self.request.build_absolute_uri( - reverse('wiki.views.list_documents')) + reverse('kuma.wiki.views.list_documents')) def items(self): locale = ((self.request.GET.get('all_locales', False) is False) @@ -177,12 +177,12 @@ def get_object(self, request, format, tag=None): if tag: self.title = _('MDN documents for %s review' % tag) self.link = self.request.build_absolute_uri( - reverse('wiki.views.list_documents_for_review', + reverse('kuma.wiki.views.list_documents_for_review', args=(tag,))) else: self.title = _('MDN documents for review') self.link = self.request.build_absolute_uri( - reverse('wiki.views.list_documents_for_review')) + reverse('kuma.wiki.views.list_documents_for_review')) return tag def items(self, tag=None): @@ -208,7 +208,7 @@ def get_object(self, request, format, tag=None): self.locale) # TODO: Need an HTML / dashboard version of this feed self.link = self.request.build_absolute_uri( - reverse('wiki.views.list_documents')) + reverse('kuma.wiki.views.list_documents')) def items(self): return (Document.objects @@ -357,7 +357,7 @@ def item_description(self, item): def item_link(self, item): return self.request.build_absolute_uri( - reverse('wiki.views.document', locale=item.document.locale, + reverse('kuma.wiki.views.document', locale=item.document.locale, args=(item.document.slug,))) def item_pubdate(self, item): diff --git a/apps/wiki/fixtures/wiki/documents.json b/kuma/wiki/fixtures/wiki/documents.json similarity index 100% rename from apps/wiki/fixtures/wiki/documents.json rename to kuma/wiki/fixtures/wiki/documents.json diff --git a/apps/wiki/fixtures/wiki/templates.json b/kuma/wiki/fixtures/wiki/templates.json similarity index 100% rename from apps/wiki/fixtures/wiki/templates.json rename to kuma/wiki/fixtures/wiki/templates.json diff --git a/apps/wiki/fixtures/wiki/toolbars.json b/kuma/wiki/fixtures/wiki/toolbars.json similarity index 100% rename from apps/wiki/fixtures/wiki/toolbars.json rename to kuma/wiki/fixtures/wiki/toolbars.json diff --git a/apps/wiki/forms.py b/kuma/wiki/forms.py similarity index 98% rename from apps/wiki/forms.py rename to kuma/wiki/forms.py index 379177692af..28c7bc90251 100644 --- a/apps/wiki/forms.py +++ b/kuma/wiki/forms.py @@ -1,23 +1,22 @@ import re +import magic +from tower import ugettext_lazy as _lazy +from tower import ugettext as _ + from django import forms from django.conf import settings from django.forms.widgets import CheckboxSelectMultiple -from tower import ugettext_lazy as _lazy -from tower import ugettext as _ - import constance.config -import magic from contentflagging.forms import ContentFlagForm +import kuma.wiki.content from sumo.form_fields import StrippedCharField - -import wiki.content -from wiki.models import (Document, Revision, - AttachmentRevision, valid_slug_parent) from .constants import (SLUG_CLEANSING_REGEX, REVIEW_FLAG_TAGS, LOCALIZATION_FLAG_TAGS, RESERVED_SLUGS) +from .models import (Document, Revision, + AttachmentRevision, valid_slug_parent) TITLE_REQUIRED = _lazy(u'Please provide a title.') @@ -218,7 +217,7 @@ def __init__(self, *args, **kwargs): content = self.instance.content if not self.instance.document.is_template: - tool = wiki.content.parse(content) + tool = kuma.wiki.content.parse(content) tool.injectSectionIDs() if self.section_id: tool.extractSection(self.section_id) @@ -283,7 +282,7 @@ def clean_content(self): # Make sure we start with content form the latest revision. full_content = self.instance.document.current_revision.content # Replace the section content with the form content. - tool = wiki.content.parse(full_content) + tool = kuma.wiki.content.parse(full_content) tool.replaceSection(self.section_id, content) content = tool.serialize() diff --git a/apps/wiki/helpers.py b/kuma/wiki/helpers.py similarity index 99% rename from apps/wiki/helpers.py rename to kuma/wiki/helpers.py index f3ac61c688d..cef13c90de2 100644 --- a/apps/wiki/helpers.py +++ b/kuma/wiki/helpers.py @@ -5,19 +5,19 @@ import re import urllib +import jinja2 +from pyquery import PyQuery as pq +from tidylib import tidy_document +from tower import ugettext as _ + from django.core.serializers.json import DjangoJSONEncoder from django.utils.html import conditional_escape import constance.config from jingo import register -import jinja2 -from pyquery import PyQuery as pq -from tidylib import tidy_document -from tower import ugettext as _ from teamwork.shortcuts import build_policy_admin_links from sumo.urlresolvers import reverse - from .constants import DIFF_WRAP_COLUMN @@ -202,7 +202,7 @@ def colorize_diff(diff): @register.filter def wiki_bleach(val): - from wiki.models import Document + from kuma.wiki.models import Document return jinja2.Markup(Document.objects.clean_content(val)) diff --git a/apps/wiki/kumascript.py b/kuma/wiki/kumascript.py similarity index 99% rename from apps/wiki/kumascript.py rename to kuma/wiki/kumascript.py index f4f004e3467..02830102de9 100644 --- a/apps/wiki/kumascript.py +++ b/kuma/wiki/kumascript.py @@ -1,9 +1,9 @@ -import time -from urlparse import urljoin -import json import base64 -import hashlib from collections import defaultdict +import json +import hashlib +import time +from urlparse import urljoin import requests @@ -214,7 +214,7 @@ def process_body(response, use_constance_bleach_whitelists=False): # We defer bleach sanitation of kumascript content all the way # through editing, source display, and raw output. But, we still # want sanitation, so it finally gets picked up here. - from wiki.models import Document + from kuma.wiki.models import Document return Document.objects.clean_content(resp_body, use_constance_bleach_whitelists) diff --git a/apps/wiki/management/__init__.py b/kuma/wiki/management/__init__.py similarity index 100% rename from apps/wiki/management/__init__.py rename to kuma/wiki/management/__init__.py diff --git a/apps/wiki/management/commands/__init__.py b/kuma/wiki/management/commands/__init__.py similarity index 100% rename from apps/wiki/management/commands/__init__.py rename to kuma/wiki/management/commands/__init__.py diff --git a/apps/wiki/management/commands/generate_sphinx_template.py b/kuma/wiki/management/commands/generate_sphinx_template.py similarity index 98% rename from apps/wiki/management/commands/generate_sphinx_template.py rename to kuma/wiki/management/commands/generate_sphinx_template.py index 42a7a86d57e..4fb63763d5f 100644 --- a/apps/wiki/management/commands/generate_sphinx_template.py +++ b/kuma/wiki/management/commands/generate_sphinx_template.py @@ -2,16 +2,16 @@ import test_utils import re +import html5lib +from html5lib import constants as html5lib_constants +from tower import ugettext as _ + from django.conf import settings from django.shortcuts import render from django.core.management.base import NoArgsCommand -import wiki.content +import kuma.wiki.content -from tower import ugettext as _ - -import html5lib -from html5lib import constants as html5lib_constants class Command(NoArgsCommand): diff --git a/apps/wiki/management/commands/populate_file_m2m.py b/kuma/wiki/management/commands/populate_file_m2m.py similarity index 92% rename from apps/wiki/management/commands/populate_file_m2m.py rename to kuma/wiki/management/commands/populate_file_m2m.py index 1b8590fef4e..7eb6b40c3a3 100644 --- a/apps/wiki/management/commands/populate_file_m2m.py +++ b/kuma/wiki/management/commands/populate_file_m2m.py @@ -2,7 +2,7 @@ from django.core.management.base import NoArgsCommand -from wiki.models import Document +from kuma.wiki.models import Document class Command(NoArgsCommand): diff --git a/apps/wiki/management/commands/refresh_wiki_caches.py b/kuma/wiki/management/commands/refresh_wiki_caches.py similarity index 98% rename from apps/wiki/management/commands/refresh_wiki_caches.py rename to kuma/wiki/management/commands/refresh_wiki_caches.py index e028b186daa..ab2d02149a9 100644 --- a/apps/wiki/management/commands/refresh_wiki_caches.py +++ b/kuma/wiki/management/commands/refresh_wiki_caches.py @@ -4,15 +4,15 @@ Run this periodically, it's useful for preventing redundant traffic between Kuma and other services like Kumascript. """ -import sys -import time import datetime -import urlparse import hashlib import logging -import requests - from optparse import make_option +import sys +import time +import urlparse + +import requests from django.conf import settings from django.core.cache import cache @@ -21,7 +21,7 @@ from django.core.management.base import (BaseCommand, NoArgsCommand, CommandError) -from wiki.models import (Document, Revision) +from kuma.wiki.models import (Document, Revision) PAGE_EXISTS_KEY_TMPL = getattr(settings, 'wiki_page_exists_key_tmpl', diff --git a/apps/wiki/management/commands/render_document.py b/kuma/wiki/management/commands/render_document.py similarity index 97% rename from apps/wiki/management/commands/render_document.py rename to kuma/wiki/management/commands/render_document.py index 6a1aaaa773c..f1e673b52ab 100644 --- a/apps/wiki/management/commands/render_document.py +++ b/kuma/wiki/management/commands/render_document.py @@ -8,8 +8,8 @@ from django.core.management.base import BaseCommand, CommandError -from wiki.models import Document, DocumentRenderingInProgress -from wiki.tasks import render_document +from kuma.wiki.models import Document, DocumentRenderingInProgress +from kuma.wiki.tasks import render_document class Command(BaseCommand): diff --git a/apps/wiki/management/commands/render_stale_documents.py b/kuma/wiki/management/commands/render_stale_documents.py similarity index 92% rename from apps/wiki/management/commands/render_stale_documents.py rename to kuma/wiki/management/commands/render_stale_documents.py index 7d4fb186bb2..53cc3b17517 100644 --- a/apps/wiki/management/commands/render_stale_documents.py +++ b/kuma/wiki/management/commands/render_stale_documents.py @@ -5,7 +5,7 @@ from optparse import make_option from django.core.management.base import BaseCommand -from wiki.tasks import render_stale_documents +from kuma.wiki.tasks import render_stale_documents class Command(BaseCommand): diff --git a/apps/wiki/management/commands/repair_translation_breadcrumbs.py b/kuma/wiki/management/commands/repair_translation_breadcrumbs.py similarity index 97% rename from apps/wiki/management/commands/repair_translation_breadcrumbs.py rename to kuma/wiki/management/commands/repair_translation_breadcrumbs.py index da84a3c3060..668e10ff289 100644 --- a/apps/wiki/management/commands/repair_translation_breadcrumbs.py +++ b/kuma/wiki/management/commands/repair_translation_breadcrumbs.py @@ -2,8 +2,10 @@ Repair breadcrumb relations for translations that are missing parent topics. """ import logging + from django.core.management.base import (BaseCommand) -from wiki.models import Document + +from kuma.wiki.models import Document class Command(BaseCommand): diff --git a/apps/wiki/managers.py b/kuma/wiki/managers.py similarity index 100% rename from apps/wiki/managers.py rename to kuma/wiki/managers.py diff --git a/apps/wiki/middleware.py b/kuma/wiki/middleware.py similarity index 100% rename from apps/wiki/middleware.py rename to kuma/wiki/middleware.py diff --git a/apps/wiki/migrations/0001_initial.py b/kuma/wiki/migrations/0001_initial.py similarity index 100% rename from apps/wiki/migrations/0001_initial.py rename to kuma/wiki/migrations/0001_initial.py diff --git a/apps/wiki/migrations/0002_auto__add_editortoolbar.py b/kuma/wiki/migrations/0002_auto__add_editortoolbar.py similarity index 100% rename from apps/wiki/migrations/0002_auto__add_editortoolbar.py rename to kuma/wiki/migrations/0002_auto__add_editortoolbar.py diff --git a/apps/wiki/migrations/0003_auto__del_field_editortoolbar_config_file__add_field_editortoolbar_nam.py b/kuma/wiki/migrations/0003_auto__del_field_editortoolbar_config_file__add_field_editortoolbar_nam.py similarity index 100% rename from apps/wiki/migrations/0003_auto__del_field_editortoolbar_config_file__add_field_editortoolbar_nam.py rename to kuma/wiki/migrations/0003_auto__del_field_editortoolbar_config_file__add_field_editortoolbar_nam.py diff --git a/apps/wiki/migrations/0004_auto__chg_field_editortoolbar_code.py b/kuma/wiki/migrations/0004_auto__chg_field_editortoolbar_code.py similarity index 100% rename from apps/wiki/migrations/0004_auto__chg_field_editortoolbar_code.py rename to kuma/wiki/migrations/0004_auto__chg_field_editortoolbar_code.py diff --git a/apps/wiki/migrations/0005_auto__add_reviewtaggedrevision__add_reviewtag.py b/kuma/wiki/migrations/0005_auto__add_reviewtaggedrevision__add_reviewtag.py similarity index 100% rename from apps/wiki/migrations/0005_auto__add_reviewtaggedrevision__add_reviewtag.py rename to kuma/wiki/migrations/0005_auto__add_reviewtaggedrevision__add_reviewtag.py diff --git a/apps/wiki/migrations/0006_auto__add_field_revision_title__add_field_revision_slug.py b/kuma/wiki/migrations/0006_auto__add_field_revision_title__add_field_revision_slug.py similarity index 100% rename from apps/wiki/migrations/0006_auto__add_field_revision_title__add_field_revision_slug.py rename to kuma/wiki/migrations/0006_auto__add_field_revision_title__add_field_revision_slug.py diff --git a/apps/wiki/migrations/0007_auto__add_field_revision_mindtouch_old_id.py b/kuma/wiki/migrations/0007_auto__add_field_revision_mindtouch_old_id.py similarity index 100% rename from apps/wiki/migrations/0007_auto__add_field_revision_mindtouch_old_id.py rename to kuma/wiki/migrations/0007_auto__add_field_revision_mindtouch_old_id.py diff --git a/apps/wiki/migrations/0008_auto__add_field_document_mindtouch_page_id__add_field_document_modifie.py b/kuma/wiki/migrations/0008_auto__add_field_document_mindtouch_page_id__add_field_document_modifie.py similarity index 100% rename from apps/wiki/migrations/0008_auto__add_field_document_mindtouch_page_id__add_field_document_modifie.py rename to kuma/wiki/migrations/0008_auto__add_field_document_mindtouch_page_id__add_field_document_modifie.py diff --git a/apps/wiki/migrations/0009_auto__add_field_revision_is_mindtouch_migration__add_unique_revision_m.py b/kuma/wiki/migrations/0009_auto__add_field_revision_is_mindtouch_migration__add_unique_revision_m.py similarity index 100% rename from apps/wiki/migrations/0009_auto__add_field_revision_is_mindtouch_migration__add_unique_revision_m.py rename to kuma/wiki/migrations/0009_auto__add_field_revision_is_mindtouch_migration__add_unique_revision_m.py diff --git a/apps/wiki/migrations/0010_add_locale_slug_uniqueness.py b/kuma/wiki/migrations/0010_add_locale_slug_uniqueness.py similarity index 100% rename from apps/wiki/migrations/0010_add_locale_slug_uniqueness.py rename to kuma/wiki/migrations/0010_add_locale_slug_uniqueness.py diff --git a/apps/wiki/migrations/0011_auto__add_field_revision_tags.py b/kuma/wiki/migrations/0011_auto__add_field_revision_tags.py similarity index 100% rename from apps/wiki/migrations/0011_auto__add_field_revision_tags.py rename to kuma/wiki/migrations/0011_auto__add_field_revision_tags.py diff --git a/apps/wiki/migrations/0012_auto__add_documenttag__add_taggeddocument.py b/kuma/wiki/migrations/0012_auto__add_documenttag__add_taggeddocument.py similarity index 100% rename from apps/wiki/migrations/0012_auto__add_documenttag__add_taggeddocument.py rename to kuma/wiki/migrations/0012_auto__add_documenttag__add_taggeddocument.py diff --git a/apps/wiki/migrations/0013_add_permission_edit_template.py b/kuma/wiki/migrations/0013_add_permission_edit_template.py similarity index 100% rename from apps/wiki/migrations/0013_add_permission_edit_template.py rename to kuma/wiki/migrations/0013_add_permission_edit_template.py diff --git a/apps/wiki/migrations/0014_add_show_toc_field.py b/kuma/wiki/migrations/0014_add_show_toc_field.py similarity index 100% rename from apps/wiki/migrations/0014_add_show_toc_field.py rename to kuma/wiki/migrations/0014_add_show_toc_field.py diff --git a/apps/wiki/migrations/0015_add_topical_parent.py b/kuma/wiki/migrations/0015_add_topical_parent.py similarity index 100% rename from apps/wiki/migrations/0015_add_topical_parent.py rename to kuma/wiki/migrations/0015_add_topical_parent.py diff --git a/apps/wiki/migrations/0016_add_file_storage.py b/kuma/wiki/migrations/0016_add_file_storage.py similarity index 100% rename from apps/wiki/migrations/0016_add_file_storage.py rename to kuma/wiki/migrations/0016_add_file_storage.py diff --git a/apps/wiki/migrations/0017_deferred_rendering.py b/kuma/wiki/migrations/0017_deferred_rendering.py similarity index 100% rename from apps/wiki/migrations/0017_deferred_rendering.py rename to kuma/wiki/migrations/0017_deferred_rendering.py diff --git a/apps/wiki/migrations/0018_clean_documenttags.py b/kuma/wiki/migrations/0018_clean_documenttags.py similarity index 100% rename from apps/wiki/migrations/0018_clean_documenttags.py rename to kuma/wiki/migrations/0018_clean_documenttags.py diff --git a/apps/wiki/migrations/0019_disallow_add_attachment.py b/kuma/wiki/migrations/0019_disallow_add_attachment.py similarity index 100% rename from apps/wiki/migrations/0019_disallow_add_attachment.py rename to kuma/wiki/migrations/0019_disallow_add_attachment.py diff --git a/apps/wiki/migrations/0020_revision_created_index.py b/kuma/wiki/migrations/0020_revision_created_index.py similarity index 100% rename from apps/wiki/migrations/0020_revision_created_index.py rename to kuma/wiki/migrations/0020_revision_created_index.py diff --git a/apps/wiki/migrations/0021_add_is_redirect_field.py b/kuma/wiki/migrations/0021_add_is_redirect_field.py similarity index 100% rename from apps/wiki/migrations/0021_add_is_redirect_field.py rename to kuma/wiki/migrations/0021_add_is_redirect_field.py diff --git a/apps/wiki/migrations/0022_populate_is_redirect.py b/kuma/wiki/migrations/0022_populate_is_redirect.py similarity index 100% rename from apps/wiki/migrations/0022_populate_is_redirect.py rename to kuma/wiki/migrations/0022_populate_is_redirect.py diff --git a/apps/wiki/migrations/0023_attachment_m2m.py b/kuma/wiki/migrations/0023_attachment_m2m.py similarity index 100% rename from apps/wiki/migrations/0023_attachment_m2m.py rename to kuma/wiki/migrations/0023_attachment_m2m.py diff --git a/apps/wiki/migrations/0024_add_toc_depth_field.py b/kuma/wiki/migrations/0024_add_toc_depth_field.py similarity index 100% rename from apps/wiki/migrations/0024_add_toc_depth_field.py rename to kuma/wiki/migrations/0024_add_toc_depth_field.py diff --git a/apps/wiki/migrations/0025_migrate_toc_depth.py b/kuma/wiki/migrations/0025_migrate_toc_depth.py similarity index 100% rename from apps/wiki/migrations/0025_migrate_toc_depth.py rename to kuma/wiki/migrations/0025_migrate_toc_depth.py diff --git a/apps/wiki/migrations/0026_remove_show_toc.py b/kuma/wiki/migrations/0026_remove_show_toc.py similarity index 100% rename from apps/wiki/migrations/0026_remove_show_toc.py rename to kuma/wiki/migrations/0026_remove_show_toc.py diff --git a/apps/wiki/migrations/0027_auto__add_field_document_json.py b/kuma/wiki/migrations/0027_auto__add_field_document_json.py similarity index 100% rename from apps/wiki/migrations/0027_auto__add_field_document_json.py rename to kuma/wiki/migrations/0027_auto__add_field_document_json.py diff --git a/apps/wiki/migrations/0028_auto__add_field_document_team.py b/kuma/wiki/migrations/0028_auto__add_field_document_team.py similarity index 100% rename from apps/wiki/migrations/0028_auto__add_field_document_team.py rename to kuma/wiki/migrations/0028_auto__add_field_document_team.py diff --git a/apps/wiki/migrations/0029_auto__add_documentzone.py b/kuma/wiki/migrations/0029_auto__add_documentzone.py similarity index 100% rename from apps/wiki/migrations/0029_auto__add_documentzone.py rename to kuma/wiki/migrations/0029_auto__add_documentzone.py diff --git a/apps/wiki/migrations/0030_auto__add_unique_documentzone_document.py b/kuma/wiki/migrations/0030_auto__add_unique_documentzone_document.py similarity index 100% rename from apps/wiki/migrations/0030_auto__add_unique_documentzone_document.py rename to kuma/wiki/migrations/0030_auto__add_unique_documentzone_document.py diff --git a/apps/wiki/migrations/0031_deletable_pages.py b/kuma/wiki/migrations/0031_deletable_pages.py similarity index 100% rename from apps/wiki/migrations/0031_deletable_pages.py rename to kuma/wiki/migrations/0031_deletable_pages.py diff --git a/apps/wiki/migrations/0032_add_deletion_log.py b/kuma/wiki/migrations/0032_add_deletion_log.py similarity index 100% rename from apps/wiki/migrations/0032_add_deletion_log.py rename to kuma/wiki/migrations/0032_add_deletion_log.py diff --git a/apps/wiki/migrations/0033_auto__add_field_documentzone_url_root.py b/kuma/wiki/migrations/0033_auto__add_field_documentzone_url_root.py similarity index 100% rename from apps/wiki/migrations/0033_auto__add_field_documentzone_url_root.py rename to kuma/wiki/migrations/0033_auto__add_field_documentzone_url_root.py diff --git a/apps/wiki/migrations/0034_auto__del_unique_documentzone_url_root.py b/kuma/wiki/migrations/0034_auto__del_unique_documentzone_url_root.py similarity index 100% rename from apps/wiki/migrations/0034_auto__del_unique_documentzone_url_root.py rename to kuma/wiki/migrations/0034_auto__del_unique_documentzone_url_root.py diff --git a/apps/wiki/migrations/0035_auto__add_localizationtaggedrevision__add_localizationtag.py b/kuma/wiki/migrations/0035_auto__add_localizationtaggedrevision__add_localizationtag.py similarity index 100% rename from apps/wiki/migrations/0035_auto__add_localizationtaggedrevision__add_localizationtag.py rename to kuma/wiki/migrations/0035_auto__add_localizationtaggedrevision__add_localizationtag.py diff --git a/apps/wiki/migrations/0036_auto__del_field_revision_mindtouch_old_id.py b/kuma/wiki/migrations/0036_auto__del_field_revision_mindtouch_old_id.py similarity index 100% rename from apps/wiki/migrations/0036_auto__del_field_revision_mindtouch_old_id.py rename to kuma/wiki/migrations/0036_auto__del_field_revision_mindtouch_old_id.py diff --git a/apps/wiki/migrations/0037_auto__add_field_document_render_max_age__add_field_document_render_exp.py b/kuma/wiki/migrations/0037_auto__add_field_document_render_max_age__add_field_document_render_exp.py similarity index 100% rename from apps/wiki/migrations/0037_auto__add_field_document_render_max_age__add_field_document_render_exp.py rename to kuma/wiki/migrations/0037_auto__add_field_document_render_max_age__add_field_document_render_exp.py diff --git a/apps/wiki/migrations/0038_auto__add_field_revision_render_max_age__add_field_revision_render_exp.py b/kuma/wiki/migrations/0038_auto__add_field_revision_render_max_age__add_field_revision_render_exp.py similarity index 100% rename from apps/wiki/migrations/0038_auto__add_field_revision_render_max_age__add_field_revision_render_exp.py rename to kuma/wiki/migrations/0038_auto__add_field_revision_render_max_age__add_field_revision_render_exp.py diff --git a/apps/wiki/migrations/0039_auto__add_index_document_deleted.py b/kuma/wiki/migrations/0039_auto__add_index_document_deleted.py similarity index 100% rename from apps/wiki/migrations/0039_auto__add_index_document_deleted.py rename to kuma/wiki/migrations/0039_auto__add_index_document_deleted.py diff --git a/apps/wiki/migrations/0040_auto__add_fields_for_cached_content.py b/kuma/wiki/migrations/0040_auto__add_fields_for_cached_content.py similarity index 100% rename from apps/wiki/migrations/0040_auto__add_fields_for_cached_content.py rename to kuma/wiki/migrations/0040_auto__add_fields_for_cached_content.py diff --git a/apps/wiki/migrations/0041_auto__del_firefoxversion__del_unique_firefoxversion_item_id_document__.py b/kuma/wiki/migrations/0041_auto__del_firefoxversion__del_unique_firefoxversion_item_id_document__.py similarity index 100% rename from apps/wiki/migrations/0041_auto__del_firefoxversion__del_unique_firefoxversion_item_id_document__.py rename to kuma/wiki/migrations/0041_auto__del_firefoxversion__del_unique_firefoxversion_item_id_document__.py diff --git a/apps/wiki/migrations/0042_auto__add_field_document_toc_html.py b/kuma/wiki/migrations/0042_auto__add_field_document_toc_html.py similarity index 100% rename from apps/wiki/migrations/0042_auto__add_field_document_toc_html.py rename to kuma/wiki/migrations/0042_auto__add_field_document_toc_html.py diff --git a/apps/wiki/migrations/0043_auto__add_field_document_summary_html.py b/kuma/wiki/migrations/0043_auto__add_field_document_summary_html.py similarity index 100% rename from apps/wiki/migrations/0043_auto__add_field_document_summary_html.py rename to kuma/wiki/migrations/0043_auto__add_field_document_summary_html.py diff --git a/apps/wiki/migrations/0044_auto__add_field_document_summary_text.py b/kuma/wiki/migrations/0044_auto__add_field_document_summary_text.py similarity index 100% rename from apps/wiki/migrations/0044_auto__add_field_document_summary_text.py rename to kuma/wiki/migrations/0044_auto__add_field_document_summary_text.py diff --git a/apps/wiki/migrations/0045_auto__del_field_revision_reviewed__del_field_revision_reviewer.py b/kuma/wiki/migrations/0045_auto__del_field_revision_reviewed__del_field_revision_reviewer.py similarity index 100% rename from apps/wiki/migrations/0045_auto__del_field_revision_reviewed__del_field_revision_reviewer.py rename to kuma/wiki/migrations/0045_auto__del_field_revision_reviewed__del_field_revision_reviewer.py diff --git a/apps/wiki/migrations/__init__.py b/kuma/wiki/migrations/__init__.py similarity index 100% rename from apps/wiki/migrations/__init__.py rename to kuma/wiki/migrations/__init__.py diff --git a/apps/wiki/models.py b/kuma/wiki/models.py similarity index 99% rename from apps/wiki/models.py rename to kuma/wiki/models.py index 4643826a429..2a561a72cbc 100644 --- a/apps/wiki/models.py +++ b/kuma/wiki/models.py @@ -1,10 +1,18 @@ from datetime import datetime, timedelta -from urlparse import urlparse import hashlib import json -import newrelic.agent -import traceback import sys +import traceback +from urlparse import urlparse + +try: + from functools import wraps +except ImportError: + from django.utils.functional import wraps + +import newrelic.agent +from pyquery import PyQuery +from tower import ugettext_lazy as _lazy, ugettext as _ from django.conf import settings from django.contrib.auth.models import User @@ -17,29 +25,21 @@ from django.utils.decorators import available_attrs from django.utils.functional import cached_property -try: - from functools import wraps -except ImportError: - from django.utils.functional import wraps - import constance.config import jingo -from pyquery import PyQuery from south.modelsinspector import add_introspection_rules from taggit.models import ItemBase, TagBase from taggit.managers import TaggableManager from taggit.utils import parse_tags, edit_string_for_tags from teamwork.models import Team from tidings.models import NotificationsMixin -from tower import ugettext_lazy as _lazy, ugettext as _ import waffle +from search.decorators import register_live_index from sumo import ProgrammingError from sumo.models import LocaleField from sumo.urlresolvers import reverse, split_path from sumo_locales import LOCALES - -from search.decorators import register_live_index from . import kumascript from .constants import (SECONDARY_CACHE_ALIAS, TEMPLATE_TITLE_PREFIX, URL_REMAPS_CACHE_KEY_TMPL, REDIRECT_HTML, @@ -1276,8 +1276,8 @@ def from_url(url, required_locale=None, id_only=False): except Http404: return None - import wiki.views # Views import models; models import views. - if view != wiki.views.document: + from . import views # Views import models; models import views. + if view != views.document: return None # Map locale-slug pair to Document ID: @@ -1465,7 +1465,7 @@ def has_voted(self, request): def is_watched_by(self, user): """Return whether `user` is notified of edits to me.""" - from wiki.events import EditDocumentEvent + from .events import EditDocumentEvent return EditDocumentEvent.is_notifying(user, self) def get_mapping_type(self): diff --git a/apps/wiki/queries.py b/kuma/wiki/queries.py similarity index 100% rename from apps/wiki/queries.py rename to kuma/wiki/queries.py diff --git a/apps/wiki/signals.py b/kuma/wiki/signals.py similarity index 100% rename from apps/wiki/signals.py rename to kuma/wiki/signals.py diff --git a/apps/wiki/tasks.py b/kuma/wiki/tasks.py similarity index 100% rename from apps/wiki/tasks.py rename to kuma/wiki/tasks.py index a22bf736a5e..6b2948ee18d 100644 --- a/apps/wiki/tasks.py +++ b/kuma/wiki/tasks.py @@ -1,16 +1,16 @@ import logging +from celery.task import task, group + from django.conf import settings from django.contrib.auth.models import User from django.core.mail import send_mail from django.db import transaction from django.dispatch import receiver -from celery.task import task, group import waffle from devmo.utils import MemcacheLock - from .exceptions import StaleDocumentsRenderingInProgress, PageMoveError from .models import Document from .signals import render_done diff --git a/apps/wiki/templates/admin/wiki/document/change_list.html b/kuma/wiki/templates/admin/wiki/document/change_list.html similarity index 100% rename from apps/wiki/templates/admin/wiki/document/change_list.html rename to kuma/wiki/templates/admin/wiki/document/change_list.html diff --git a/apps/wiki/templates/admin/wiki/document/load_data_form.html b/kuma/wiki/templates/admin/wiki/document/load_data_form.html similarity index 100% rename from apps/wiki/templates/admin/wiki/document/load_data_form.html rename to kuma/wiki/templates/admin/wiki/document/load_data_form.html diff --git a/apps/wiki/templates/admin/wiki/purge_documents.html b/kuma/wiki/templates/admin/wiki/purge_documents.html similarity index 100% rename from apps/wiki/templates/admin/wiki/purge_documents.html rename to kuma/wiki/templates/admin/wiki/purge_documents.html diff --git a/apps/wiki/templates/wiki/attachment_detail.html b/kuma/wiki/templates/wiki/attachment_detail.html similarity index 100% rename from apps/wiki/templates/wiki/attachment_detail.html rename to kuma/wiki/templates/wiki/attachment_detail.html diff --git a/apps/wiki/templates/wiki/attachment_history.html b/kuma/wiki/templates/wiki/attachment_history.html similarity index 100% rename from apps/wiki/templates/wiki/attachment_history.html rename to kuma/wiki/templates/wiki/attachment_history.html diff --git a/apps/wiki/templates/wiki/attachments/generic.html b/kuma/wiki/templates/wiki/attachments/generic.html similarity index 100% rename from apps/wiki/templates/wiki/attachments/generic.html rename to kuma/wiki/templates/wiki/attachments/generic.html diff --git a/apps/wiki/templates/wiki/base.html b/kuma/wiki/templates/wiki/base.html similarity index 100% rename from apps/wiki/templates/wiki/base.html rename to kuma/wiki/templates/wiki/base.html diff --git a/apps/wiki/templates/wiki/ckeditor_config.js b/kuma/wiki/templates/wiki/ckeditor_config.js similarity index 100% rename from apps/wiki/templates/wiki/ckeditor_config.js rename to kuma/wiki/templates/wiki/ckeditor_config.js diff --git a/apps/wiki/templates/wiki/code_sample.html b/kuma/wiki/templates/wiki/code_sample.html similarity index 100% rename from apps/wiki/templates/wiki/code_sample.html rename to kuma/wiki/templates/wiki/code_sample.html diff --git a/apps/wiki/templates/wiki/compare_revisions.html b/kuma/wiki/templates/wiki/compare_revisions.html similarity index 100% rename from apps/wiki/templates/wiki/compare_revisions.html rename to kuma/wiki/templates/wiki/compare_revisions.html diff --git a/apps/wiki/templates/wiki/confirm_document_delete.html b/kuma/wiki/templates/wiki/confirm_document_delete.html similarity index 100% rename from apps/wiki/templates/wiki/confirm_document_delete.html rename to kuma/wiki/templates/wiki/confirm_document_delete.html diff --git a/apps/wiki/templates/wiki/confirm_revision_delete.html b/kuma/wiki/templates/wiki/confirm_revision_delete.html similarity index 100% rename from apps/wiki/templates/wiki/confirm_revision_delete.html rename to kuma/wiki/templates/wiki/confirm_revision_delete.html diff --git a/apps/wiki/templates/wiki/confirm_revision_revert.html b/kuma/wiki/templates/wiki/confirm_revision_revert.html similarity index 100% rename from apps/wiki/templates/wiki/confirm_revision_revert.html rename to kuma/wiki/templates/wiki/confirm_revision_revert.html diff --git a/apps/wiki/templates/wiki/deletion_log.html b/kuma/wiki/templates/wiki/deletion_log.html similarity index 100% rename from apps/wiki/templates/wiki/deletion_log.html rename to kuma/wiki/templates/wiki/deletion_log.html diff --git a/apps/wiki/templates/wiki/document.html b/kuma/wiki/templates/wiki/document.html similarity index 100% rename from apps/wiki/templates/wiki/document.html rename to kuma/wiki/templates/wiki/document.html diff --git a/apps/wiki/templates/wiki/document_revisions.html b/kuma/wiki/templates/wiki/document_revisions.html similarity index 100% rename from apps/wiki/templates/wiki/document_revisions.html rename to kuma/wiki/templates/wiki/document_revisions.html diff --git a/apps/wiki/templates/wiki/edit_attachment.html b/kuma/wiki/templates/wiki/edit_attachment.html similarity index 100% rename from apps/wiki/templates/wiki/edit_attachment.html rename to kuma/wiki/templates/wiki/edit_attachment.html diff --git a/apps/wiki/templates/wiki/edit_document.html b/kuma/wiki/templates/wiki/edit_document.html similarity index 100% rename from apps/wiki/templates/wiki/edit_document.html rename to kuma/wiki/templates/wiki/edit_document.html diff --git a/apps/wiki/templates/wiki/email/edited.ltxt b/kuma/wiki/templates/wiki/email/edited.ltxt similarity index 100% rename from apps/wiki/templates/wiki/email/edited.ltxt rename to kuma/wiki/templates/wiki/email/edited.ltxt diff --git a/apps/wiki/templates/wiki/includes/ace_scripts.html b/kuma/wiki/templates/wiki/includes/ace_scripts.html similarity index 100% rename from apps/wiki/templates/wiki/includes/ace_scripts.html rename to kuma/wiki/templates/wiki/includes/ace_scripts.html diff --git a/apps/wiki/templates/wiki/includes/attachment_list.html b/kuma/wiki/templates/wiki/includes/attachment_list.html similarity index 100% rename from apps/wiki/templates/wiki/includes/attachment_list.html rename to kuma/wiki/templates/wiki/includes/attachment_list.html diff --git a/apps/wiki/templates/wiki/includes/attachment_row.html b/kuma/wiki/templates/wiki/includes/attachment_row.html similarity index 100% rename from apps/wiki/templates/wiki/includes/attachment_row.html rename to kuma/wiki/templates/wiki/includes/attachment_row.html diff --git a/apps/wiki/templates/wiki/includes/attachment_upload_results.html b/kuma/wiki/templates/wiki/includes/attachment_upload_results.html similarity index 100% rename from apps/wiki/templates/wiki/includes/attachment_upload_results.html rename to kuma/wiki/templates/wiki/includes/attachment_upload_results.html diff --git a/apps/wiki/templates/wiki/includes/ckeditor_scripts.html b/kuma/wiki/templates/wiki/includes/ckeditor_scripts.html similarity index 100% rename from apps/wiki/templates/wiki/includes/ckeditor_scripts.html rename to kuma/wiki/templates/wiki/includes/ckeditor_scripts.html diff --git a/apps/wiki/templates/wiki/includes/document_macros.html b/kuma/wiki/templates/wiki/includes/document_macros.html similarity index 100% rename from apps/wiki/templates/wiki/includes/document_macros.html rename to kuma/wiki/templates/wiki/includes/document_macros.html diff --git a/apps/wiki/templates/wiki/includes/document_toc_field.html b/kuma/wiki/templates/wiki/includes/document_toc_field.html similarity index 100% rename from apps/wiki/templates/wiki/includes/document_toc_field.html rename to kuma/wiki/templates/wiki/includes/document_toc_field.html diff --git a/apps/wiki/templates/wiki/includes/guide_links.html b/kuma/wiki/templates/wiki/includes/guide_links.html similarity index 100% rename from apps/wiki/templates/wiki/includes/guide_links.html rename to kuma/wiki/templates/wiki/includes/guide_links.html diff --git a/apps/wiki/templates/wiki/includes/kumascript_errors.html b/kuma/wiki/templates/wiki/includes/kumascript_errors.html similarity index 100% rename from apps/wiki/templates/wiki/includes/kumascript_errors.html rename to kuma/wiki/templates/wiki/includes/kumascript_errors.html diff --git a/apps/wiki/templates/wiki/includes/more_help.html b/kuma/wiki/templates/wiki/includes/more_help.html similarity index 100% rename from apps/wiki/templates/wiki/includes/more_help.html rename to kuma/wiki/templates/wiki/includes/more_help.html diff --git a/apps/wiki/templates/wiki/includes/page_buttons.html b/kuma/wiki/templates/wiki/includes/page_buttons.html similarity index 100% rename from apps/wiki/templates/wiki/includes/page_buttons.html rename to kuma/wiki/templates/wiki/includes/page_buttons.html diff --git a/apps/wiki/templates/wiki/includes/review_tags.html b/kuma/wiki/templates/wiki/includes/review_tags.html similarity index 100% rename from apps/wiki/templates/wiki/includes/review_tags.html rename to kuma/wiki/templates/wiki/includes/review_tags.html diff --git a/apps/wiki/templates/wiki/includes/revision_comment.html b/kuma/wiki/templates/wiki/includes/revision_comment.html similarity index 100% rename from apps/wiki/templates/wiki/includes/revision_comment.html rename to kuma/wiki/templates/wiki/includes/revision_comment.html diff --git a/apps/wiki/templates/wiki/includes/revision_diff.html b/kuma/wiki/templates/wiki/includes/revision_diff.html similarity index 100% rename from apps/wiki/templates/wiki/includes/revision_diff.html rename to kuma/wiki/templates/wiki/includes/revision_diff.html diff --git a/apps/wiki/templates/wiki/includes/revision_diff_table.html b/kuma/wiki/templates/wiki/includes/revision_diff_table.html similarity index 100% rename from apps/wiki/templates/wiki/includes/revision_diff_table.html rename to kuma/wiki/templates/wiki/includes/revision_diff_table.html diff --git a/apps/wiki/templates/wiki/includes/tag_suggestions.html b/kuma/wiki/templates/wiki/includes/tag_suggestions.html similarity index 100% rename from apps/wiki/templates/wiki/includes/tag_suggestions.html rename to kuma/wiki/templates/wiki/includes/tag_suggestions.html diff --git a/apps/wiki/templates/wiki/includes/translate_description.html b/kuma/wiki/templates/wiki/includes/translate_description.html similarity index 100% rename from apps/wiki/templates/wiki/includes/translate_description.html rename to kuma/wiki/templates/wiki/includes/translate_description.html diff --git a/apps/wiki/templates/wiki/includes/wiki_notifier.html b/kuma/wiki/templates/wiki/includes/wiki_notifier.html similarity index 100% rename from apps/wiki/templates/wiki/includes/wiki_notifier.html rename to kuma/wiki/templates/wiki/includes/wiki_notifier.html diff --git a/apps/wiki/templates/wiki/list_documents.html b/kuma/wiki/templates/wiki/list_documents.html similarity index 100% rename from apps/wiki/templates/wiki/list_documents.html rename to kuma/wiki/templates/wiki/list_documents.html diff --git a/apps/wiki/templates/wiki/list_documents_for_review.html b/kuma/wiki/templates/wiki/list_documents_for_review.html similarity index 100% rename from apps/wiki/templates/wiki/list_documents_for_review.html rename to kuma/wiki/templates/wiki/list_documents_for_review.html diff --git a/apps/wiki/templates/wiki/list_documents_with_localization_tags.html b/kuma/wiki/templates/wiki/list_documents_with_localization_tags.html similarity index 100% rename from apps/wiki/templates/wiki/list_documents_with_localization_tags.html rename to kuma/wiki/templates/wiki/list_documents_with_localization_tags.html diff --git a/apps/wiki/templates/wiki/list_files.html b/kuma/wiki/templates/wiki/list_files.html similarity index 100% rename from apps/wiki/templates/wiki/list_files.html rename to kuma/wiki/templates/wiki/list_files.html diff --git a/apps/wiki/templates/wiki/list_tags.html b/kuma/wiki/templates/wiki/list_tags.html similarity index 100% rename from apps/wiki/templates/wiki/list_tags.html rename to kuma/wiki/templates/wiki/list_tags.html diff --git a/apps/wiki/templates/wiki/move_document.html b/kuma/wiki/templates/wiki/move_document.html similarity index 100% rename from apps/wiki/templates/wiki/move_document.html rename to kuma/wiki/templates/wiki/move_document.html diff --git a/apps/wiki/templates/wiki/move_requested.html b/kuma/wiki/templates/wiki/move_requested.html similarity index 100% rename from apps/wiki/templates/wiki/move_requested.html rename to kuma/wiki/templates/wiki/move_requested.html diff --git a/apps/wiki/templates/wiki/new_document.html b/kuma/wiki/templates/wiki/new_document.html similarity index 100% rename from apps/wiki/templates/wiki/new_document.html rename to kuma/wiki/templates/wiki/new_document.html diff --git a/apps/wiki/templates/wiki/preview.html b/kuma/wiki/templates/wiki/preview.html similarity index 100% rename from apps/wiki/templates/wiki/preview.html rename to kuma/wiki/templates/wiki/preview.html diff --git a/apps/wiki/templates/wiki/revision.html b/kuma/wiki/templates/wiki/revision.html similarity index 100% rename from apps/wiki/templates/wiki/revision.html rename to kuma/wiki/templates/wiki/revision.html diff --git a/apps/wiki/templates/wiki/select_locale.html b/kuma/wiki/templates/wiki/select_locale.html similarity index 100% rename from apps/wiki/templates/wiki/select_locale.html rename to kuma/wiki/templates/wiki/select_locale.html diff --git a/apps/wiki/templates/wiki/sitemap.xml b/kuma/wiki/templates/wiki/sitemap.xml similarity index 100% rename from apps/wiki/templates/wiki/sitemap.xml rename to kuma/wiki/templates/wiki/sitemap.xml diff --git a/apps/wiki/templates/wiki/sphinx.html b/kuma/wiki/templates/wiki/sphinx.html similarity index 100% rename from apps/wiki/templates/wiki/sphinx.html rename to kuma/wiki/templates/wiki/sphinx.html diff --git a/apps/wiki/templates/wiki/translate.html b/kuma/wiki/templates/wiki/translate.html similarity index 100% rename from apps/wiki/templates/wiki/translate.html rename to kuma/wiki/templates/wiki/translate.html diff --git a/apps/wiki/templates/wikiparser/hook_video.html b/kuma/wiki/templates/wikiparser/hook_video.html similarity index 100% rename from apps/wiki/templates/wikiparser/hook_video.html rename to kuma/wiki/templates/wikiparser/hook_video.html diff --git a/apps/wiki/tests/__init__.py b/kuma/wiki/tests/__init__.py similarity index 98% rename from apps/wiki/tests/__init__.py rename to kuma/wiki/tests/__init__.py index cba7854d5c2..4aa48422258 100644 --- a/apps/wiki/tests/__init__.py +++ b/kuma/wiki/tests/__init__.py @@ -10,9 +10,9 @@ from waffle.models import Flag from devmo.tests import LocalizingClient +import kuma.wiki.content +from kuma.wiki.models import Document, Revision from sumo.tests import TestCase, get_user -import wiki.content -from wiki.models import Document, Revision class TestCaseBase(TestCase): @@ -151,7 +151,7 @@ def __iter__(self): continue yield token - return (wiki.content + return (kuma.wiki.content .parse(unicode(input)) .filter(WhitespaceRemovalFilter) .serialize()) diff --git a/apps/wiki/tests/test_content.py b/kuma/wiki/tests/test_content.py similarity index 95% rename from apps/wiki/tests/test_content.py rename to kuma/wiki/tests/test_content.py index 8a293b67f65..ff3af26013d 100644 --- a/apps/wiki/tests/test_content.py +++ b/kuma/wiki/tests/test_content.py @@ -1,27 +1,27 @@ # This Python file uses the following encoding: utf-8 # see also: http://www.python.org/dev/peps/pep-0263/ from urlparse import urljoin -from jinja2 import escape, Markup +import bleach +from jinja2 import escape, Markup from nose.tools import eq_, ok_ from nose.plugins.attrib import attr - from pyquery import PyQuery as pq -import bleach + +import kuma.wiki.content +from kuma.wiki.content import (CodeSyntaxFilter, DekiscriptMacroFilter, + SectionTOCFilter, SectionIDFilter, + H2TOCFilter, H3TOCFilter, + SECTION_TAGS, get_seo_description, + get_content_sections, extract_css_classnames, + extract_html_attributes, + extract_kumascript_macro_names) +from kuma.wiki.constants import ALLOWED_TAGS, ALLOWED_ATTRIBUTES +from kuma.wiki.models import Document +from kuma.wiki.tests import normalize_html, doc_rev, document +from kuma.wiki.helpers import bugize_text from sumo.tests import TestCase -import wiki.content -from wiki.content import (CodeSyntaxFilter, DekiscriptMacroFilter, - SectionTOCFilter, SectionIDFilter, - H2TOCFilter, H3TOCFilter, - SECTION_TAGS, get_seo_description, - get_content_sections, extract_css_classnames, - extract_html_attributes, - extract_kumascript_macro_names) -from wiki.constants import ALLOWED_TAGS, ALLOWED_ATTRIBUTES -from wiki.models import Document -from wiki.tests import normalize_html, doc_rev, document -from wiki.helpers import bugize_text class ContentSectionToolTests(TestCase): @@ -57,7 +57,7 @@ def test_section_ids(self): """ - result_src = (wiki.content + result_src = (kuma.wiki.content .parse(doc_src) .injectSectionIDs() .serialize()) @@ -93,7 +93,7 @@ def test_incremented_section_ids(self):

Header Two

""" - result_src = (wiki.content + result_src = (kuma.wiki.content .parse(doc_src) .injectSectionIDs() .serialize()) @@ -109,7 +109,7 @@ def test_incremented_section_ids(self): eq_(result_src, expected) # Ensure 1, 2 doesn't turn into 3, 4 - result_src = (wiki.content + result_src = (kuma.wiki.content .parse(expected) .injectSectionIDs() .serialize()) @@ -130,7 +130,7 @@ def test_simple_implicit_section_extract(self):

test

test

""" - result = (wiki.content + result = (kuma.wiki.content .parse(doc_src) .extractSection(id="s1") .serialize()) @@ -171,7 +171,7 @@ def test_contained_implicit_section_extract(self):

test

test

""" - result = (wiki.content + result = (kuma.wiki.content .parse(doc_src) .extractSection(id="s5") .serialize()) @@ -215,7 +215,7 @@ def test_explicit_section_extract(self):

test

test

""" - result = (wiki.content + result = (kuma.wiki.content .parse(doc_src) .extractSection(id="parent-s5") .serialize()) @@ -249,7 +249,7 @@ def test_multilevel_implicit_section_extract(self):

test

test

""" - result = (wiki.content + result = (kuma.wiki.content .parse(doc_src) .extractSection(id="s4") .serialize()) @@ -296,7 +296,7 @@ def test_morelevels_implicit_section_extract(self):

Head

test

""" - result = (wiki.content + result = (kuma.wiki.content .parse(doc_src) .extractSection(id="s8") .serialize()) @@ -328,7 +328,7 @@ def test_basic_section_replace(self):

test

test

""" - result = (wiki.content + result = (kuma.wiki.content .parse(doc_src) .replaceSection(id="s2", replace_src=replace_src) .serialize()) @@ -357,7 +357,7 @@ def test_section_edit_links(self):

test

test

""" - result = (wiki.content + result = (kuma.wiki.content .parse(doc_src) .injectSectionEditingLinks('some-slug', 'en-US') .serialize()) @@ -388,7 +388,7 @@ def test_code_syntax_conversion(self): .dek-trans { color: red; } """ - result = (wiki.content + result = (kuma.wiki.content .parse(doc_src) .filter(CodeSyntaxFilter).serialize()) eq_(normalize_html(expected), normalize_html(result)) @@ -465,7 +465,7 @@ def test_generate_toc(self): """ - result = (wiki.content + result = (kuma.wiki.content .parse(doc_src) .filter(SectionTOCFilter).serialize()) eq_(normalize_html(expected), normalize_html(result)) @@ -493,7 +493,7 @@ def test_generate_toc_h2(self):
  • CSS
  • """ - result = (wiki.content + result = (kuma.wiki.content .parse(doc_src) .filter(H2TOCFilter).serialize()) eq_(normalize_html(expected), normalize_html(result)) @@ -532,7 +532,7 @@ def test_generate_toc_h3(self): """ - result = (wiki.content + result = (kuma.wiki.content .parse(doc_src) .filter(H3TOCFilter).serialize()) eq_(normalize_html(expected), normalize_html(result)) @@ -548,7 +548,7 @@ def test_bug_925043(self): Masteringprint """ - result = (wiki.content + result = (kuma.wiki.content .parse(doc_src) .filter(SectionTOCFilter).serialize()) eq_(normalize_html(expected), normalize_html(result)) @@ -585,13 +585,13 @@ def test_dekiscript_macro_conversion(self): doc_src_lines = doc_src.split("\n") expected_lines = expected.split("\n") for i in range(0, len(doc_src_lines)): - result = (wiki.content + result = (kuma.wiki.content .parse(doc_src_lines[i]) .filter(DekiscriptMacroFilter).serialize()) eq_(normalize_html(expected_lines[i]), normalize_html(result)) # But, the whole thing should work in the filter, as well. - result = (wiki.content + result = (kuma.wiki.content .parse(doc_src) .filter(DekiscriptMacroFilter).serialize()) eq_(normalize_html(expected), normalize_html(result)) @@ -615,7 +615,7 @@ def test_noinclude(self):
    Przykłady 例 예제 示例
    """ - result = (wiki.content.filter_out_noinclude(doc_src)) + result = (kuma.wiki.content.filter_out_noinclude(doc_src)) eq_(normalize_html(expected), normalize_html(result)) def test_noinclude_empty_content(self): @@ -623,7 +623,7 @@ def test_noinclude_empty_content(self): empty string as input""" doc_src = '' try: - result = wiki.content.filter_out_noinclude(doc_src) + result = kuma.wiki.content.filter_out_noinclude(doc_src) eq_('', result) except: ok_(False, "There should not have been an exception") @@ -688,31 +688,31 @@ def test_sample_code_extraction(self): """ % (escape(sample_html), escape(sample_css), escape(sample_js)) # live sample using the section logic - result = wiki.content.extract_code_sample('sample0', doc_src) + result = kuma.wiki.content.extract_code_sample('sample0', doc_src) eq_('section html', result['html'].strip()) eq_('section css', result['css'].strip()) eq_('section js', result['js'].strip()) # pull out a complete sample. - result = wiki.content.extract_code_sample('sample2', doc_src) + result = kuma.wiki.content.extract_code_sample('sample2', doc_src) eq_(sample_html.strip(), result['html'].strip()) eq_(sample_css.strip(), result['css'].strip()) eq_(sample_js.strip(), result['js'].strip()) # a sample missing one part. - result = wiki.content.extract_code_sample('sample3', doc_src) + result = kuma.wiki.content.extract_code_sample('sample3', doc_src) eq_('Ignore me', result['html'].strip()) eq_(None, result['css']) eq_('Ignore me', result['js'].strip()) # a sample with only one part. - result = wiki.content.extract_code_sample('sample4', doc_src) + result = kuma.wiki.content.extract_code_sample('sample4', doc_src) eq_(None, result['html']) eq_(None, result['css']) eq_('Ignore me', result['js'].strip()) # a "sample" with no code listings. - result = wiki.content.extract_code_sample('not-a-sample', doc_src) + result = kuma.wiki.content.extract_code_sample('not-a-sample', doc_src) eq_(None, result['html']) eq_(None, result['css']) eq_(None, result['js']) @@ -732,7 +732,7 @@ def test_bug819999(self): } """ - result = wiki.content.extract_code_sample('bug819999', doc_src) + result = kuma.wiki.content.extract_code_sample('bug819999', doc_src) ok_(result['css'].find(u'\xa0') == -1) def test_bugize_text(self): @@ -757,7 +757,7 @@ def test_iframe_host_filter(self):

    test

    """ % dict(embed_url=embed_url) - result_src = (wiki.content.parse(doc_src) + result_src = (kuma.wiki.content.parse(doc_src) .filterIframeHosts('^https?\:\/\/sampleserver') .serialize()) page = pq(result_src) @@ -782,7 +782,7 @@ def test_iframe_host_filter_invalid_host(self):

    test

    """ - result_src = (wiki.content.parse(doc_src) + result_src = (kuma.wiki.content.parse(doc_src) .filterIframeHosts('^https?\:\/\/(sample|test)server') .serialize()) page = pq(result_src) @@ -804,9 +804,9 @@ def test_iframe_host_filter_youtube(self):

    test

    """ % tubes - result_src = (wiki.content.parse(doc_src) - .filterIframeHosts('^https?\:\/\/(www.)?youtube.com\/embed\/(\.*)') - .serialize()) + result_src = (kuma.wiki.content.parse(doc_src) + .filterIframeHosts('^https?\:\/\/(www.)?youtube.com\/embed\/(\.*)') + .serialize()) page = pq(result_src) eq_(page.find('#if1').attr('src'), tubes[0]) @@ -824,7 +824,7 @@ def test_iframe_host_contents_filter(self): """ - result_src = (wiki.content.parse(doc_src) + result_src = (kuma.wiki.content.parse(doc_src) .filterIframeHosts('^https?\:\/\/sampleserver') .serialize()) eq_(normalize_html(expected_src), normalize_html(result_src)) @@ -913,7 +913,7 @@ def test_link_annotation(self): for idx in range(0, len(doc_lines)): doc_line = doc_lines[idx] expected_line = expected_lines[idx] - result_line = (wiki.content.parse(doc_line) + result_line = (kuma.wiki.content.parse(doc_line) .annotateLinks(base_url=vars['base_url']) .serialize()) eq_(normalize_html(expected_line), normalize_html(result_line)) @@ -943,7 +943,7 @@ def test_editor_safety_filter(self):

    Header Three

    test

    """ - result_src = (wiki.content.parse(doc_src) + result_src = (kuma.wiki.content.parse(doc_src) .filterEditorSafety() .serialize()) eq_(normalize_html(expected_src), normalize_html(result_src)) @@ -965,7 +965,7 @@ def test_ignore_heading_section_extract(self):

    Head 4-1-1

    test s4-2

    """ - result = (wiki.content + result = (kuma.wiki.content .parse(doc_src) .extractSection(id="s4-1", ignore_heading=True) .serialize()) @@ -996,7 +996,7 @@ def test_ignore_heading_section_replace(self):

    test

    test

    """ - result = (wiki.content + result = (kuma.wiki.content .parse(doc_src) .replaceSection(id="s2", replace_src=replace_src, diff --git a/apps/wiki/tests/test_cron.py b/kuma/wiki/tests/test_cron.py similarity index 94% rename from apps/wiki/tests/test_cron.py rename to kuma/wiki/tests/test_cron.py index 42933db1a0a..e5cc33375d8 100644 --- a/apps/wiki/tests/test_cron.py +++ b/kuma/wiki/tests/test_cron.py @@ -2,9 +2,9 @@ from django.conf import settings +from kuma.wiki.cron import build_sitemaps +from kuma.wiki.models import Document from sumo.tests import TestCase -from wiki.cron import build_sitemaps -from wiki.models import Document class SitemapsTestCase(TestCase): diff --git a/apps/wiki/tests/test_events.py b/kuma/wiki/tests/test_events.py similarity index 78% rename from apps/wiki/tests/test_events.py rename to kuma/wiki/tests/test_events.py index ec871e3a6d0..b0643bda6b2 100644 --- a/apps/wiki/tests/test_events.py +++ b/kuma/wiki/tests/test_events.py @@ -1,7 +1,7 @@ from nose.tools import eq_ -from wiki.tests import TestCaseBase, revision -from wiki.events import context_dict +from kuma.wiki.events import context_dict +from kuma.wiki.tests import TestCaseBase, revision class NotificationEmailTests(TestCaseBase): diff --git a/apps/wiki/tests/test_feeds.py b/kuma/wiki/tests/test_feeds.py similarity index 98% rename from apps/wiki/tests/test_feeds.py rename to kuma/wiki/tests/test_feeds.py index 9cee233690b..7af8bff6a08 100644 --- a/apps/wiki/tests/test_feeds.py +++ b/kuma/wiki/tests/test_feeds.py @@ -2,17 +2,17 @@ # This Python file uses the following encoding: utf-8 # see also: http://www.python.org/dev/peps/pep-0263/ -import time import datetime import json import hashlib +import time from nose.tools import eq_, ok_ from pyquery import PyQuery as pq +from kuma.wiki.tests import (TestCaseBase, document, revision, make_translation, + wait_add_rev) from sumo.urlresolvers import reverse -from wiki.tests import (TestCaseBase, document, revision, make_translation, - wait_add_rev) class FeedTests(TestCaseBase): diff --git a/apps/wiki/tests/test_forms.py b/kuma/wiki/tests/test_forms.py similarity index 96% rename from apps/wiki/tests/test_forms.py rename to kuma/wiki/tests/test_forms.py index 0b7095dbc1e..3bbbe7546f6 100644 --- a/apps/wiki/tests/test_forms.py +++ b/kuma/wiki/tests/test_forms.py @@ -1,9 +1,9 @@ from nose.tools import eq_, ok_ from nose.plugins.attrib import attr +from kuma.wiki.forms import RevisionForm, RevisionValidationForm, TreeMoveForm +from kuma.wiki.tests import doc_rev, normalize_html from sumo.tests import TestCase -from wiki.forms import RevisionForm, RevisionValidationForm, TreeMoveForm -from wiki.tests import doc_rev, normalize_html class FormEditorSafetyFilterTests(TestCase): diff --git a/apps/wiki/tests/test_helpers.py b/kuma/wiki/tests/test_helpers.py similarity index 93% rename from apps/wiki/tests/test_helpers.py rename to kuma/wiki/tests/test_helpers.py index d2cc71b2a59..76af5da5775 100644 --- a/apps/wiki/tests/test_helpers.py +++ b/kuma/wiki/tests/test_helpers.py @@ -2,10 +2,10 @@ from django.contrib.auth.models import User -from wiki.tests import TestCaseBase, revision -from wiki.helpers import (revisions_unified_diff, - document_zone_management_links, tojson) -from wiki.models import DocumentZone +from kuma.wiki.models import DocumentZone +from kuma.wiki.helpers import (revisions_unified_diff, + document_zone_management_links, tojson) +from kuma.wiki.tests import TestCaseBase, revision class HelpTests(TestCaseBase): diff --git a/apps/wiki/tests/test_kumascript.py b/kuma/wiki/tests/test_kumascript.py similarity index 96% rename from apps/wiki/tests/test_kumascript.py rename to kuma/wiki/tests/test_kumascript.py index 77a34eb0fb4..21d2e120cf4 100644 --- a/apps/wiki/tests/test_kumascript.py +++ b/kuma/wiki/tests/test_kumascript.py @@ -2,10 +2,11 @@ # see also: http://www.python.org/dev/peps/pep-0263/ import json import base64 + from nose.tools import eq_ from . import TestCaseBase -from wiki import kumascript +from kuma.wiki import kumascript class KumascriptClientTests(TestCaseBase): diff --git a/apps/wiki/tests/test_middleware.py b/kuma/wiki/tests/test_middleware.py similarity index 97% rename from apps/wiki/tests/test_middleware.py rename to kuma/wiki/tests/test_middleware.py index b5f3b653d12..ad8901ed7eb 100644 --- a/apps/wiki/tests/test_middleware.py +++ b/kuma/wiki/tests/test_middleware.py @@ -4,11 +4,11 @@ from nose.tools import eq_ from sumo.urlresolvers import reverse -from . import TestCaseBase +from kuma.wiki.constants import SECONDARY_CACHE_ALIAS +from kuma.wiki.models import DocumentZone +from kuma.wiki.tests import revision -from wiki.constants import SECONDARY_CACHE_ALIAS -from wiki.models import DocumentZone -from wiki.tests import revision +from . import TestCaseBase class DocumentZoneMiddlewareTestCase(TestCaseBase): diff --git a/apps/wiki/tests/test_models.py b/kuma/wiki/tests/test_models.py similarity index 98% rename from apps/wiki/tests/test_models.py rename to kuma/wiki/tests/test_models.py index 641f3a5b402..8278130460c 100644 --- a/apps/wiki/tests/test_models.py +++ b/kuma/wiki/tests/test_models.py @@ -1,41 +1,37 @@ +from cStringIO import StringIO from datetime import datetime, timedelta import json import time from xml.sax.saxutils import escape -from django.conf import settings - -from cStringIO import StringIO import mock from nose.tools import eq_, ok_ from nose.plugins.attrib import attr from nose import SkipTest +from django.conf import settings from django.core.exceptions import ValidationError from django.contrib.auth.models import User, Group, Permission from django.contrib.contenttypes.models import ContentType import constance.config - from waffle.models import Switch -from sumo import ProgrammingError -from sumo.tests import TestCase - from devmo.utils import MemcacheLock from devmo.tests import override_constance_settings - -from wiki.cron import calculate_related_documents -from wiki.exceptions import (PageMoveError, - DocumentRenderedContentNotAvailable, - DocumentRenderingInProgress) -from wiki.models import (Document, Revision, - Attachment, DocumentZone, - TaggedDocument,) -from wiki.tests import (document, revision, doc_rev, normalize_html, - create_template_test_users, - create_topical_parents_docs) -from wiki import tasks +from kuma.wiki.cron import calculate_related_documents +from kuma.wiki.exceptions import (PageMoveError, + DocumentRenderedContentNotAvailable, + DocumentRenderingInProgress) +from kuma.wiki.models import (Document, Revision, + Attachment, DocumentZone, + TaggedDocument,) +from kuma.wiki import tasks +from kuma.wiki.tests import (document, revision, doc_rev, normalize_html, + create_template_test_users, + create_topical_parents_docs) +from sumo import ProgrammingError +from sumo.tests import TestCase def _objects_eq(manager, list_): @@ -939,7 +935,7 @@ def test_rendering_fields(self): ok_(not self.d1.is_rendering_in_progress) @override_constance_settings(KUMASCRIPT_TIMEOUT=1.0) - @mock.patch('wiki.kumascript.get') + @mock.patch('kuma.wiki.kumascript.get') def test_get_rendered(self, mock_kumascript_get): """get_rendered() should return rendered content when available, attempt a render() when it's not""" @@ -969,7 +965,7 @@ def test_get_rendered(self, mock_kumascript_get): @attr('bug875349') @override_constance_settings(KUMASCRIPT_TIMEOUT=1.0) - @mock.patch('wiki.kumascript.get') + @mock.patch('kuma.wiki.kumascript.get') def test_build_json_on_render(self, mock_kumascript_get): """ A document's json field is refreshed on render(), but not on save() @@ -995,7 +991,7 @@ def test_build_json_on_render(self, mock_kumascript_get): self.d1.render() eq_(self.d1.title, self.d1.get_json_data()['title']) - @mock.patch('wiki.kumascript.get') + @mock.patch('kuma.wiki.kumascript.get') def test_get_summary(self, mock_kumascript_get): """get_summary() should attempt to use rendered""" raise SkipTest("Transient failures here, skip for now") @@ -1010,7 +1006,7 @@ def test_get_summary(self, mock_kumascript_get): constance.config.KUMASCRIPT_TIMEOUT = 0.0 - @mock.patch('wiki.kumascript.get') + @mock.patch('kuma.wiki.kumascript.get') def test_one_render_at_a_time(self, mock_kumascript_get): """Only one in-progress rendering should be allowed for a Document""" mock_kumascript_get.return_value = (self.rendered_content, None) @@ -1023,7 +1019,7 @@ def test_one_render_at_a_time(self, mock_kumascript_get): except DocumentRenderingInProgress: pass - @mock.patch('wiki.kumascript.get') + @mock.patch('kuma.wiki.kumascript.get') def test_render_timeout(self, mock_kumascript_get): """ A rendering that has taken too long is no longer considered in progress @@ -1040,7 +1036,7 @@ def test_render_timeout(self, mock_kumascript_get): ok_(False, "A timed-out rendering should not be considered as " "still in progress") - @mock.patch('wiki.kumascript.get') + @mock.patch('kuma.wiki.kumascript.get') def test_long_render_sets_deferred(self, mock_kumascript_get): """A rendering that takes more than a desired response time marks the document as in need of deferred rendering in the future.""" @@ -1062,7 +1058,7 @@ def my_kumascript_get(self, cache_control, base_url, timeout): ok_(self.d1.defer_rendering) constance.config.KUMASCRIPT_TIMEOUT = 0.0 - @mock.patch('wiki.kumascript.get') + @mock.patch('kuma.wiki.kumascript.get') @mock.patch_object(tasks.render_document, 'delay') def test_schedule_rendering(self, mock_render_document_delay, mock_kumascript_get): @@ -1097,7 +1093,7 @@ def test_schedule_rendering(self, mock_render_document_delay, ok_(self.d1.is_rendering_scheduled) ok_(not self.d1.is_rendering_in_progress) - @mock.patch('wiki.kumascript.get') + @mock.patch('kuma.wiki.kumascript.get') @mock.patch_object(tasks.render_document, 'delay') def test_deferred_vs_immediate_rendering(self, mock_render_document_delay, mock_kumascript_get): @@ -1139,7 +1135,7 @@ def test_deferred_vs_immediate_rendering(self, mock_render_document_delay, pass ok_(mock_render_document_delay.called) - @mock.patch('wiki.kumascript.get') + @mock.patch('kuma.wiki.kumascript.get') def test_errors_stored_correctly(self, mock_kumascript_get): errors = [ {'level': 'error', 'message': 'This is a fake error', @@ -1178,7 +1174,7 @@ def test_find_stale_documents(self): sorted([x.pk for x in stale_docs])) @override_constance_settings(KUMASCRIPT_TIMEOUT=1.0) - @mock.patch('wiki.kumascript.get') + @mock.patch('kuma.wiki.kumascript.get') def test_update_expires_with_max_age(self, mock_kumascript_get): mock_kumascript_get.return_value = ('MOCK CONTENT', None) @@ -1196,7 +1192,7 @@ def test_update_expires_with_max_age(self, mock_kumascript_get): ok_(d1.render_expires < later + timedelta(seconds=1)) @override_constance_settings(KUMASCRIPT_TIMEOUT=1.0) - @mock.patch('wiki.kumascript.get') + @mock.patch('kuma.wiki.kumascript.get') def test_update_expires_without_max_age(self, mock_kumascript_get): mock_kumascript_get.return_value = ('MOCK CONTENT', None) @@ -1209,7 +1205,7 @@ def test_update_expires_without_max_age(self, mock_kumascript_get): ok_(not d1.render_expires) @override_constance_settings(KUMASCRIPT_TIMEOUT=1.0) - @mock.patch('wiki.kumascript.get') + @mock.patch('kuma.wiki.kumascript.get') def test_render_stale(self, mock_kumascript_get): mock_kumascript_get.return_value = ('MOCK CONTENT', None) @@ -1232,7 +1228,7 @@ def test_render_stale(self, mock_kumascript_get): ok_(d1_fresh.last_rendered_at > earlier) @override_constance_settings(KUMASCRIPT_TIMEOUT=1.0) - @mock.patch('wiki.kumascript.get') + @mock.patch('kuma.wiki.kumascript.get') @mock.patch_object(tasks.render_document, 'delay') def test_render_stale_immediate(self, mock_render_document_delay, mock_kumascript_get): diff --git a/apps/wiki/tests/test_templates.py b/kuma/wiki/tests/test_templates.py similarity index 99% rename from apps/wiki/tests/test_templates.py rename to kuma/wiki/tests/test_templates.py index eee865da6ab..aa36013673f 100644 --- a/apps/wiki/tests/test_templates.py +++ b/kuma/wiki/tests/test_templates.py @@ -1,7 +1,14 @@ # This Python file uses the following encoding: utf-8 from datetime import datetime, timedelta -import urllib import time +import urllib + +from BeautifulSoup import BeautifulSoup +import mock +from nose import SkipTest +from nose.tools import eq_, ok_ +from nose.plugins.attrib import attr +from pyquery import PyQuery as pq from django.conf import settings from django.contrib.auth.models import User @@ -11,25 +18,18 @@ from django.test.client import Client from django.test.utils import override_settings -import mock -from nose import SkipTest -from nose.tools import eq_, ok_ -from nose.plugins.attrib import attr -from pyquery import PyQuery as pq -from BeautifulSoup import BeautifulSoup - import constance.config +from devmo.tests import SkippedTestCase +from kuma.wiki.events import EditDocumentEvent +from kuma.wiki.constants import REDIRECT_CONTENT +from kuma.wiki.models import (Document, Revision, HelpfulVote, + DocumentTag, Attachment) +from kuma.wiki.tests import (TestCaseBase, document, revision, new_document_data, + create_topical_parents_docs, make_test_file) from sumo.urlresolvers import reverse from sumo.helpers import urlparams from sumo.tests import post, get -from wiki.events import EditDocumentEvent -from wiki.constants import REDIRECT_CONTENT -from wiki.models import (Document, Revision, HelpfulVote, - DocumentTag, Attachment) -from wiki.tests import (TestCaseBase, document, revision, new_document_data, - create_topical_parents_docs, make_test_file) -from devmo.tests import SkippedTestCase DOCUMENT_EDITED_EMAIL_CONTENT = """ diff --git a/apps/wiki/tests/test_views.py b/kuma/wiki/tests/test_views.py similarity index 99% rename from apps/wiki/tests/test_views.py rename to kuma/wiki/tests/test_views.py index 7a619aae51d..9cac6e8c70d 100644 --- a/apps/wiki/tests/test_views.py +++ b/kuma/wiki/tests/test_views.py @@ -1,9 +1,15 @@ # coding=utf-8 +import base64 import datetime import json -import base64 -import time import logging +import time + +import mock +from nose import SkipTest +from nose.tools import eq_, ok_ +from nose.plugins.attrib import attr +from pyquery import PyQuery as pq from urlparse import urlparse @@ -19,36 +25,26 @@ from django.http import Http404 from django.utils.encoding import smart_str -import mock -from nose import SkipTest -from nose.tools import eq_, ok_ -from nose.plugins.attrib import attr -from pyquery import PyQuery as pq - import constance.config - from waffle.models import Flag +from authkeys.models import Key +from devmo.tests import override_constance_settings +from . import TestCaseBase, FakeResponse, make_test_file +from kuma.wiki.constants import DOCUMENT_LAST_MODIFIED_CACHE_KEY_TMPL +import kuma.wiki.content +from kuma.wiki.content import get_seo_description +from kuma.wiki.events import EditDocumentEvent +from kuma.wiki.models import (Document, Revision, Attachment, DocumentZone, + AttachmentRevision, DocumentAttachment) +from kuma.wiki.tests import (doc_rev, document, new_document_data, revision, + normalize_html, create_template_test_users, + make_translation) +from kuma.wiki.forms import MIDAIR_COLLISION from sumo.tests import post, get from sumo.helpers import urlparams from sumo.urlresolvers import reverse -from devmo.tests import override_constance_settings - -from . import TestCaseBase, FakeResponse, make_test_file - -from authkeys.models import Key - -from wiki.constants import DOCUMENT_LAST_MODIFIED_CACHE_KEY_TMPL -from wiki.content import get_seo_description -from wiki.events import EditDocumentEvent -from wiki.models import (Document, Revision, Attachment, DocumentZone, - AttachmentRevision, DocumentAttachment) -from wiki.tests import (doc_rev, document, new_document_data, revision, - normalize_html, create_template_test_users, - make_translation) -from wiki.forms import MIDAIR_COLLISION - class RedirectTests(TestCaseBase): """Tests for the REDIRECT wiki directive""" @@ -578,7 +574,7 @@ def setUp(self): # TODO: upgrade mock to 0.8.0 so we can do this. # self.mock_kumascript_get = ( - # mock.patch('wiki.kumascript.get')) + # mock.patch('kuma.wiki.kumascript.get')) # self.mock_kumascript_get.return_value = self.d.html def tearDown(self): @@ -589,7 +585,7 @@ def tearDown(self): # self.mock_kumascript_get.stop() @override_constance_settings(KUMASCRIPT_TIMEOUT=1.0) - @mock.patch('wiki.kumascript.get') + @mock.patch('kuma.wiki.kumascript.get') def test_basic_view(self, mock_kumascript_get): """When kumascript timeout is non-zero, the service should be used""" mock_kumascript_get.return_value = (self.d.html, None) @@ -598,7 +594,7 @@ def test_basic_view(self, mock_kumascript_get): "kumascript should have been used") @override_constance_settings(KUMASCRIPT_TIMEOUT=0.0) - @mock.patch('wiki.kumascript.get') + @mock.patch('kuma.wiki.kumascript.get') def test_disabled(self, mock_kumascript_get): """When disabled, the kumascript service should not be used""" mock_kumascript_get.return_value = (self.d.html, None) @@ -607,7 +603,7 @@ def test_disabled(self, mock_kumascript_get): "kumascript not should have been used") @override_constance_settings(KUMASCRIPT_TIMEOUT=0.0) - @mock.patch('wiki.kumascript.get') + @mock.patch('kuma.wiki.kumascript.get') def test_disabled_rendering(self, mock_kumascript_get): """When disabled, the kumascript service should not be used in rendering""" @@ -618,7 +614,7 @@ def test_disabled_rendering(self, mock_kumascript_get): "kumascript not should have been used") @override_constance_settings(KUMASCRIPT_TIMEOUT=1.0) - @mock.patch('wiki.kumascript.get') + @mock.patch('kuma.wiki.kumascript.get') def test_nomacros(self, mock_kumascript_get): mock_kumascript_get.return_value = (self.d.html, None) self.client.get('%s?nomacros' % self.url, follow=False) @@ -626,7 +622,7 @@ def test_nomacros(self, mock_kumascript_get): "kumascript should not have been used") @override_constance_settings(KUMASCRIPT_TIMEOUT=1.0) - @mock.patch('wiki.kumascript.get') + @mock.patch('kuma.wiki.kumascript.get') def test_raw(self, mock_kumascript_get): mock_kumascript_get.return_value = (self.d.html, None) self.client.get('%s?raw' % self.url, follow=False) @@ -634,7 +630,7 @@ def test_raw(self, mock_kumascript_get): "kumascript should not have been used") @override_constance_settings(KUMASCRIPT_TIMEOUT=1.0) - @mock.patch('wiki.kumascript.get') + @mock.patch('kuma.wiki.kumascript.get') def test_raw_macros(self, mock_kumascript_get): mock_kumascript_get.return_value = (self.d.html, None) self.client.get('%s?raw¯os' % self.url, follow=False) @@ -2286,7 +2282,7 @@ def _create_doc(slug, locale): locale=settings.WIKI_DEFAULT_LANGUAGE)) @override_constance_settings(KUMASCRIPT_TIMEOUT=1.0) - @mock.patch('wiki.kumascript.get') + @mock.patch('kuma.wiki.kumascript.get') def test_revert(self, mock_kumascript_get): self.client.login(username='admin', password='testpass') @@ -3125,7 +3121,7 @@ def tearDown(self): constance.config.KUMASCRIPT_TIMEOUT = 0 constance.config.KUMASCRIPT_MAX_AGE = 0 - @mock.patch('wiki.kumascript.get') + @mock.patch('kuma.wiki.kumascript.get') def test_rendered_content(self, mock_kumascript_get): """Document view should serve up rendered content when available""" mock_kumascript_get.return_value = (self.rendered_content, None) @@ -3161,7 +3157,7 @@ def test_rendering_in_progress_warning(self): p = pq(resp.content) eq_(1, p.find('#doc-rendering-in-progress').length) - @mock.patch('wiki.kumascript.get') + @mock.patch('kuma.wiki.kumascript.get') def test_raw_content_during_initial_render(self, mock_kumascript_get): """Raw content should be displayed during a document's initial deferred rendering""" @@ -3191,7 +3187,7 @@ def test_raw_content_during_initial_render(self, mock_kumascript_get): @attr('schedule_rendering') @mock.patch_object(Document, 'schedule_rendering') - @mock.patch('wiki.kumascript.get') + @mock.patch('kuma.wiki.kumascript.get') def test_schedule_rendering(self, mock_kumascript_get, mock_document_schedule_rendering): mock_kumascript_get.return_value = (self.rendered_content, None) @@ -3221,7 +3217,7 @@ def test_schedule_rendering(self, mock_kumascript_get, eq_(302, response.status_code) ok_(mock_document_schedule_rendering.called) - @mock.patch('wiki.kumascript.get') + @mock.patch('kuma.wiki.kumascript.get') @mock.patch('requests.post') def test_alternate_bleach_whitelist(self, mock_requests_post, mock_kumascript_get): diff --git a/apps/wiki/urls.py b/kuma/wiki/urls.py similarity index 94% rename from apps/wiki/urls.py rename to kuma/wiki/urls.py index cbe8f931d91..b4770e8cd61 100644 --- a/apps/wiki/urls.py +++ b/kuma/wiki/urls.py @@ -1,13 +1,13 @@ from django.conf.urls import include, patterns, url from django.views.generic import TemplateView -from wiki.feeds import (DocumentsRecentFeed, DocumentsReviewFeed, RevisionsFeed, - AttachmentsFeed, - DocumentsUpdatedTranslationParentFeed,) +from .feeds import (DocumentsRecentFeed, DocumentsReviewFeed, RevisionsFeed, + AttachmentsFeed, + DocumentsUpdatedTranslationParentFeed,) # These patterns inherit (?P[^\$]+). -document_patterns = patterns('wiki.views', +document_patterns = patterns('kuma.wiki.views', url(r'^$', 'document', name='wiki.document'), url(r'^\$revision/(?P\d+)$', 'revision', name='wiki.revision'), @@ -48,7 +48,7 @@ url(r'^\$vote', 'helpful_vote', name="wiki.document_vote"), ) -urlpatterns = patterns('wiki.views', +urlpatterns = patterns('kuma.wiki.views', # Un/Subscribe to locale 'ready for review' notifications. url(r'^/ckeditor_config.js$', 'ckeditor_config', name='wiki.ckeditor_config'), diff --git a/apps/wiki/utils.py b/kuma/wiki/utils.py similarity index 100% rename from apps/wiki/utils.py rename to kuma/wiki/utils.py diff --git a/apps/wiki/views.py b/kuma/wiki/views.py similarity index 99% rename from apps/wiki/views.py rename to kuma/wiki/views.py index 52063c7bb3a..e91bbf4b054 100644 --- a/apps/wiki/views.py +++ b/kuma/wiki/views.py @@ -3,15 +3,19 @@ import json import hashlib import logging +import mime_types import re from urllib import urlencode -import mime_types try: from cStringIO import cStringIO as StringIO except: from StringIO import StringIO +import newrelic.agent +from pyquery import PyQuery as pq +from tower import ugettext_lazy as _lazy, ugettext as _ + from django.conf import settings from django.contrib import messages from django.core.exceptions import PermissionDenied @@ -32,25 +36,21 @@ xframe_options_sameorigin) from django.views.decorators.csrf import csrf_exempt -from authkeys.decorators import accepts_auth_key import constance.config import jinja2 -import newrelic.agent -from pyquery import PyQuery as pq from smuggler.utils import superuser_required from smuggler.forms import ImportFileForm from teamwork.shortcuts import get_object_or_404_or_403 -from tower import ugettext_lazy as _lazy, ugettext as _ from access.decorators import permission_required, login_required +from authkeys.decorators import accepts_auth_key from contentflagging.models import ContentFlag, FLAG_NOTIFICATIONS +import kuma.wiki.content +from kuma.users.models import UserProfile from search.store import referrer_url from sumo.helpers import urlparams from sumo.urlresolvers import reverse from sumo.utils import paginate, smart_int -from kuma.users.models import UserProfile - -import wiki.content from . import kumascript from .constants import (DOCUMENTS_PER_PAGE, TEMPLATE_TITLE_PREFIX, SLUG_CLEANSING_REGEX, REVIEW_FLAG_TAGS_DEFAULT, @@ -352,7 +352,7 @@ def _filter_doc_html(request, doc, doc_html, rendering_params): return doc_html # TODO: One more view-time content parsing instance to refactor - tool = wiki.content.parse(doc_html) + tool = kuma.wiki.content.parse(doc_html) # ?raw view is often used for editors - apply safety filtering. # TODO: Should this stuff happen in render() itself? @@ -380,7 +380,7 @@ def _filter_doc_html(request, doc, doc_html, rendering_params): # because this is often paired with ?section - so we'd need to store every # section twice for with & without include sections if rendering_params['include']: - doc_html = wiki.content.filter_out_noinclude(doc_html) + doc_html = kuma.wiki.content.filter_out_noinclude(doc_html) return doc_html @@ -1240,17 +1240,17 @@ def _edit_document_collision(request, orig_rev, curr_rev, is_iframe_target, # Process the content as if it were about to be saved, so that the # html_diff is close as possible. - content = (wiki.content - .parse(request.POST['content']) - .injectSectionIDs() - .serialize()) + content = (kuma.wiki.content + .parse(request.POST['content']) + .injectSectionIDs() + .serialize()) # Process the original content for a diff, extracting a section if we're # editing one. if (doc.is_template): curr_content = curr_rev.content else: - tool = wiki.content.parse(curr_rev.content) + tool = kuma.wiki.content.parse(curr_rev.content) tool.injectSectionIDs() if section_id: tool.extractSection(section_id) @@ -1669,9 +1669,9 @@ def translate(request, document_slug, document_locale, revision_id=None): elif not doc: content = based_on_rev.content if content: - initial.update(content=wiki.content.parse(content) - .filterEditorSafety() - .serialize()) + initial.update(content=kuma.wiki.content.parse(content) + .filterEditorSafety() + .serialize()) instance = doc and doc.current_or_latest_revision() rev_form = RevisionForm(instance=instance, initial=initial) @@ -1826,9 +1826,9 @@ def json_view(request, document_slug=None, document_locale=None): return HttpResponseBadRequest() document = get_object_or_404(Document, **kwargs) - (wiki.content.parse(document.html) - .injectSectionIDs() - .serialize()) + (kuma.wiki.content.parse(document.html) + .injectSectionIDs() + .serialize()) stale = True if request.user.is_authenticated(): diff --git a/puppet/files/etc/motd b/puppet/files/etc/motd index 893f21bff01..a359cd7ee5f 100644 --- a/puppet/files/etc/motd +++ b/puppet/files/etc/motd @@ -7,7 +7,7 @@ To run developer-local.allizom.org, run: (Consult ~/src/Procfile to see what services are managed by Foreman.) To run Kuma tests: - ~/src/manage.py test actioncounters contentflagging kuma.demos devmo landing kuma.users search wiki kuma.events + ~/src/manage.py test actioncounters contentflagging kuma.demos devmo landing kuma.users search kuma.wiki kuma.events To run KumaScript tests: cd ~/src/kumascript && ./node_modules/.bin/nodeunit tests diff --git a/settings.py b/settings.py index 38c4cd61559..09ffee941c4 100644 --- a/settings.py +++ b/settings.py @@ -393,8 +393,8 @@ def lazy_language_deki_map(): # LocaleURLMiddleware must be before any middleware that uses # sumo.urlresolvers.reverse() to add locale prefixes to URLs: 'sumo.middleware.LocaleURLMiddleware', - 'wiki.middleware.DocumentZoneMiddleware', - 'wiki.middleware.ReadOnlyMiddleware', + 'kuma.wiki.middleware.DocumentZoneMiddleware', + 'kuma.wiki.middleware.ReadOnlyMiddleware', 'sumo.middleware.Forbidden403Middleware', 'django.middleware.common.CommonMiddleware', 'sumo.middleware.RemoveSlashMiddleware', @@ -409,7 +409,7 @@ def lazy_language_deki_map(): 'kuma.users.middleware.BanMiddleware', 'badger.middleware.RecentBadgeAwardsMiddleware', - 'wiki.badges.BadgeAwardingMiddleware', + 'kuma.wiki.badges.BadgeAwardingMiddleware', ) # Auth @@ -474,7 +474,7 @@ def lazy_language_deki_map(): 'landing', 'search', 'kuma.users', - 'wiki', + 'kuma.wiki', 'kuma.events', # DEMOS @@ -816,7 +816,7 @@ def JINJA_CONFIG(): CELERY_IMPORTS = ( 'devmo.tasks', - 'wiki.tasks', + 'kuma.wiki.tasks', 'search.tasks', 'tidings.events', 'elasticutils.contrib.django.tasks', diff --git a/urls.py b/urls.py index ff828d4ce47..20448971e93 100644 --- a/urls.py +++ b/urls.py @@ -31,14 +31,14 @@ def _error_page(request, status): # Django admin: (r'^grappelli/', include('grappelli.urls')), url(r'^admin/wiki/document/purge/', - 'wiki.admin.purge_view', + 'kuma.wiki.admin.purge_view', name='wiki.admin_bulk_purge'), (r'^admin/', include('smuggler.urls')), (r'^admin/', include(admin.site.urls)), (r'^search', include('search.urls')), - (r'^docs', include('wiki.urls')), + (r'^docs', include('kuma.wiki.urls')), # Javascript translations. url(r'^jsi18n/.*$', cache_page(60 * 60 * 24 * 365)(javascript_catalog), @@ -49,19 +49,19 @@ def _error_page(request, status): # Files. url(r'^files/new/$', - 'wiki.views.new_attachment', + 'kuma.wiki.views.new_attachment', name='wiki.new_attachment'), url(r'^files/(?P\d+)/$', - 'wiki.views.attachment_detail', + 'kuma.wiki.views.attachment_detail', name='wiki.attachment_detail'), url(r'^files/(?P\d+)/edit/$', - 'wiki.views.edit_attachment', + 'kuma.wiki.views.edit_attachment', name='wiki.edit_attachment'), url(r'^files/(?P\d+)/history/$', - 'wiki.views.attachment_history', + 'kuma.wiki.views.attachment_history', name='wiki.attachment_history'), url(r'^files/(?P\d+)/(?P.+)$', - 'wiki.views.raw_file', + 'kuma.wiki.views.raw_file', name='wiki.raw_file'), # Flagged content. @@ -104,7 +104,7 @@ def _error_page(request, status): # with local instances' ability to serve media. urlpatterns += patterns('', url(r'^@api/deki/files/(?P\d+)/=(?P.+)$', - 'wiki.views.mindtouch_file_redirect', + 'kuma.wiki.views.mindtouch_file_redirect', name='wiki.mindtouch_file_redirect'), - (r'^(?P.*)$', 'wiki.views.mindtouch_to_kuma_redirect'), + (r'^(?P.*)$', 'kuma.wiki.views.mindtouch_to_kuma_redirect'), ) From fd509f4d105d134e6479a030038c034bdbb1d1c1 Mon Sep 17 00:00:00 2001 From: James Bennett Date: Mon, 4 Aug 2014 14:34:06 -0400 Subject: [PATCH 02/24] Fix Travis config after merge conflict. --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 244c3a0cc0c..73eb45ba391 100644 --- a/.travis.yml +++ b/.travis.yml @@ -41,7 +41,6 @@ script: after_success: - coveralls ->>>>>>> master notifications: irc: From 183ff71fabf59ba70aede87e230a5f202b88d0dd Mon Sep 17 00:00:00 2001 From: James Bennett Date: Mon, 4 Aug 2014 15:57:13 -0400 Subject: [PATCH 03/24] Fix a stray import. --- kuma/wiki/events.py | 1 - 1 file changed, 1 deletion(-) diff --git a/kuma/wiki/events.py b/kuma/wiki/events.py index c54ed98d6d5..06aee16c7e5 100644 --- a/kuma/wiki/events.py +++ b/kuma/wiki/events.py @@ -5,7 +5,6 @@ from django.core.mail import EmailMessage from django.template import Context, loader -from tidings.events import InstanceEvent from tower import ugettext as _ from devmo import email_utils From 32166926c87f4551bd148095c8a9e719520e6493 Mon Sep 17 00:00:00 2001 From: groovecoder Date: Thu, 31 Jul 2014 17:04:15 -0500 Subject: [PATCH 04/24] remove un-used auth code --- settings.py | 1 - 1 file changed, 1 deletion(-) diff --git a/settings.py b/settings.py index 353d5b61de1..acf4b52e24a 100644 --- a/settings.py +++ b/settings.py @@ -426,7 +426,6 @@ def lazy_language_deki_map(): # Auth AUTHENTICATION_BACKENDS = ( - 'django.contrib.auth.backends.ModelBackend', 'allauth.account.auth_backends.AuthenticationBackend', 'teamwork.backends.TeamworkBackend', ) From 232a0fddf586b41c292dc14e7b446ab0a8b1e43b Mon Sep 17 00:00:00 2001 From: Jannis Leidel Date: Mon, 4 Aug 2014 16:54:38 +0200 Subject: [PATCH 05/24] Updated some account related URLs. - Renamed "social" URL pattern into "account" - Moved URL patterns from allauth to kuma. - Moved authkeys and other URLs into "users/account" namespace Conflicts: kuma/users/providers/github/urls.py --- apps/authkeys/urls.py | 6 ++-- kuma/users/providers/github/urls.py | 5 +++ kuma/users/urls.py | 55 +++++++++++++++++++++++------ urls.py | 3 -- 4 files changed, 53 insertions(+), 16 deletions(-) create mode 100644 kuma/users/providers/github/urls.py diff --git a/apps/authkeys/urls.py b/apps/authkeys/urls.py index 3777d21fa26..c0dcd37d6a6 100644 --- a/apps/authkeys/urls.py +++ b/apps/authkeys/urls.py @@ -2,7 +2,7 @@ urlpatterns = patterns('authkeys.views', url(r'^$', 'list', name='authkeys.list'), - url(r'^new$', 'new', name='authkeys.new'), - url(r'^(?P\d+)/history$', 'history', name='authkeys.history'), - url(r'^(?P\d+)/delete$', 'delete', name='authkeys.delete'), + url(r'^/new$', 'new', name='authkeys.new'), + url(r'^/(?P\d+)/history$', 'history', name='authkeys.history'), + url(r'^/(?P\d+)/delete$', 'delete', name='authkeys.delete'), ) diff --git a/kuma/users/providers/github/urls.py b/kuma/users/providers/github/urls.py new file mode 100644 index 00000000000..aeeeb9569c4 --- /dev/null +++ b/kuma/users/providers/github/urls.py @@ -0,0 +1,5 @@ +from allauth.socialaccount.providers.oauth2.urls import default_urlpatterns + +from .provider import KumaGitHubProvider + +urlpatterns = default_urlpatterns(KumaGitHubProvider) diff --git a/kuma/users/urls.py b/kuma/users/urls.py index c848cd534b4..8fe7d1d0f29 100644 --- a/kuma/users/urls.py +++ b/kuma/users/urls.py @@ -1,28 +1,63 @@ from django.conf.urls import include, patterns, url +from django.utils import importlib + +from allauth.account import views as account_views +from allauth.socialaccount import providers, views as socialaccount_views -from allauth.account.views import login, logout from teamwork.views import user_roles from . import views + +account_patterns = patterns('', + url(r'^signin/cancelled/?$', socialaccount_views.login_cancelled, + name='socialaccount_login_cancelled'), + url(r'^signin/error/?$', socialaccount_views.login_error, + name='socialaccount_login_error'), + url(r'^signup/?$', views.signup, name='socialaccount_signup'), + url(r'^connections/?$', socialaccount_views.connections, + name='socialaccount_connections'), + url(r'^inactive/?$', account_views.account_inactive, + name='account_inactive'), + url(r'^email/?$', account_views.email, name='account_email'), + url(r'^email/confirm/?$', account_views.email_verification_sent, + name='account_email_verification_sent'), + url(r'^email/confirm/(?P\w+)/?$', account_views.confirm_email, + name='account_confirm_email'), + # Auth keys + url(r'^keys', include('authkeys.urls')), +) + + users_patterns = patterns('', - url(r'^social/signup/$', views.signup, name='socialaccount_signup'), - url(r'^', include('allauth.urls')), - url(r"^signin/$", login, name="account_login"), - url(r"^signout/$", logout, name="account_logout"), + url(r'^signup/?$', account_views.signup, name='account_signup'), + url(r'^signin/?$', account_views.login, name='account_login'), + url(r'^signout/?$', account_views.logout, name='account_logout'), + url(r'^account/', include(account_patterns)), url(r'^ban/(?P\d+)$', views.ban_user, name='users.ban_user'), ) + +for provider in providers.registry.get_list(): + try: + prov_mod = importlib.import_module(provider.package + '.urls') + except ImportError: + continue + prov_urlpatterns = getattr(prov_mod, 'urlpatterns', None) + if prov_urlpatterns: + users_patterns += prov_urlpatterns + + urlpatterns = patterns('', url(r'^profiles/(?P[^/]+)/?$', views.profile_view, - name="users.profile"), + name='users.profile'), url(r'^profiles/(?P[^/]+)/roles$', user_roles, - name="users.roles"), + name='users.roles'), url(r'^profiles/(?P[^/]+)/edit$', views.profile_edit, - name="users.profile_edit"), + name='users.profile_edit'), url(r'^profile/?$', views.my_profile, - name="users.my_profile"), + name='users.my_profile'), url(r'^profile/edit/?$', views.my_profile_edit, - name="users.my_profile_edit"), + name='users.my_profile_edit'), url(r'^newsletter/?$', 'kuma.users.views.apps_newsletter', name='users.apps_newsletter'), url(r'^users/', include(users_patterns)), diff --git a/urls.py b/urls.py index 4d164f1ba44..5d202b3c724 100644 --- a/urls.py +++ b/urls.py @@ -72,9 +72,6 @@ def _error_page(request, status): # Users ('', include('kuma.users.urls')), - # Auth keys - (r'^keys/', include('authkeys.urls')), - # Badges (r'^badges/', include('badger.urls_simple')), From f62c5012124f8cf22b8ba2b88f82af3cbac18901 Mon Sep 17 00:00:00 2001 From: David Walsh Date: Tue, 5 Aug 2014 09:23:49 -0500 Subject: [PATCH 06/24] Vertically center icons on homepage maps --- media/redesign/stylus/home.styl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/media/redesign/stylus/home.styl b/media/redesign/stylus/home.styl index 8d0422260f0..8c552381fcf 100644 --- a/media/redesign/stylus/home.styl +++ b/media/redesign/stylus/home.styl @@ -75,7 +75,7 @@ $blue-background-text-color = #fff; } &[class^='icon-']:before { - margin: 16px 0 0 0; + margin: 18px 0 0 0; display: block; text-align: center; } @@ -95,7 +95,7 @@ $blue-background-text-color = #fff; float: left; &:before { - margin: 9px 0 0 0; + margin: 11px 0 0 0; display: block; text-align: center; } From 0c537bd07516f24d15b0bdeecbeaefc20c519adc Mon Sep 17 00:00:00 2001 From: David Walsh Date: Tue, 5 Aug 2014 12:45:52 -0500 Subject: [PATCH 07/24] Fix minor annoyances with login widget --- media/redesign/stylus/main/structure.styl | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/media/redesign/stylus/main/structure.styl b/media/redesign/stylus/main/structure.styl index e5b5b0a045a..4e53ef305a9 100644 --- a/media/redesign/stylus/main/structure.styl +++ b/media/redesign/stylus/main/structure.styl @@ -312,15 +312,15 @@ a.github-button { .oauth-login-container { /* same as user-state, copying down as user-state will go */ bidi-style(right, 200px, left, auto); + set-font-size($small-bump-font-size); position: absolute; top: 12px; - set-font-size($small-bump-font-size); - z-index: 3; cursor: pointer; border-radius: 8px; border: 1px solid transparent; display: inline-block; + overflow: hidden; &.active { border-color: rgba(255, 255, 255, 0.3); @@ -377,18 +377,10 @@ a.github-button { &:hover, &:active, &:focus { background: rgba($link-color, 0.1); } - - &:after { - position: absolute; - top: 6px; - bidi-style(right, 10px, left, auto); - font-family: FontAwesome; - bidi-value(content, "\f0da", "\f0d9"); - opacity: 0.5; - } } {$selector-icon} { + background: none; bidi-style(margin-right, $icon-margin, margin-left, 0); } } From 89d098fdc976a8d23c4d9bf94447ce7eeafacdd1 Mon Sep 17 00:00:00 2001 From: David Walsh Date: Tue, 5 Aug 2014 14:02:51 -0500 Subject: [PATCH 08/24] Use $ for variable in content.styl --- media/redesign/stylus/main/content.styl | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/media/redesign/stylus/main/content.styl b/media/redesign/stylus/main/content.styl index 25946d06e2a..2bf2406397d 100644 --- a/media/redesign/stylus/main/content.styl +++ b/media/redesign/stylus/main/content.styl @@ -3,7 +3,7 @@ We cannot put these styles in the tags.styl file because they don't apply to the entire layout */ -table-blue = #d4dde4; +$table-blue = #d4dde4; .text-content { @@ -32,15 +32,15 @@ table-blue = #d4dde4; border: 2px solid #fff; td { - background-color: rgba(table-blue, 0.15); + background-color: rgba($table-blue, 0.15); border: @border; - box-shadow: inset 0 -1px 0 0 rgba(table-blue, 0.5); + box-shadow: inset 0 -1px 0 0 rgba($table-blue, 0.5); } td.header, th { border: @border; - border-bottom: 2px solid rgba(table-blue, 1); - background: rgba(table-blue, 0.5); + border-bottom: 2px solid rgba($table-blue, 1); + background: rgba($table-blue, 0.5); font-family: 'Open Sans Light', sans-serif; font-size: 14px; padding: 2px 8px 4px; @@ -50,7 +50,7 @@ table-blue = #d4dde4; &.fullwidth-table { background: #fff; - border: 1px solid rgba(table-blue, 0.5); + border: 1px solid rgba($table-blue, 0.5); margin-bottom: $grid-spacing; width: 100%; @@ -62,8 +62,8 @@ table-blue = #d4dde4; } td.header, th { - background: rgba(table-blue, 0.5); - border: 1px solid rgba(table-blue, 1); + background: rgba($table-blue, 0.5); + border: 1px solid rgba($table-blue, 1); font-weight: bold; padding: 0 5px; } @@ -78,7 +78,7 @@ table-blue = #d4dde4; } thead th { - background: rgba(table-blue, 0.5); + background: rgba($table-blue, 0.5); } /* lists and definitions */ From d8b7b8042c52834814692f67ffe22daa8320f811 Mon Sep 17 00:00:00 2001 From: udeepak Date: Wed, 6 Aug 2014 08:36:26 +0530 Subject: [PATCH 09/24] Delete "The Basics of HTML" link. Please delete the "The Basics of HTML" link as the link is broken and is causing a 404 error. --- apps/landing/templates/landing/learn_html.html | 5 ----- 1 file changed, 5 deletions(-) diff --git a/apps/landing/templates/landing/learn_html.html b/apps/landing/templates/landing/learn_html.html index c4d88791b83..932a131916e 100644 --- a/apps/landing/templates/landing/learn_html.html +++ b/apps/landing/templates/landing/learn_html.html @@ -28,11 +28,6 @@

    {{ _('Learn HTML') }}

    {{ _('Introductory Level') }}

    From d3bdc8338fb2f098be7f2007c8c36855a38b179f Mon Sep 17 00:00:00 2001 From: David Walsh Date: Mon, 4 Aug 2014 14:54:03 -0500 Subject: [PATCH 18/24] Remove unused cells from attachment list --- kuma/wiki/templates/wiki/includes/attachment_list.html | 2 -- media/js/wiki-edit.js | 4 ---- 2 files changed, 6 deletions(-) diff --git a/kuma/wiki/templates/wiki/includes/attachment_list.html b/kuma/wiki/templates/wiki/includes/attachment_list.html index b52d39cbf89..5d139d86887 100644 --- a/kuma/wiki/templates/wiki/includes/attachment_list.html +++ b/kuma/wiki/templates/wiki/includes/attachment_list.html @@ -41,7 +41,6 @@

    {{ _('Attachments') }}

    - {{ attachment_form.file | safe }} {{ attachment_form.title | safe }} {{ attachment_form.description | safe }} diff --git a/media/js/wiki-edit.js b/media/js/wiki-edit.js index 41095314f38..155f3afaf2a 100644 --- a/media/js/wiki-edit.js +++ b/media/js/wiki-edit.js @@ -711,10 +711,6 @@ $clone.insertBefore($attachmentsNewTableActions); $clone.addClass('dynamic-row'); - // Show the cell actions now! - $attachmentsNewTable.find('.page-attachment-actions-cell').removeClass('hidden'); - $clone.find('.delete-attachment').removeClass('hidden'); - return $clone; } clone().find('input[type="text"]')[0].focus(); From 71cda3b1d7d75ba58b774d23ed0800da87f8e98b Mon Sep 17 00:00:00 2001 From: David Walsh Date: Wed, 6 Aug 2014 21:04:33 -0500 Subject: [PATCH 19/24] Single quotes for stylus files --- media/redesign/stylus/badges.styl | 2 +- media/redesign/stylus/home.styl | 4 ++-- media/redesign/stylus/includes/grid.styl | 2 +- media/redesign/stylus/includes/mixins.styl | 2 +- media/redesign/stylus/learn.styl | 22 +++++++++++----------- media/redesign/stylus/main/content.styl | 4 ++-- media/redesign/stylus/main/tags.styl | 6 +++--- media/redesign/stylus/profile.styl | 6 +++--- media/redesign/stylus/search.styl | 2 +- media/redesign/stylus/submission.styl | 2 +- media/redesign/stylus/wiki.styl | 10 +++++----- 11 files changed, 31 insertions(+), 31 deletions(-) diff --git a/media/redesign/stylus/badges.styl b/media/redesign/stylus/badges.styl index 83b9d23d0d1..d5bf78f8ad0 100644 --- a/media/redesign/stylus/badges.styl +++ b/media/redesign/stylus/badges.styl @@ -188,7 +188,7 @@ dl.award dd.awarded_to img.avatar { display: none; } -input[type="submit"].delete-badge { +input[type='submit'].delete-badge { margin: 0 auto; display: inherit; } diff --git a/media/redesign/stylus/home.styl b/media/redesign/stylus/home.styl index 8c552381fcf..a4e8cedd555 100644 --- a/media/redesign/stylus/home.styl +++ b/media/redesign/stylus/home.styl @@ -356,7 +356,7 @@ $blue-background-text-color = #fff; /* In right-to-left languages, show some carousel items in reverse order and hide the pager. This is not a permanent solution, https://bugzilla.mozilla.org/show_bug.cgi?id=992745 */ - html[dir="rtl"] & { + html[dir='rtl'] & { .owl-item { float: right; } @@ -516,7 +516,7 @@ $blue-background-text-color = #fff; } /* right to left */ -html[dir="rtl"] #home { +html[dir='rtl'] #home { h2 { > $selector-icon:before { diff --git a/media/redesign/stylus/includes/grid.styl b/media/redesign/stylus/includes/grid.styl index 2f1bda4a580..166d7dca7a1 100644 --- a/media/redesign/stylus/includes/grid.styl +++ b/media/redesign/stylus/includes/grid.styl @@ -91,7 +91,7 @@ draw-grid() { } /* adjustments to reverse the column containers in RTL */ - html[dir="rtl"] .column-container { + html[dir='rtl'] .column-container { {$grid-column-selector} { &:first-child { margin-right: 0; diff --git a/media/redesign/stylus/includes/mixins.styl b/media/redesign/stylus/includes/mixins.styl index 9d514ced272..5f3c552a430 100644 --- a/media/redesign/stylus/includes/mixins.styl +++ b/media/redesign/stylus/includes/mixins.styl @@ -227,7 +227,7 @@ bidi-style(ltr-prop, value, inverse-prop, inverse-value, make-important = false) {ltr-prop}: value make-important; - html[dir="rtl"] & { + html[dir='rtl'] & { if (ltr-prop != inverse-prop) { {inverse-prop}: value make-important; } diff --git a/media/redesign/stylus/learn.styl b/media/redesign/stylus/learn.styl index 811f56b8278..df69efdd5e1 100644 --- a/media/redesign/stylus/learn.styl +++ b/media/redesign/stylus/learn.styl @@ -13,7 +13,7 @@ text-align: left; a:before { - content: "\00AB\00A0"; + content: '\00AB\00A0'; } } @@ -44,14 +44,14 @@ } #blackboard { - background: #242424 url("../img/boardframe-top.jpg") center top no-repeat; + background: #242424 url('../img/boardframe-top.jpg') center top no-repeat; box-shadow: 0 2px 3px rgba(0,0,0,.25); margin: $grid-spacing auto; padding: 60px 0 0; width: 940px; ul { - background: url("../img/boardframe-btm.png") center bottom no-repeat; + background: url('../img/boardframe-btm.png') center bottom no-repeat; overflow: auto; padding: 0 60px 50px 0; @@ -100,15 +100,15 @@ h2 { #sub-html & { - background-image: url("../img/chalk-html.png"); + background-image: url('../img/chalk-html.png'); } #sub-css & { - background-image: url("../img/chalk-css.png"); + background-image: url('../img/chalk-css.png'); } #sub-js & { - background-image: url("../img/chalk-js.png"); + background-image: url('../img/chalk-js.png'); } } @@ -142,8 +142,8 @@ h2 { position: absolute; top: $grid-spacing; left: $grid-spacing; - background: url("../img/p2pu-webcraft.png") no-repeat 0 0; - content: ""; + background: url('../img/p2pu-webcraft.png') no-repeat 0 0; + content: ''; height: 80px; width: 101px; } @@ -156,7 +156,7 @@ h2 { } .learn-module h2 { - background: url("../img/icons-learnlevels.png") no-repeat; + background: url('../img/icons-learnlevels.png') no-repeat; color: #a36100; min-height: 56px; padding: 12px 18px 0 68px; @@ -195,7 +195,7 @@ h2 { position: absolute; top: -1px; left: 0; - background: url("../img/icons-tags.png") 0 0 no-repeat; + background: url('../img/icons-tags.png') 0 0 no-repeat; content: ''; height: 17px; width: 14px; @@ -242,7 +242,7 @@ h2 { visibility: hidden; width: 340px; vendorize(transition, bottom .4s ease-out); - vendorize(transition-property, unquote("bottom, opacity, visibility")); + vendorize(transition-property, unquote('bottom, opacity, visibility')); } &.visible .bubble { diff --git a/media/redesign/stylus/main/content.styl b/media/redesign/stylus/main/content.styl index 2bf2406397d..260473fa307 100644 --- a/media/redesign/stylus/main/content.styl +++ b/media/redesign/stylus/main/content.styl @@ -241,7 +241,7 @@ ul.tagit { } .ui-icon-close { - background: url("../img/icn-delete.png") center -96px no-repeat; + background: url('../img/icn-delete.png') center -96px no-repeat; cursor: pointer; display: inline-block; height: 15px; @@ -333,7 +333,7 @@ div.tip { /* Classes created by the WYSIWYG */ .twocolumns { - vendorize(column-count, 2) + vendorize(column-count, 2); } .threecolumns { vendorize(column-count, 3); diff --git a/media/redesign/stylus/main/tags.styl b/media/redesign/stylus/main/tags.styl index 2bb5e5daf79..97314e8b6c3 100644 --- a/media/redesign/stylus/main/tags.styl +++ b/media/redesign/stylus/main/tags.styl @@ -32,13 +32,13 @@ blockquote { &:before { top: 0; left: 10px; - content: "\201C"; + content: '\201C'; } &:after { bottom: 0; right: 10px; - content: "\201D"; + content: '\201D'; } } @@ -257,7 +257,7 @@ a.button:hover, a.button:focus, a.button:active { @media print { /* Not a pretty selector but needed to keep Prism in check */ - pre, pre[class*="language-"], code { + pre, pre[class*='language-'], code { white-space: pre-wrap; &, & span { diff --git a/media/redesign/stylus/profile.styl b/media/redesign/stylus/profile.styl index e676ecf538f..d16d930425b 100644 --- a/media/redesign/stylus/profile.styl +++ b/media/redesign/stylus/profile.styl @@ -76,12 +76,12 @@ &:before { color: #a19f93; - content: "/"; + content: '/'; margin-right: @margin-right; } &:first-child:before { - content: ""; + content: ''; margin: 0; } } @@ -198,7 +198,7 @@ table.activity { .profile-edit { /* Set forms to full width so that they resize with the column. */ - .section li > input[type="text"], select, textarea, #tagit-interests, #tags-expertise, legend { + .section li > input[type='text'], select, textarea, #tagit-interests, #tags-expertise, legend { width: 100%; vendorize(box-sizing, border-box); } diff --git a/media/redesign/stylus/search.styl b/media/redesign/stylus/search.styl index d01f03f8e59..273beee8b1f 100644 --- a/media/redesign/stylus/search.styl +++ b/media/redesign/stylus/search.styl @@ -146,7 +146,7 @@ h3 {$selector-icon}, fieldset {$selector-icon} { margin-right: 7px; } &:hover .filter-name, - input[type="checkbox"]:focus+ .filter-name{ + input[type='checkbox']:focus+ .filter-name{ color: $link-color; } diff --git a/media/redesign/stylus/submission.styl b/media/redesign/stylus/submission.styl index fe82cfdbc36..5ce6b2ab3b2 100644 --- a/media/redesign/stylus/submission.styl +++ b/media/redesign/stylus/submission.styl @@ -77,7 +77,7 @@ } } - input[type="url"], input[type="email"], input[type="text"] { + input[type='url'], input[type='email'], input[type='text'] { width: 450px; } diff --git a/media/redesign/stylus/wiki.styl b/media/redesign/stylus/wiki.styl index 44e311c58dd..2f57c8c0105 100644 --- a/media/redesign/stylus/wiki.styl +++ b/media/redesign/stylus/wiki.styl @@ -196,7 +196,7 @@ article { .external-icon:not([href^='https://mdn.mozillademos.org']) { white-space: pre-line; - html[dir="ltr"] &:before, html[dir="rtl"] &:after { + html[dir='ltr'] &:before, html[dir='rtl'] &:after { content: '\f08e'; font-family: FontAwesome; set-font-size(9px); @@ -205,7 +205,7 @@ article { margin-right: 3px; } - html[dir="rtl"] &:after { + html[dir='rtl'] &:after { transform: rotateY(180deg); } @@ -1153,7 +1153,7 @@ div.note { } #page-attachments-new-table { - input[type="text"] { + input[type='text'] { width: 90%; .attachment-required { @@ -1202,13 +1202,13 @@ details { summary:before { set-font-size(1.25em); bidi-value(float, left, right); - content: "+"; + content: '+'; margin-top: -.15em; bidi-style(margin-left, -15px, margin-right, 0); } &.open summary:before { - content: "–"; + content: '–'; margin-top: -.2em; bidi-style(margin-left, -13px, margin-right, 0); } From 936ae2c80ec9f72b945a3e0a4f5770b5f476c651 Mon Sep 17 00:00:00 2001 From: groovecoder Date: Thu, 7 Aug 2014 12:11:45 -0500 Subject: [PATCH 20/24] bug 775485 - remove extra IRC link from html email --- kuma/users/templates/users/email/welcome/html.ltxt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kuma/users/templates/users/email/welcome/html.ltxt b/kuma/users/templates/users/email/welcome/html.ltxt index 5b527e9f678..b3f6341f931 100644 --- a/kuma/users/templates/users/email/welcome/html.ltxt +++ b/kuma/users/templates/users/email/welcome/html.ltxt @@ -44,7 +44,7 @@ channel_link='irc://irc.mozilla.org/mdn', irc_link=add_utm('https://wiki.mozilla.org/IRC', 'welcome') %} - Real-time chat: #mdn channel on irc.mozilla.org. (Get more info about IRC.) You can find the MDN writing staff admins there: Eric Shepherd (sheppy), Jean-Yves Perrier (teoli), Will Bamberg (wbamberg), Florian Scholz (fscholz), Chris Mills (chrismills), and community manager Janet Swisher (jms). + Real-time chat: #mdn channel on irc.mozilla.org. You can find the MDN writing staff admins there: Eric Shepherd (sheppy), Jean-Yves Perrier (teoli), Will Bamberg (wbamberg), Florian Scholz (fscholz), Chris Mills (chrismills), and community manager Janet Swisher (jms). {% endtrans %}
  • From 4dec719dc8bb89502f4e5a127a4fd6e138a4dfa6 Mon Sep 17 00:00:00 2001 From: groovecoder Date: Thu, 7 Aug 2014 12:18:04 -0500 Subject: [PATCH 21/24] updates from Janet "The Swish" Swisher --- kuma/users/templates/users/email/welcome/html.ltxt | 2 +- kuma/users/templates/users/email/welcome/plain.ltxt | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/kuma/users/templates/users/email/welcome/html.ltxt b/kuma/users/templates/users/email/welcome/html.ltxt index b3f6341f931..07bb8aaa478 100644 --- a/kuma/users/templates/users/email/welcome/html.ltxt +++ b/kuma/users/templates/users/email/welcome/html.ltxt @@ -44,7 +44,7 @@ channel_link='irc://irc.mozilla.org/mdn', irc_link=add_utm('https://wiki.mozilla.org/IRC', 'welcome') %} - Real-time chat: #mdn channel on irc.mozilla.org. You can find the MDN writing staff admins there: Eric Shepherd (sheppy), Jean-Yves Perrier (teoli), Will Bamberg (wbamberg), Florian Scholz (fscholz), Chris Mills (chrismills), and community manager Janet Swisher (jms). + Real-time chat: #mdn channel on irc.mozilla.org. (Get more info about IRC.) You can find the MDN writing staff admins there: Eric Shepherd (sheppy), Jean-Yves Perrier (teoli), Will Bamberg (wbamberg), Florian Scholz (fscholz), Chris Mills (chrismills), and me (jms), MDN's community manager. {% endtrans %}
  • diff --git a/kuma/users/templates/users/email/welcome/plain.ltxt b/kuma/users/templates/users/email/welcome/plain.ltxt index d4b9e5494c9..6a019f1510f 100644 --- a/kuma/users/templates/users/email/welcome/plain.ltxt +++ b/kuma/users/templates/users/email/welcome/plain.ltxt @@ -51,8 +51,8 @@ Want to talk to someone about MDN? There are a few ways you can do that: You can find the MDN writing staff admins there: Eric Shepherd (sheppy), Jean-Yves Perrier (teoli), Will Bamberg (wbamberg), - Florian Scholz (fscholz), Chris Mills (chrismills), and - community manager Janet Swisher (jms). + Florian Scholz (fscholz), Chris Mills (chrismills), and + me (jms), MDN's community manager. * Blog: {{ blog_link }} {% endtrans %} From df7f962c18bba812a7afea824846b68123054423 Mon Sep 17 00:00:00 2001 From: groovecoder Date: Thu, 7 Aug 2014 17:08:02 -0500 Subject: [PATCH 22/24] remove sumo.parser --- apps/sumo/helpers.py | 7 - apps/sumo/parser.py | 231 -------------- apps/sumo/tests/test_parser.py | 545 --------------------------------- 3 files changed, 783 deletions(-) delete mode 100644 apps/sumo/parser.py delete mode 100644 apps/sumo/tests/test_parser.py diff --git a/apps/sumo/helpers.py b/apps/sumo/helpers.py index 115613eac58..96f1d6b327c 100644 --- a/apps/sumo/helpers.py +++ b/apps/sumo/helpers.py @@ -17,7 +17,6 @@ from pytz import timezone from tower import ugettext_lazy as _lazy, ungettext -import sumo.parser from sumo.urlresolvers import reverse @@ -69,12 +68,6 @@ def urlparams(url_, hash=None, query_dict=None, **query): return new.geturl() -@register.filter -def wiki_to_html(wiki_markup, locale=settings.WIKI_DEFAULT_LANGUAGE): - """Wiki Markup -> HTML jinja2.Markup object""" - return jinja2.Markup(sumo.parser.wiki_to_html(wiki_markup, locale=locale)) - - class Paginator(object): def __init__(self, pager): diff --git a/apps/sumo/parser.py b/apps/sumo/parser.py deleted file mode 100644 index 20aed7d4247..00000000000 --- a/apps/sumo/parser.py +++ /dev/null @@ -1,231 +0,0 @@ -from django.conf import settings - -import jingo -from tower import ugettext_lazy as _lazy -from wikimarkup.parser import Parser - -from sumo.urlresolvers import reverse - - -ALLOWED_ATTRIBUTES = { - 'a': ['href', 'title', 'class', 'rel'], - 'div': ['id', 'class', 'style', 'data-for', 'title', 'data-target', - 'data-modal'], - 'h1': ['id'], - 'h2': ['id'], - 'h3': ['id'], - 'h4': ['id'], - 'h5': ['id'], - 'h6': ['id'], - 'li': ['class'], - 'span': ['class', 'data-for'], - 'img': ['class', 'src', 'alt', 'title', 'height', 'width', 'style'], - 'video': ['height', 'width', 'controls', 'data-fallback', 'poster'], - 'source': ['src', 'type'], -} -IMAGE_PARAMS = ['alt', 'align', 'caption', 'valign', 'frame', 'page', 'link', - 'width', 'height'] -IMAGE_PARAM_VALUES = { - 'align': ('none', 'left', 'center', 'right'), - 'valign': ('baseline', 'sub', 'super', 'top', 'text-top', 'middle', - 'bottom', 'text-bottom'), -} - - -def wiki_to_html(wiki_markup, locale=settings.WIKI_DEFAULT_LANGUAGE): - """Wiki Markup -> HTML""" - return WikiParser().parse(wiki_markup, show_toc=False, locale=locale) - - -def get_object_fallback(cls, title, locale, default=None, **kwargs): - """Return an instance of cls matching title and locale, or fall back to the - default locale. - - When falling back to the default locale, follow any wiki redirects - internally. - - If the fallback fails, the return value is `default`. - - You may pass in additional kwargs which go straight to the query. - - """ - try: - return cls.objects.get(title=title, locale=locale, **kwargs) - except cls.DoesNotExist: - pass - - # Fallback - try: - default_lang_doc = cls.objects.get( - title=title, locale=settings.WIKI_DEFAULT_LANGUAGE, **kwargs) - - # Return the translation of this English item: - if hasattr(default_lang_doc, 'translated_to'): - trans = default_lang_doc.translated_to(locale) - if trans and trans.current_revision: - return trans - - # Follow redirects internally in an attempt to find a translation of - # the final redirect target in the requested locale. This happens a lot - # when an English article is renamed and a redirect is left in its - # wake: we wouldn't want the non-English user to be linked to the - # English redirect, which would happily redirect them to the English - # final article. - if hasattr(default_lang_doc, 'redirect_document'): - target = default_lang_doc.redirect_document() - if target: - trans = target.translated_to(locale) - if trans and trans.current_revision: - return trans - - # Return the English item: - return default_lang_doc - # Okay, all else failed - except cls.DoesNotExist: - return default - - -def _get_wiki_link(title, locale): - """Checks the page exists, and returns its URL or the URL to create it. - - Return value is a dict: {'found': boolean, 'url': string}. - found is False if the document does not exist. - - """ - from kuma.wiki.models import Document - d = get_object_fallback(Document, locale=locale, title=title, - is_template=False) - if d: - return {'found': True, 'url': d.get_absolute_url(), 'text': d.title} - - # To avoid circular imports, wiki.models imports wiki_to_html - from sumo.helpers import urlparams - return {'found': False, - 'text': title, - 'url': urlparams(reverse('wiki.new_document', locale=locale), - title=title)} - - -def build_hook_params(string, locale, allowed_params=[], - allowed_param_values={}): - """Parses a string of the form 'some-title|opt1|opt2=arg2|opt3...' - - Builds a list of items and returns relevant parameters in a dict. - - """ - if not '|' in string: # No params? Simple and easy. - string = string.strip() - return (string, {'alt': string}) - - items = [i.strip() for i in string.split('|')] - title = items.pop(0) - params = {} - - last_item = '' - for item in items: # this splits by = or assigns the dict key to True - if '=' in item: - param, value = item.split('=', 1) - params[param] = value - else: - params[item] = True - last_item = item - - if 'caption' in allowed_params: - params['caption'] = title - # Allowed parameters are not caption. All else is. - if last_item and last_item not in allowed_params: - params['caption'] = items.pop() - del params[last_item] - elif last_item == 'caption': - params['caption'] = last_item - - # Validate params allowed - for p in params.keys(): - if p not in allowed_params: - del params[p] - - # Validate params with limited # of values - for p in allowed_param_values: - if p in params and params[p] not in allowed_param_values[p]: - del params[p] - - # Handle page as a special case - if 'page' in params and params['page'] is not True: - link = _get_wiki_link(params['page'], locale) - params['link'] = link['url'] - params['found'] = link['found'] - - return (title, params) - - -class WikiParser(Parser): - """Wrapper for wikimarkup which adds Kitsune-specific callbacks and setup. - """ - - def __init__(self, base_url=None): - super(WikiParser, self).__init__(base_url) - - # Register default hooks - self.registerInternalLinkHook(None, self._hook_internal_link) - self.registerInternalLinkHook('Image', self._hook_image_tag) - - def parse(self, text, show_toc=None, tags=None, attributes=None, - locale=settings.WIKI_DEFAULT_LANGUAGE): - """Given wiki markup, return HTML. - - Pass a locale to get all the hooks to look up Documents or Media - (Video, Image) for that locale. We key Documents by title and locale, - so both are required to identify it for a e.g. link. - - Since py-wikimarkup's hooks don't offer custom paramters for callbacks, - we're using self.locale to keep things simple.""" - self.locale = locale - - parser_kwargs = {'tags': tags} if tags else {} - return super(WikiParser, self).parse(text, show_toc=show_toc, - attributes=attributes or ALLOWED_ATTRIBUTES, **parser_kwargs) - - def _hook_internal_link(self, parser, space, name): - """Parses text and returns internal link.""" - text = False - title = name - - # Split on pipe -- [[href|name]] - if '|' in name: - title, text = title.split('|', 1) - - hash = '' - if '#' in title: - title, hash = title.split('#', 1) - - # Sections use _, page names use + - if hash != '': - hash = '#' + hash.replace(' ', '_') - - # Links to this page can just contain href="#hash" - if title == '' and hash != '': - if not text: - text = hash.replace('_', ' ') - return u'%s' % (hash, text) - - link = _get_wiki_link(title, self.locale) - a_cls = '' - if not link['found']: - a_cls = ' class="new"' - if not text: - text = link['text'] - return u'%s' % (link['url'], hash, a_cls, text) - - def _hook_image_tag(self, parser, space, name): - """Adds syntax for inserting images.""" - title, params = build_hook_params(name, self.locale, IMAGE_PARAMS, - IMAGE_PARAM_VALUES) - - message = _lazy(u'The image "%s" does not exist.') % title - image = get_object_fallback(Image, title, self.locale, message) - if isinstance(image, basestring): - return image - - template = jingo.env.get_template('wikiparser/hook_image.html') - r_kwargs = {'image': image, 'params': params} - return template.render(**r_kwargs) diff --git a/apps/sumo/tests/test_parser.py b/apps/sumo/tests/test_parser.py deleted file mode 100644 index 043a9bb6aba..00000000000 --- a/apps/sumo/tests/test_parser.py +++ /dev/null @@ -1,545 +0,0 @@ -from functools import partial - -from django.conf import settings - -from nose.tools import eq_ -from pyquery import PyQuery as pq - -from gallery.tests import image -from sumo.parser import (WikiParser, build_hook_params, _get_wiki_link, - get_object_fallback, IMAGE_PARAMS, IMAGE_PARAM_VALUES) -from sumo.tests import TestCase -from wiki.models import Document -from wiki.tests import document, revision - - -def pq_link(p, text): - return pq(p.parse(text))('a') - - -def pq_img(p, text, selector='img', locale=settings.WIKI_DEFAULT_LANGUAGE): - doc = pq(p.parse(text, locale=locale)) - return doc(selector) - - -def doc_rev_parser(content, title='Installing Firefox', parser_cls=WikiParser): - p = parser_cls() - d = document(title=title) - d.save() - r = revision(document=d, content=content, is_approved=True) - r.save() - return (d, r, p) - - -build_hook_params_default = partial(build_hook_params, - locale=settings.WIKI_DEFAULT_LANGUAGE, - allowed_params=IMAGE_PARAMS, - allowed_param_values=IMAGE_PARAM_VALUES) - - -class GetObjectFallbackTests(TestCase): - fixtures = ['users.json'] - - def test_empty(self): - """get_object_fallback returns message when no objects.""" - # English does not exist - obj = get_object_fallback(Document, 'A doc', 'en-US', '!') - eq_('!', obj) - - def test_english(self): - # Create the English document - d = document(title='A doc') - d.save() - # Now it exists - obj = get_object_fallback(Document, 'A doc', 'en-US', '!') - eq_(d, obj) - - def test_from_french(self): - # Create the English document - d = document(title='A doc') - d.save() - # Returns English document for French - obj = get_object_fallback(Document, 'A doc', 'fr', '!') - eq_(d, obj) - - def test_french(self): - # Create English parent document - en_d = document() - en_d.save() - en_r = revision(document=en_d, is_approved=True) - en_r.save() - - # Create the French document - fr_d = document(parent=en_d, title='A doc', locale='fr') - fr_d.save() - obj = get_object_fallback(Document, 'A doc', 'fr', '!') - eq_(fr_d, obj) - - # Also works when English exists - d = document(title='A doc') - d.save() - obj = get_object_fallback(Document, 'A doc', 'fr', '!') - eq_(fr_d, obj) - - def test_translated(self): - """If a localization of the English fallback exists, use it.""" - - en_d = document(title='A doc') - en_d.save() - en_r = revision(document=en_d, is_approved=True) - en_r.save() - - fr_d = document(parent=en_d, title='Une doc', locale='fr') - fr_d.save() - - # Without an approved revision, the en-US doc should be returned. - obj = get_object_fallback(Document, 'A doc', 'fr') - eq_(en_d, obj) - - # Approve a revision, then fr doc should be returned. - fr_r = revision(document=fr_d, is_approved=True) - fr_r.save() - obj = get_object_fallback(Document, 'A doc', 'fr') - eq_(fr_d, obj) - - def test_redirect(self): - """Assert get_object_fallback follows wiki redirects.""" - target_rev = revision( - document=document(title='target', save=True), - is_approved=True, - save=True) - translated_target_rev = revision( - document=document(parent=target_rev.document, locale='de', - save=True), - is_approved=True, - save=True) - revision( - document=document(title='redirect', save=True), - content='REDIRECT [[target]]', - is_approved=True).save() - - eq_(translated_target_rev.document, - get_object_fallback(Document, 'redirect', 'de')) - - def test_redirect_translations_only(self): - """Make sure get_object_fallback doesn't follow redirects when working - purely in the default language. - - That would make it hard to navigate to redirects (to edit them, for - example). - - """ - revision(document=document(title='target', save=True), - content='O hai.', - is_approved=True).save() - redirect_rev = revision(document=document(title='redirect', save=True), - content='REDIRECT [[target]]', - is_approved=True, - save=True) - eq_(redirect_rev.document, - get_object_fallback(Document, 'redirect', - redirect_rev.document.locale)) - - -class TestWikiParser(TestCase): - fixtures = ['users.json'] - - def setUp(self): - self.d, self.r, self.p = doc_rev_parser( - 'Test content', 'Installing Firefox') - - def test_image_params_page(self): - """build_hook_params handles wiki pages.""" - _, params = build_hook_params_default('t|page=Installing Firefox') - eq_('/en-US/kb/installing-firefox', params['link']) - assert params['found'] - - def test_image_params_link(self): - """_build_image_params handles external links.""" - _, params = build_hook_params_default('t|link=http://example.com') - eq_('http://example.com', params['link']) - - def test_image_params_page_link(self): - """_build_image_params - wiki page overrides link.""" - text = 't|page=Installing Firefox|link=http://example.com' - _, params = build_hook_params_default(text) - eq_('/en-US/kb/installing-firefox', params['link']) - - def test_image_params_align(self): - """Align valid options.""" - align_vals = ('none', 'left', 'center', 'right') - for align in align_vals: - _, params = build_hook_params_default('test.jpg|align=' + align) - eq_(align, params['align']) - - def test_image_params_align_invalid(self): - """Align invalid options.""" - _, params = build_hook_params_default('align=zzz') - assert not 'align' in params, 'Align is present in params' - - def test_image_params_valign(self): - """Vertical align valid options.""" - valign_vals = ('baseline', 'sub', 'super', 'top', 'text-top', - 'middle', 'bottom', 'text-bottom') - for valign in valign_vals: - _, params = build_hook_params_default('title|valign=' + valign) - eq_(valign, params['valign']) - - def test_image_params_valign_invalid(self): - """Vertical align invalid options.""" - _, params = build_hook_params_default('valign=zzz') - assert not 'valign' in params, 'Vertical align is present in params' - - def test_image_params_alt(self): - """Image alt override.""" - _, params = build_hook_params_default('t|alt=some alternative text') - eq_('some alternative text', params['alt']) - - def test_image_params_frame(self): - """Framed image.""" - _, params = build_hook_params_default('title|frame') - assert params['frame'] - - def test_image_params_width_height(self): - """Image width.""" - _, params = build_hook_params_default('t|width=10|height=20') - eq_('10', params['width']) - eq_('20', params['height']) - - def test_get_wiki_link(self): - """Wiki links are properly built for existing pages.""" - eq_({'found': True, 'url': '/en-US/kb/installing-firefox', - 'text': 'Installing Firefox'}, - _get_wiki_link('Installing Firefox', - locale=settings.WIKI_DEFAULT_LANGUAGE)) - - def test_showfor(self): - """ tags should be escaped, not obeyed.""" - eq_('

    <showfor>smoo</showfor>

    ', - self.p.parse('smoo').replace('\n', '')) - - -class TestWikiInternalLinks(TestCase): - fixtures = ['users.json'] - - def setUp(self): - self.d, self.r, self.p = doc_rev_parser( - 'Test content', 'Installing Firefox') - - def test_simple(self): - """Simple internal link markup.""" - link = pq_link(self.p, '[[Installing Firefox]]') - eq_('/en-US/kb/installing-firefox', link.attr('href')) - eq_('Installing Firefox', link.text()) - assert not link.hasClass('new') - - def test_simple_markup(self): - text = '[[Installing Firefox]]' - eq_('

    ' + - 'Installing Firefox

    ', - self.p.parse(text).replace('\n', '')) - - def test_link_hash(self): - """Internal link with hash.""" - link = pq_link(self.p, '[[Installing Firefox#section name]]') - eq_('/en-US/kb/installing-firefox#section_name', link.attr('href')) - eq_('Installing Firefox', link.text()) - - def test_link_hash_text(self): - """Internal link with hash and text.""" - link = pq_link(self.p, '[[Installing Firefox#section name|section]]') - eq_('/en-US/kb/installing-firefox#section_name', link.attr('href')) - eq_('section', link.text()) - - def test_hash_only(self): - """Internal hash only.""" - link = pq_link(self.p, '[[#section 3]]') - eq_('#section_3', link.attr('href')) - eq_('#section 3', link.text()) - - def test_link_name(self): - """Internal link with name.""" - link = pq_link(self.p, '[[Installing Firefox|this name]]') - eq_('/en-US/kb/installing-firefox', link.attr('href')) - eq_('this name', link.text()) - - def test_link_with_extra_pipe(self): - link = pq_link(self.p, '[[Installing Firefox|with|pipe]]') - eq_('/en-US/kb/installing-firefox', link.attr('href')) - eq_('with|pipe', link.text()) - - def test_hash_name(self): - """Internal hash with name.""" - link = pq_link(self.p, '[[#section 3|this name]]') - eq_('#section_3', link.attr('href')) - eq_('this name', link.text()) - assert not link.hasClass('new') - - def test_link_hash_name(self): - """Internal link with hash and name.""" - link = pq_link(self.p, '[[Installing Firefox#section 3|this name]]') - eq_('/en-US/kb/installing-firefox#section_3', link.attr('href')) - eq_('this name', link.text()) - - def test_link_hash_name_markup(self): - """Internal link with hash and name.""" - text = '[[Installing Firefox#section 3|this name]]' - eq_('

    this name\n

    ', self.p.parse(text)) - - def test_simple_create(self): - """Simple link for inexistent page.""" - link = pq_link(self.p, '[[A new page]]') - assert link.hasClass('new') - eq_('/en-US/kb/new?title=A+new+page', link.attr('href')) - eq_('A new page', link.text()) - - def test_link_edit_hash_name(self): - """Internal link for inexistent page with hash and name.""" - link = pq_link(self.p, '[[A new page#section 3|this name]]') - eq_('/en-US/kb/new?title=A+new+page#section_3', link.attr('href')) - eq_('this name', link.text()) - - def test_link_with_localization(self): - """A link to an English doc with a local translation.""" - en_d = document(title='A doc') - en_d.save() - en_r = revision(document=en_d, is_approved=True) - en_r.save() - - fr_d = document(parent=en_d, title='Une doc', locale='fr') - fr_d.save() - - # Without an approved revision, link should go to en-US doc. - link = pq(self.p.parse('[[A doc]]', locale='fr')) - eq_('/en-US/kb/a-doc', link.find('a').attr('href')) - eq_('A doc', link.find('a').text()) - - # Approve a revision. Now link should go to fr doc. - fr_r = revision(document=fr_d, is_approved=True) - fr_r.save() - link = pq(self.p.parse('[[A doc]]', locale='fr')) - eq_('/fr/kb/une-doc', link.find('a').attr('href')) - eq_('Une doc', link.find('a').text()) - - -class TestWikiImageTags(TestCase): - fixtures = ['users.json'] - - def setUp(self): - self.d, self.r, self.p = doc_rev_parser( - 'Test content', 'Installing Firefox') - self.img = image(title='test.jpg') - - def tearDown(self): - self.img.delete() - - def test_empty(self): - """Empty image tag markup does not change.""" - img = pq_img(self.p, '[[Image:]]', 'p') - eq_('The image "" does not exist.', img.text()) - - def test_simple(self): - """Simple image tag markup.""" - img = pq_img(self.p, '[[Image:test.jpg]]', 'img') - eq_('test.jpg', img.attr('alt')) - eq_(self.img.file.url, img.attr('src')) - - def test_simple_fallback(self): - """Fallback to English if current locale doesn't have the image.""" - img = pq_img(self.p, '[[Image:test.jpg]]', selector='img', locale='ja') - eq_('test.jpg', img.attr('alt')) - eq_(self.img.file.url, img.attr('src')) - - def test_full_fallback(self): - """Find current locale's image, not the English one.""" - # first, pretend there is no English version - self.img.locale = 'ja' - self.img.save() - img = pq_img(self.p, '[[Image:test.jpg]]', selector='img', locale='ja') - eq_('test.jpg', img.attr('alt')) - eq_(self.img.file.url, img.attr('src')) - - # then, create an English version - en_img = image(title='test.jpg') - # Ensure they're not equal - self.assertNotEquals(en_img.file.url, self.img.file.url) - - # make sure there is no fallback - img = pq_img(self.p, '[[Image:test.jpg]]', selector='img', locale='ja') - eq_('test.jpg', img.attr('alt')) - eq_(self.img.file.url, img.attr('src')) - - # now delete the English version - self.img.delete() - self.img = en_img # don't break tearDown - img = pq_img(self.p, '[[Image:test.jpg]]', selector='img', locale='ja') - eq_('test.jpg', img.attr('alt')) - eq_(self.img.file.url, img.attr('src')) - - def test_caption(self): - """Give the image a caption.""" - self.img.title = 'img test.jpg' - self.img.save() - img_div = pq_img(self.p, '[[Image:img test.jpg|frame|my caption]]', - 'div.img') - img = img_div('img') - caption = img_div.text() - - eq_(self.img.file.url, img.attr('src')) - eq_('my caption', img.attr('alt')) - eq_('my caption', caption) - - def test_page_link(self): - """Link to a wiki page.""" - img_a = pq_img(self.p, '[[Image:test.jpg|page=Installing Firefox]]', - 'a') - img = img_a('img') - - eq_('test.jpg', img.attr('alt')) - eq_(self.img.file.url, img.attr('src')) - eq_('/en-US/kb/installing-firefox', img_a.attr('href')) - - def test_page_link_edit(self): - """Link to a nonexistent wiki page.""" - img_a = pq_img(self.p, '[[Image:test.jpg|page=Article List]]', 'a') - img = img_a('img') - - eq_('test.jpg', img.attr('alt')) - eq_(self.img.file.url, img.attr('src')) - assert img_a.hasClass('new') - eq_('/en-US/kb/new?title=Article+List', img_a.attr('href')) - - def test_page_link_caption(self): - """Link to a wiki page with caption and frame.""" - img_div = pq_img(self.p, - '[[Image:test.jpg|frame|page=A page|my caption]]', - 'div.img') - img_a = img_div('a') - img = img_a('img') - caption = img_div.text() - - eq_('my caption', img.attr('alt')) - eq_('my caption', caption) - eq_(self.img.file.url, img.attr('src')) - assert img_a.hasClass('new') - eq_('/en-US/kb/new?title=A+page', img_a.attr('href')) - - def test_link(self): - """Link to an external page.""" - img_a = pq_img(self.p, '[[Image:test.jpg|link=http://test.com]]', 'a') - img = img_a('img') - - eq_('test.jpg', img.attr('alt')) - eq_(self.img.file.url, img.attr('src')) - eq_('http://test.com', img_a.attr('href')) - - def test_link_caption(self): - """Link to an external page with caption.""" - img_div = pq_img(self.p, - '[[Image:test.jpg|link=http://ab.us|frame|caption]]', - 'div.img') - img = img_div('img') - img_a = img_div('a') - - eq_(self.img.file.url, img.attr('src')) - eq_('http://ab.us', img_a.attr('href')) - - def test_link_align(self): - """Link with align.""" - img_div = pq_img(self.p, - '[[Image:test.jpg|link=http://site.com|align=left]]', - 'div.img') - eq_('img align-left', img_div.attr('class')) - - def test_link_align_invalid(self): - """Link with invalid align.""" - img = pq_img(self.p, - '[[Image:test.jpg|link=http://example.ro|align=inv]]') - eq_('frameless', img.attr('class')) - - def test_link_valign(self): - """Link with valign.""" - img = pq_img(self.p, - '[[Image:test.jpg|link=http://example.com|valign=top]]') - eq_('vertical-align: top;', img.attr('style')) - - def test_link_valign_invalid(self): - """Link with invalid valign.""" - img = pq_img(self.p, - '[[Image:test.jpg|link=http://example.com|valign=off]]') - eq_(None, img.attr('style')) - - def test_alt(self): - """Image alt attribute is overriden but caption is not.""" - img_div = pq_img(self.p, - '[[Image:test.jpg|alt=my alt|frame|my caption]]', - 'div.img') - img = img_div('img') - caption = img_div.text() - - eq_('my alt', img.attr('alt')) - eq_('my caption', caption) - - def test_alt_empty(self): - """Image alt attribute can be empty.""" - img = pq_img(self.p, '[[Image:test.jpg|alt=|my caption]]') - - eq_('', img.attr('alt')) - - def test_alt_unsafe(self): - """Potentially unsafe alt content is escaped.""" - unsafe_vals = ( - ('an"', - 'an"&lt;script&gt;alert()&lt;/script&gt;'), - ("an'", - "an'&lt;script&gt;alert()&lt;/script&gt;"), - ('single\'"double', - "single'"double"), - ) - for alt_sent, alt_expected in unsafe_vals: - img = pq_img(self.p, '[[Image:test.jpg|alt=' + alt_sent + ']]') - - is_true = str(img).startswith('' + alt_expected + ' Date: Thu, 7 Aug 2014 22:35:30 -0500 Subject: [PATCH 23/24] Update window shortcuts --- media/redesign/js/wiki.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/media/redesign/js/wiki.js b/media/redesign/js/wiki.js index 2206ae5bee7..458aad639ce 100644 --- a/media/redesign/js/wiki.js +++ b/media/redesign/js/wiki.js @@ -264,7 +264,7 @@ }, 10); // Set it forth! - if($toc.length || $pageButtons.attr('data-sticky') == "true"){ + if($toc.length || $pageButtons.attr('data-sticky') == 'true'){ scrollFn(); $(win).on('scroll resize', scrollFn); } @@ -528,8 +528,8 @@ // If the page does not have any YouTube videos if(!$youtubeIframes.length) return; - var origin = window.location.protocol + "//" + window.location.hostname + - (window.location.port ? ':' + window.location.port: ''); + var origin = win.location.protocol + '//' + win.location.hostname + + (win.location.port ? ':' + win.location.port: ''); //Enable JS API on all YouTube iframes, might cause flicker! $youtubeIframes.each(function() { @@ -541,12 +541,12 @@ // Load YouTube Iframe API var youtubeScript = doc.createElement('script'); youtubeScript.async = 'true'; - youtubeScript.src = "//www.youtube.com/iframe_api"; + youtubeScript.src = '//www.youtube.com/iframe_api'; doc.body.appendChild(youtubeScript); // Method executed by YouTube API, needs to be global - window.onYouTubeIframeAPIReady = function(event) { + win.onYouTubeIframeAPIReady = function(event) { $youtubeIframes.each(function(i){ players[i] = new YT.Player($(this).get(0)); @@ -617,7 +617,7 @@ }); }); players[i].addEventListener('onError', function(event) { - mdn.trackError('YouTube Error: ' + event.data + 'on ' + window.location.href); + mdn.trackError('YouTube Error: ' + event.data + 'on ' + win.location.href); }); }); }; From 48d8477b9252ccc7658546f27c2434b66fc3297a Mon Sep 17 00:00:00 2001 From: David Walsh Date: Thu, 7 Aug 2014 23:00:26 -0500 Subject: [PATCH 24/24] Add homepage JS for slider --- apps/landing/templates/landing/homepage.html | 5 ++++- media/redesign/js/home.js | 13 ------------- 2 files changed, 4 insertions(+), 14 deletions(-) delete mode 100644 media/redesign/js/home.js diff --git a/apps/landing/templates/landing/homepage.html b/apps/landing/templates/landing/homepage.html index 7db22b63ea3..a06f0fe27cd 100644 --- a/apps/landing/templates/landing/homepage.html +++ b/apps/landing/templates/landing/homepage.html @@ -169,5 +169,8 @@

    {{ _('Help improve MDN') }}< {% block js %} {{ super() }} - {{ js('home', async=True) }} + {% endblock %} diff --git a/media/redesign/js/home.js b/media/redesign/js/home.js deleted file mode 100644 index 24ab760ecec..00000000000 --- a/media/redesign/js/home.js +++ /dev/null @@ -1,13 +0,0 @@ -(function($) { - 'use strict'; - - // Create the demos slider - var $list = $('.home-demos-list'); - if ($list.length) { - $list.owlCarousel({ - lazyLoad: true - }); - $list.css('height', 'auto'); - } - -})(jQuery);