Skip to content
Browse files

Drop the 'search translations' functionality.

The functionality was provided by the ``trans_memory`` addon. Since this
is no longer needed (too slow) and does not fit the future plans, the
whole addon is dropped.
  • Loading branch information...
1 parent 755bfd5 commit 66981ae0c280e5d9a15401cece8c5beee6806557 Apostolos Bessas committed May 24, 2012
View
11 transifex/addons/lotte/tests/templates.py
@@ -27,17 +27,6 @@ def test_breadcrumbs(self):
resp = self.client['team_member'].get(self.translate_view_url)
self.assertContains(resp, 'Translate')
- def test_search_translation_link(self):
- """Test that search translation link exists and points to search page."""
-
- # Test the response contents
- resp = self.client['team_member'].get(self.translate_view_url)
- self.assertTemplateUsed(resp, 'translate.html')
- self.assertContains(resp, 'Search translations', status_code=200)
- self.assertContains(resp,
- 'Search in Transifex memory for existing translations (uses a new tab/window)')
- self.assertContains(resp, reverse('search_translations'))
-
def test_filters(self):
"""Test that more languages, filter by users, resources appear."""
View
5 transifex/addons/trans_memory/__init__.py
@@ -1,5 +0,0 @@
-# -*- coding: utf-8 -*-
-class Meta:
- author = "Indifex Ltd."
- title = "Translation Memory"
- description = "Search through current and past translations"
View
0 transifex/addons/trans_memory/models.py
No changes.
View
18 transifex/addons/trans_memory/static/trans_memory/css/search_translation.css
@@ -1,18 +0,0 @@
-
-h2.pagetitle sup{
- color:#666;
- font-size:0.7em;
-}
-
-div.project_list h3 {
- border-top: 3px solid #eee;
- padding-top: 0.5em;
-}
-
-div.project_list div.entry {
- margin-bottom: 2.5em;
-}
-
-div.project_list div.entry p.comment{
- margin-top: 0.5em;
-}
View
83 transifex/addons/trans_memory/templates/search_translation.html
@@ -1,83 +0,0 @@
-{% extends "base.html" %}
-{% load staticfiles %}
-{% load i18n %}
-{% load pagination_tags %}
-{% load search_filters %}
-{% load resources_common_tags %}
-
-{% block extracss %}
-<link media="screen" href="{% static "trans_memory/css/search_translation.css" %}" type="text/css" rel="stylesheet" />
-{% endblock %}
-
-{% block breadcrumb %}{% endblock %}
-
-{% block title %}{{ block.super }} | {% trans "Search translations" %}{% endblock %}
-
-{% block body_class %}search project_list{% endblock %}
-
-{% block content_title %}
- <h2 class="pagetitle">
- {% trans "Search translations" %} {% if translations.count %}<sup>({{ translations.count }})</sup> {% endif %}
- </h2>
-{% endblock %}
-
-{% block content_main %}
-
-<fieldset>
-{% include "search_translation_form.html" %}
-</fieldset>
-
-{% autopaginate translations 25 %}
-
-{% if query %}
- {% if translations %}
- <div class="project_list">
- {% for translation in translations %}
-
- {% with translation.language as translation_language %}
-
- {% ifchanged translation_language %}
- <h3>
- {% blocktrans with source_language as source_language %}{{ source_language }} &rarr; {{ translation_language }}{% endblocktrans %}
- </h3>
- {% endifchanged %}
-
- <div class="entry">
- {% with translation.source_entity as source_entity %}
-
- {% highlight terms as source_highlighted %}
- {{ source_entity|entity_translation:source_language }}
- {% endhighlight %}
-
- <p class="i16 text" title="{% trans "Source string" %}">{{ source_highlighted.highlighted }}</p>
- <p class="i16 comment" title="{% trans "Translation" %}">{{ translation.string }}</p>
-
- {% if source_entity.description %}
- <p class="long_description"><span>{% trans "Description:"</span>{{ source_entity.string }}</p>
- {% endif %}
-
- {% with source_entity.resource as resource %}
- <p class="long_description">
- <span>{% trans "Location:" %}</span>
- <a href="{{ resource.project.get_absolute_url}}">{{ resource.project }}</a> &raquo;
- <a href="{{ resource.get_absolute_url}}">{{ resource.name }}</a>
- </p>
- {% endwith %}
- {% endwith %}
- {% endwith %}
- </div>
- {% endfor %}
-
- </div>
- {% else %}
- {% trans "Tough luck! No translations obtained." %}
- {% endif %}
-{% endif %}
-
-<div class="pagination top">{% paginate %}</div>
-
-
-{% endblock %}
-
-{% block content_footer %}
-{% endblock %}
View
41 transifex/addons/trans_memory/templates/search_translation_form.html
@@ -1,41 +0,0 @@
-{% load i18n %}
-<div class="searchform" style="border-bottom:1px solid #ddd;">
- <form action="{% url search_translations %}" method="GET" class="search_projects">
- <table>
- <tr>
- <td>
- <label for="tq">{% trans "Search for a string:" %}</label><br/>
- <input class="query withbgimage" type="text" name="tq" size="30" value="{{ query|escape }}">
- </td>
- <td>
- <label for="source_lang">{% trans "From:" %}</label>
- <br/>
- <label for="target_lang">{% trans "To:" %}</label>
- </td>
- <td>
- <select name="source_lang" class="query withbgimage" placeholder="Choose language" >
- {% for language in languages %}
- {% ifequal language.code source_language.code %}
- <option value="{{ language.code }}" selected="selected">{{ language.name }}</option>
- {% else %}
- <option value="{{ language.code }}">{{ language.name }}</option>
- {% endifequal %}
- {% endfor %}
- </select>
- <br />
- <select name="target_lang" class="query withbgimage" placeholder="Choose language" >
- <option value="">Any language</option>
- {% for language in languages %}
- {% ifequal language.code target_language_code %}
- <option value="{{ language.code }}" selected="selected">{{ language.name }}</option>
- {% else %}
- <option value="{{ language.code }}">{{ language.name }}</option>
- {% endifequal %}
- {% endfor %}
- </select>
- </td>
- <td>
- <input class="i16 submit buttonized" type="submit" value="{% trans "Search" %}">
- </td></tr></table>
- </form>
-</div>
View
5 transifex/addons/trans_memory/templates/trans_memory/lotte_header_link.html
@@ -1,5 +0,0 @@
-{% load i18n %}
-{% url search_translations as search_translations %}
-<div class="lotte-header-link">
- <a href="{{ search_translations }}" class="nude-button i16 search_translations tipsy_enable" target="_new" title="{% trans "Search in Transifex memory for existing translations (uses a new tab/window)" %}">{% trans "Search translations" %}</a>
-</div>
View
56 transifex/addons/trans_memory/tests.py
@@ -1,56 +0,0 @@
-# -*- coding: utf-8 -*-
-from transifex.txcommon.tests.base import BaseTestCase
-from transifex.resources.models import SourceEntity
-
-class MemoryViewsTests(BaseTestCase):
-
- def setUp(self):
- super(MemoryViewsTests, self).setUp()
- self.entity = self.resource.entities[0]
- self.URL_PREFIX = '/search_translations/'
-
- def testAnonymousPagesStatusCode(self):
- pages = {302: [(self.URL_PREFIX),],}
- self.assert_url_statuses(pages, self.client["anonymous"])
-
- def test_memory_search(self):
- """Test search for existing translations"""
- DATA = {'tq': 'me some', 'source_lang' : self.language_en.code, 'target_lang' : self.language_ar.code}
- resp = self.client['registered'].get(self.URL_PREFIX, DATA)
- self.assertContains(resp, u'%s (%s) &rarr; %s (%s)'%
- (self.language_en.name, self.language_en.code,
- self.language_ar.name, self.language_ar.code),
- status_code = 200)
- DATA = {'tq': 'mesome', 'source_lang' : self.language_en.code, 'target_lang' : self.language_ar.code}
- resp = self.client['registered'].get(self.URL_PREFIX, DATA)
- self.assertContains(resp, 'Tough luck! No translations obtained.', status_code=200)
-
-
- def test_private_project(self):
- """Test access to various methods if the project is private."""
- source_entity = SourceEntity.objects.create(string='String2',
- context='Context2', occurrences='Occurrences1',
- resource=self.resource_private)
- source_entity.translations.create(
- string='This is a test source string',
- rule=5,
- source_entity=source_entity,
- resource=self.resource_private,
- language=self.language_en,
- user=self.user['team_member'])
- source_entity.translations.create(
- string=u'This is supposed to be arabic text! αβγ',
- rule=5,
- source_entity=source_entity,
- resource=self.resource_private,
- language=self.language_ar,
- user=self.user['team_member'])
- DATA = {'tq': 'test string', 'source_lang' : self.language_en.code, 'target_lang' : self.language_ar.code}
- resp = self.client['team_member'].get(self.URL_PREFIX, DATA)
- self.assertContains(resp, u'%s (%s) &rarr; %s (%s)'%
- (self.language_en.name, self.language_en.code,
- self.language_ar.name, self.language_ar.code),
- status_code=200)
- resp = self.client['registered'].get(self.URL_PREFIX, DATA)
- self.assertContains(resp,'Tough luck! No translations obtained.', status_code=200)
-
View
7 transifex/addons/trans_memory/urls.py
@@ -1,7 +0,0 @@
-from django.conf.urls.defaults import *
-from views import search_translations
-
-urlpatterns = patterns('',
- # Search strings
- url(r'^search_translations/$', search_translations, name='search_translations'),
-)
View
66 transifex/addons/trans_memory/views.py
@@ -1,66 +0,0 @@
-from django.contrib.auth.decorators import login_required
-from django.shortcuts import render_to_response, get_object_or_404
-from django.template import RequestContext
-
-from transifex.languages.models import Language
-from transifex.resources.models import Translation
-
-DEFAULT_LANG_CODE = 'en'
-
-# FIXME: Search only in public projects
-@login_required
-def search_translations(request):
- """Search for existing translations.
-
- This view accepts three GET variables and uses them to search in existing
- translations. It searches all the strings (translations) and returns those
- which match the string query in the particular language.
-
- tq:
- The string to search the database for.
- source_lang:
- The language which we should search the string for and can be any
- language.
- target_lang:
- Limit the shown results to only those which have this target language.
-
- """
-
- query_string = request.GET.get('tq', "")
- source_language_code = request.GET.get('source_lang', DEFAULT_LANG_CODE)
- source_language = Language.objects.get(code=source_language_code)
- target_language_code = request.GET.get('target_lang', None)
-
- search_terms = query_string.split()
- #TODO: Add check to only allow terms bigger than 2 letters
-
- translations = []
-
- if search_terms:
- #FIXME: Make searching work with terms, not full strings like now.
- #The searching should be done with OR for each term.
- search_dict = {'string': query_string,
- 'user': request.user,
- 'source_code': source_language_code}
- if target_language_code:
- search_dict.update({'target_code': target_language_code})
- translations = Translation.objects.by_string_and_language(
- **search_dict).order_by('language').exclude(language__code=source_language_code)
-
- #FIXME: Make the source_language lookup more efficient. The code below
- # attempts to replace the multiple db hits by the template tag by creating
- # a lookup dictionary once.
- #source_entity_ids = translations.values('source_entity_id')
- #sources = Translation.objects.filter(
- # source_entity__id__in=translations, language=source_language).values(
- # 'source_entity', 'string')
-
- return render_to_response("search_translation.html", {
- 'languages': Language.objects.all(),
- 'query': query_string,
- 'source_language': source_language,
- 'target_language_code': target_language_code,
- 'translations': translations,
- 'terms': search_terms},
- context_instance = RequestContext(request))
-

0 comments on commit 66981ae

Please sign in to comment.
Something went wrong with that request. Please try again.