Permalink
Browse files

[bug 825955] Locale filtering for KB media gallery

  • Loading branch information...
1 parent 40e7909 commit f8776020b991eca4046be4fdc6ea9ee715f370e8 @rehandalal rehandalal committed Mar 17, 2013
@@ -1,7 +1,7 @@
{# vim: set ts=2 et sts=2 sw=2: #}
{% extends "forums/base.html" %}
{% from "layout/errorlist.html" import errorlist %}
-{% from "includes/common_macros.html" import content_editor %}
+{% from "includes/common_macros.html" import content_editor with context %}
{# L10n: {f} if the name of the forum, {t} if the name of the thread. #}
{% set title = _('Edit a post | {t} | {f} | Forums')|f(t=thread.title,f=forum.name) %}
{% set crumbs = [(url('forums.forums'), _('Forums')),
@@ -1,7 +1,7 @@
{# vim: set ts=2 et sts=2 sw=2: #}
{% extends "forums/base.html" %}
{% from "layout/errorlist.html" import errorlist %}
-{% from "includes/common_macros.html" import content_editor %}
+{% from "includes/common_macros.html" import content_editor with context %}
{# L10n: {f} if the name of the forum. #}
{% set title = _('Create a new thread | {f} | Forums')|f(f=forum.name) %}
{% set crumbs = [(url('forums.forums'), _('Forums')),
@@ -1,7 +1,8 @@
{# vim: set ts=2 et sts=2 sw=2: #}
{% extends "forums/base.html" %}
{% from "layout/errorlist.html" import errorlist %}
-{% from "includes/common_macros.html" import content_editor, for_contributors_sidebar %}
+{% from "includes/common_macros.html" import content_editor with context %}
+{% from "includes/common_macros.html" import for_contributors_sidebar %}
{# L10n: {t} is the title of the thread. {f} is the name of the forum. #}
{% set title = _('{t} | {f} | Forums')|f(t=thread.title, f=forum.name) %}
{% set crumbs = [(url('forums.forums'), _('Contributor Forums')),
@@ -144,18 +144,15 @@ def gallery_async(request):
# Maybe refactor this into existing views and check request.is_ajax?
media_type = request.GET.get('type', 'image')
term = request.GET.get('q')
+ media_locale = request.GET.get('locale', settings.WIKI_DEFAULT_LANGUAGE)
if media_type == 'image':
media_qs = Image.objects
elif media_type == 'video':
media_qs = Video.objects
else:
raise Http404
- if request.LANGUAGE_CODE == settings.WIKI_DEFAULT_LANGUAGE:
- media_qs = media_qs.filter(locale=request.LANGUAGE_CODE)
- else:
- locales = [request.LANGUAGE_CODE, settings.WIKI_DEFAULT_LANGUAGE]
- media_qs = media_qs.filter(locale__in=locales)
+ media_qs = media_qs.filter(locale=media_locale)
if term:
media_qs = media_qs.filter(Q(title__icontains=term) |
@@ -1,6 +1,6 @@
{# vim: set ts=2 et sts=2 sw=2: #}
{% extends "groups/base.html" %}
-{% from "includes/common_macros.html" import content_editor %}
+{% from "includes/common_macros.html" import content_editor with context %}
{% set title = _('Edit | {group} | Groups')|f(group=profile.group.name) %}
{% block content %}
@@ -1,7 +1,7 @@
{# vim: set ts=2 et sts=2 sw=2: #}
{% extends "kbforums/base.html" %}
{% from "layout/errorlist.html" import errorlist %}
-{% from "includes/common_macros.html" import content_editor %}
+{% from "includes/common_macros.html" import content_editor with context %}
{% from "kbforums/includes/macros.html" import kbforums_warning with context %}
{# L10n: {t} is the title of the thread. {d} is the name of the document. #}
{% set title = _('Edit a post | {t} | {d} Discussion | Knowledge Base')|f(t=thread.title, d=document.title) %}
@@ -1,7 +1,7 @@
{# vim: set ts=2 et sts=2 sw=2: #}
{% extends "kbforums/base.html" %}
{% from "layout/errorlist.html" import errorlist %}
-{% from "includes/common_macros.html" import content_editor %}
+{% from "includes/common_macros.html" import content_editor with context %}
{% from "kbforums/includes/macros.html" import kbforums_warning with context %}
{# L10n: {d} is the name of the document. #}
{% set title = _('Create a new thread | {d} | Knowledge Base')|f(d=document.title) %}
@@ -1,7 +1,7 @@
{# vim: set ts=2 et sts=2 sw=2: #}
{% extends "kbforums/base.html" %}
{% from "layout/errorlist.html" import errorlist %}
-{% from "includes/common_macros.html" import content_editor %}
+{% from "includes/common_macros.html" import content_editor with context %}
{% from "kbforums/includes/macros.html" import kbforums_warning with context %}
{# L10n: {t} is the title of the thread. {d} is the name of the document. #}
{% set title = _('{t} | {d} Discussion | Knowledge Base')|f(t=thread.title, d=document.title) %}
@@ -1,4 +1,4 @@
-{% from "includes/common_macros.html" import content_editor %}
+{% from "includes/common_macros.html" import content_editor with context %}
{% macro avatar_link(user=None) -%}
{% if user %}
@@ -1,5 +1,5 @@
{% extends "messages/base.html" %}
-{% from "messages/includes/macros.html" import message_form %}
+{% from "messages/includes/macros.html" import message_form with context %}
{% set title = _('New Message') %}
{% set crumbs = [(url('messages.inbox'), _('Messages')), (None, title)] %}
{% set active_tab = 'new' %}
@@ -2,7 +2,8 @@
{% extends "questions/base.html" %}
{% from "layout/errorlist.html" import errorlist %}
{% from "upload/attachments.html" import attachments_form %}
-{% from "includes/common_macros.html" import content_editor, for_contributors %}
+{% from "includes/common_macros.html" import content_editor with context %}
+{% from "includes/common_macros.html" import for_contributors %}
{% from "wiki/includes/flag_form.html" import flag_form with context %}
{% from "questions/includes/questions.html" import troubleshooting_info %}
@@ -2,7 +2,7 @@
{% extends "questions/base.html" %}
{% from "layout/errorlist.html" import errorlist %}
{% from "upload/attachments.html" import attachments_form %}
-{% from "includes/common_macros.html" import content_editor %}
+{% from "includes/common_macros.html" import content_editor with context %}
{# L10n: {t} is the title of the question. #}
{% set title = _('Editing an answer | {t} | Firefox Support Forum')|f(t=answer.question.title) %}
{% set classes = 'answers' %}
@@ -11,7 +11,7 @@
#}
{% extends "questions/base.html" %}
{% from "layout/errorlist.html" import errorlist %}
-{% from "includes/common_macros.html" import content_editor %}
+{% from "includes/common_macros.html" import content_editor with context %}
{% from "questions/includes/aaq_macros-new.html" import selected_product, selected_category,
troubleshooting_instructions %}
{% set classes = 'new-question' %}
@@ -2,7 +2,7 @@
{% extends "wiki/base.html" %}
{% from "layout/errorlist.html" import errorlist %}
{% from "wiki/includes/sidebar_modules.html" import document_tools with context %}
-{% from "includes/common_macros.html" import content_editor %}
+{% from "includes/common_macros.html" import content_editor with context %}
{% from "wiki/includes/document_macros.html" import edit_messages, submit_revision %}
{% from "wiki/includes/document_macros.html" import document_lock_warning with context %}
{% set title = _('Edit Article | {document}')|f(document=document.title) %}
@@ -2,7 +2,7 @@
{% extends "wiki/base.html" %}
{% from "includes/common_macros.html" import for_contributors_sidebar %}
{% from "layout/errorlist.html" import errorlist %}
-{% from "includes/common_macros.html" import content_editor %}
+{% from "includes/common_macros.html" import content_editor with context %}
{% from "wiki/includes/document_macros.html" import submit_revision %}
{% set title = _('Create a New Article | Knowledge Base') %}
{# TODO: Change KB url to landing page when we have one #}
@@ -2,7 +2,7 @@
{% extends "wiki/base.html" %}
{% from "layout/errorlist.html" import errorlist %}
{% from "wiki/includes/sidebar_modules.html" import document_tools with context %}
-{% from "includes/common_macros.html" import content_editor %}
+{% from "includes/common_macros.html" import content_editor with context %}
{% from "wiki/includes/document_macros.html" import revision_diff, submit_revision, edit_messages with context %}
{% from "wiki/includes/document_macros.html" import document_lock_warning with context %}
{% set title = _('Translate Article | {document}')|f(document=parent.title) %}
View
@@ -647,12 +647,14 @@ Marky.MediaButton.prototype = $.extend({}, Marky.SimpleButton.prototype, {
// TODO: look at using a js template solution (jquery-tmpl?)
$html = $(
'<section class="marky">' +
- '<div class="filter"><div class="type">' +
+ '<div class="filter cf">' +
+ '<div class="search"><input type="text" name="q" />' +
+ '<button class="btn btn-important">' + gettext('Search Gallery') + '</button></div>' +
+ '<div class="type">' +
'<span>' + gettext('Show:') + '</span>' +
'<ol><li data-type="image" class="selected">' + gettext('Images') + '</li>' +
'<li data-type="video">' + gettext('Videos') + '</li></ol></div>' +
- '<div class="search"><input type="text" name="q" />' +
- '<button class="btn btn-important">' + gettext('Search Gallery') + '</button></div></div>' +
+ '<div class="locale-filter">' + gettext('Show media for:') + ' <select /></div></div>' +
'<div class="placeholder" /><div class="submit">' +
'<button class="btn btn-important">' + gettext('Insert Media') + '</button>' +
'<a href="' + galleryUrl + '#upload" class="upload" target="_blank">' +
@@ -663,6 +665,7 @@ Marky.MediaButton.prototype = $.extend({}, Marky.SimpleButton.prototype, {
selectedText = me.getSelectedText(),
mediaType = $html.find('div.type li.selected').data('type'),
mediaQ = '',
+ mediaLocale = $('html').attr('lang'),
mediaPage = 1,
kbox;
@@ -680,6 +683,15 @@ Marky.MediaButton.prototype = $.extend({}, Marky.SimpleButton.prototype, {
return false;
});
+ // Handle locale filter
+ var $lf = $html.find('div.locale-filter select');
+ $lf.html($('#_languages-select-box').html())
+ $lf.on('change', function() {
+ mediaPage = 1
+ mediaLocale = $(this).val();
+ updateResults();
+ })
+
// Handle Search button
$html.find('div.search button').click(function(e) {
mediaQ = $html.find('input[name="q"]').val();
@@ -730,7 +742,8 @@ Marky.MediaButton.prototype = $.extend({}, Marky.SimpleButton.prototype, {
$.ajax({
url: mediaSearchUrl,
type: 'GET',
- data: {type: mediaType, q: mediaQ, page: mediaPage},
+ data: {type: mediaType, q: mediaQ, page: mediaPage,
+ locale: mediaLocale},
dataType: 'html',
success: function(html) {
$html.find('div.placeholder').html(html);
@@ -175,10 +175,10 @@ section.marky {
div.placeholder {
height: 65%;
- height: -moz-calc(~"100% - 200px");
+ height: -moz-calc(~"100% - 225px");
left: 15px;
position: absolute;
- top: 100px;
+ top: 135px;
}
&.processing {
@@ -235,7 +235,7 @@ section.marky {
background: url("../img/icon.searchloupe.png") no-repeat scroll 7px center #FFFFFF;
margin: 0 7px 0 0;
padding-left: 33px;
- width: 300px;
+ width: 500px;
}
div.type {
@@ -58,6 +58,13 @@
<div class="editor-tools"></div>
<div>{{ field|safe }}</div>
</div>
+ <div style="display: none;">
+ <select id="_languages-select-box">
+ {% for lang in settings.LANGUAGE_CHOICES %}
+ <option value="{{ lang[0] }}" {% if lang[0] == request.LANGUAGE_CODE %}selected="selected"{% endif %}>{{ lang[1] }} ({{ lang[0] }})</option>
+ {% endfor %}
+ </select>
+ </div>
{% endmacro %}
{% macro list_view_item(url, label, class=None, icon_url=None) %}

0 comments on commit f877602

Please sign in to comment.