mirror of
https://github.com/Hopiu/django-rosetta.git
synced 2026-03-16 21:30:24 +00:00
massive cleanup, only test against supported django versions
This commit is contained in:
parent
c1b0c38968
commit
237c36f0d2
11 changed files with 71 additions and 92 deletions
|
|
@ -4,20 +4,10 @@ from rosetta.conf import settings as rosetta_settings
|
|||
import django
|
||||
import os
|
||||
import inspect
|
||||
from django.apps import AppConfig
|
||||
from django.apps import apps
|
||||
from django.utils import timezone
|
||||
|
||||
try:
|
||||
from django.utils import timezone
|
||||
except:
|
||||
timezone = None
|
||||
|
||||
try:
|
||||
set
|
||||
except NameError:
|
||||
from sets import Set as set # Python 2.3 fallback
|
||||
|
||||
if django.VERSION[0:2] >= (1, 7):
|
||||
from django.apps import AppConfig
|
||||
from django.apps import apps
|
||||
|
||||
try:
|
||||
from django.core.cache import caches
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@
|
|||
</thead>
|
||||
<tbody>
|
||||
{% for app,path,po in pos %}
|
||||
<tr class="{% cycle row1,row2 %}">
|
||||
<tr class="{% cycle 'row1' 'row2' %}">
|
||||
<td><a href="{% url 'rosetta-language-selection' lid forloop.counter0 %}{% if do_django %}?django{% endif %}{% if do_rosetta %}?rosetta{% endif %}">{{ app|title }}</a></td>
|
||||
<td class="ch-progress r">{{po.percent_translated|floatformat:2}}%</td>
|
||||
{% with po.untranslated_entries|length as len_untranslated_entries %}
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@
|
|||
</thead>
|
||||
<tbody>
|
||||
{% for message in rosetta_messages %}
|
||||
<tr class="{% cycle row1,row2 %}">
|
||||
<tr class="{% cycle 'row1' 'row2' %}">
|
||||
{% if message.msgid_plural %}
|
||||
<td class="original plural">
|
||||
<div class="plural-container">
|
||||
|
|
|
|||
|
|
@ -1,11 +1,10 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from django.conf import settings
|
||||
from django.contrib.auth.models import User, Group
|
||||
from django.core.urlresolvers import reverse, resolve
|
||||
from django.core.exceptions import ImproperlyConfigured
|
||||
from django.core.cache import cache
|
||||
from django.template.defaultfilters import floatformat
|
||||
from django.test import TestCase
|
||||
from django.test import TestCase # , override_settings
|
||||
from django.test.client import Client
|
||||
from django.dispatch import receiver
|
||||
from rosetta.conf import settings as rosetta_settings
|
||||
|
|
@ -26,6 +25,8 @@ class RosettaTestCase(TestCase):
|
|||
|
||||
|
||||
def setUp(self):
|
||||
from django.contrib.auth.models import User
|
||||
|
||||
user = User.objects.create_user('test_admin', 'test@test.com', 'test_password')
|
||||
user2 = User.objects.create_user('test_admin2', 'test@test2.com', 'test_password')
|
||||
user3 = User.objects.create_user('test_admin3', 'test@test2.com', 'test_password')
|
||||
|
|
@ -497,11 +498,13 @@ class RosettaTestCase(TestCase):
|
|||
r = self.client.get(reverse('rosetta-language-selection', args=('xx', 0), kwargs=dict()))
|
||||
r = self.client.get(reverse('rosetta-home'))
|
||||
# We have distinct hashes, even though the msgid and msgstr are identical
|
||||
#print (r.content)
|
||||
# print (r.content)
|
||||
self.assertTrue('m_4765f7de94996d3de5975fa797c3451f' in str(r.content))
|
||||
self.assertTrue('m_08e4e11e2243d764fc45a5a4fba5d0f2' in str(r.content))
|
||||
|
||||
def test_23_save_header_data(self):
|
||||
from django.contrib.auth.models import User
|
||||
|
||||
shutil.copy(os.path.normpath(os.path.join(self.curdir, './django.po.template')), self.dest_file)
|
||||
|
||||
unicode_user = User.objects.create_user('test_unicode', 'save_header_data@test.com', 'test_unicode')
|
||||
|
|
@ -529,7 +532,7 @@ class RosettaTestCase(TestCase):
|
|||
f_ = open(self.dest_file, 'rb')
|
||||
content = six.text_type(f_.read())
|
||||
f_.close()
|
||||
#print (content)
|
||||
# print (content)
|
||||
# make sure unicode data was properly converted to ascii
|
||||
self.assertTrue('Hello, world' in content)
|
||||
self.assertTrue('save_header_data@test.com' in content)
|
||||
|
|
@ -632,6 +635,8 @@ class RosettaTestCase(TestCase):
|
|||
rosetta_settings.ROSETTA_EXCLUDED_PATHS = ROSETTA_EXCLUDED_PATHS
|
||||
|
||||
def test_32_pr_103__language_groups(self):
|
||||
from django.contrib.auth.models import User, Group
|
||||
|
||||
ROSETTA_LANGUAGE_GROUPS = rosetta_settings.ROSETTA_LANGUAGE_GROUPS
|
||||
rosetta_settings.ROSETTA_LANGUAGE_GROUPS = False
|
||||
|
||||
|
|
|
|||
|
|
@ -1,11 +1,7 @@
|
|||
try:
|
||||
from django.conf.urls import patterns, include, url
|
||||
except ImportError:
|
||||
from django.conf.urls.defaults import patterns, include, url
|
||||
from django.conf.urls import include, url
|
||||
from .views import dummy
|
||||
|
||||
|
||||
urlpatterns = patterns(
|
||||
'',
|
||||
urlpatterns = [
|
||||
url(r'^rosetta/', include('rosetta.urls')),
|
||||
url(r'^admin/$', 'rosetta.tests.views.dummy', name='dummy-login')
|
||||
)
|
||||
url(r'^admin/$', dummy, name='dummy-login')
|
||||
]
|
||||
|
|
|
|||
|
|
@ -1,13 +1,11 @@
|
|||
try:
|
||||
from django.conf.urls import patterns, url
|
||||
except ImportError:
|
||||
from django.conf.urls.defaults import patterns, url
|
||||
from django.conf.urls import url
|
||||
from .views import (home, list_languages, download_file, lang_sel, translate_text)
|
||||
|
||||
|
||||
urlpatterns = patterns('rosetta.views',
|
||||
url(r'^$', 'home', name='rosetta-home'),
|
||||
url(r'^pick/$', 'list_languages', name='rosetta-pick-file'),
|
||||
url(r'^download/$', 'download_file', name='rosetta-download-file'),
|
||||
url(r'^select/(?P<langid>[\w\-_\.]+)/(?P<idx>\d+)/$', 'lang_sel', name='rosetta-language-selection'),
|
||||
url(r'^translate/$', 'translate_text', name='translate_text'),
|
||||
)
|
||||
urlpatterns = [
|
||||
url(r'^$', home, name='rosetta-home'),
|
||||
url(r'^pick/$', list_languages, name='rosetta-pick-file'),
|
||||
url(r'^download/$', download_file, name='rosetta-download-file'),
|
||||
url(r'^select/(?P<langid>[\w\-_\.]+)/(?P<idx>\d+)/$', lang_sel, name='rosetta-language-selection'),
|
||||
url(r'^translate/$', translate_text, name='translate_text'),
|
||||
]
|
||||
|
|
|
|||
|
|
@ -119,7 +119,6 @@ def home(request):
|
|||
if entry:
|
||||
old_msgstr = entry.msgstr
|
||||
if plural_id is not None:
|
||||
#plural_string = fix_nls(entry.msgstr_plural[plural_id], value)
|
||||
plural_string = fix_nls(entry.msgid_plural, value)
|
||||
entry.msgstr_plural[plural_id] = plural_string
|
||||
else:
|
||||
|
|
@ -203,16 +202,16 @@ def home(request):
|
|||
if _request_request('query', False) and _request_request('query', '').strip():
|
||||
query = _request_request('query', '').strip()
|
||||
rx = re.compile(re.escape(query), re.IGNORECASE)
|
||||
paginator = Paginator([e for e in rosetta_i18n_pofile if not e.obsolete and rx.search(six.text_type(e.msgstr) + six.text_type(e.msgid) + u''.join([o[0] for o in e.occurrences]))], rosetta_settings.MESSAGES_PER_PAGE)
|
||||
paginator = Paginator([e_ for e_ in rosetta_i18n_pofile if not e_.obsolete and rx.search(six.text_type(e_.msgstr) + six.text_type(e_.msgid) + u''.join([o[0] for o in e_.occurrences]))], rosetta_settings.MESSAGES_PER_PAGE)
|
||||
else:
|
||||
if rosetta_i18n_filter == 'untranslated':
|
||||
paginator = Paginator(rosetta_i18n_pofile.untranslated_entries(), rosetta_settings.MESSAGES_PER_PAGE)
|
||||
elif rosetta_i18n_filter == 'translated':
|
||||
paginator = Paginator(rosetta_i18n_pofile.translated_entries(), rosetta_settings.MESSAGES_PER_PAGE)
|
||||
elif rosetta_i18n_filter == 'fuzzy':
|
||||
paginator = Paginator([e for e in rosetta_i18n_pofile.fuzzy_entries() if not e.obsolete], rosetta_settings.MESSAGES_PER_PAGE)
|
||||
paginator = Paginator([e_ for e_ in rosetta_i18n_pofile.fuzzy_entries() if not e_.obsolete], rosetta_settings.MESSAGES_PER_PAGE)
|
||||
else:
|
||||
paginator = Paginator([e for e in rosetta_i18n_pofile if not e.obsolete], rosetta_settings.MESSAGES_PER_PAGE)
|
||||
paginator = Paginator([e_ for e_ in rosetta_i18n_pofile if not e_.obsolete], rosetta_settings.MESSAGES_PER_PAGE)
|
||||
|
||||
if 'page' in request.GET and int(request.GET.get('page')) <= paginator.num_pages and int(request.GET.get('page')) > 0:
|
||||
page = int(request.GET.get('page'))
|
||||
|
|
|
|||
|
|
@ -1,26 +1,13 @@
|
|||
#!/usr/bin/env python
|
||||
import sys
|
||||
import os
|
||||
try:
|
||||
from django.core.management import execute_manager
|
||||
OLD_DJANGO = True
|
||||
except ImportError:
|
||||
from django.core.management import execute_from_command_line
|
||||
OLD_DJANGO = False
|
||||
|
||||
if OLD_DJANGO:
|
||||
try:
|
||||
import settings # Assumed to be in the same directory.
|
||||
except ImportError:
|
||||
sys.stderr.write("Error: Can't find the file 'settings.py' in the directory containing %r. It appears you've customized things.\nYou'll have to run django-admin.py, passing it your settings module.\n(If the file settings.py does indeed exist, it's causing an ImportError somehow.)\n" % __file__)
|
||||
sys.exit(1)
|
||||
|
||||
BASEDIR = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
|
||||
sys.path.insert(0, BASEDIR)
|
||||
import sys
|
||||
|
||||
if __name__ == "__main__":
|
||||
os.environ["DJANGO_SETTINGS_MODULE"] = "testproject.settings"
|
||||
if OLD_DJANGO:
|
||||
execute_manager(settings)
|
||||
else:
|
||||
execute_from_command_line(sys.argv)
|
||||
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
|
||||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "testproject.settings")
|
||||
|
||||
import django
|
||||
django.setup()
|
||||
|
||||
from django.core.management import execute_from_command_line
|
||||
execute_from_command_line(sys.argv)
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ TEST_DATABASE_CHARSET = "utf8"
|
|||
TEST_DATABASE_COLLATION = "utf8_general_ci"
|
||||
|
||||
DATABASE_SUPPORTS_TRANSACTIONS = True
|
||||
SETTINGS_MODULE = 'testproject.settings'
|
||||
|
||||
INSTALLED_APPS = [
|
||||
'django.contrib.auth',
|
||||
|
|
@ -46,8 +47,8 @@ INSTALLED_APPS = [
|
|||
'rosetta',
|
||||
]
|
||||
|
||||
# if django.VERSION[0:2] >= (1, 7):
|
||||
# INSTALLED_APPS.append('rosetta.tests.test_app.apps.TestAppConfig')
|
||||
if django.VERSION[0:2] >= (1, 7):
|
||||
INSTALLED_APPS.append('rosetta.tests.test_app.apps.TestAppConfig')
|
||||
|
||||
LANGUAGE_CODE = "en"
|
||||
|
||||
|
|
@ -80,7 +81,25 @@ STATIC_URL = '/static/'
|
|||
ROOT_URLCONF = 'testproject.urls'
|
||||
|
||||
DEBUG = True
|
||||
TEMPLATE_DEBUG = True
|
||||
|
||||
TEMPLATES = [
|
||||
{
|
||||
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
||||
'APP_DIRS': True,
|
||||
'OPTIONS': {
|
||||
'debug': False,
|
||||
'context_processors': (
|
||||
"django.contrib.auth.context_processors.auth",
|
||||
"django.template.context_processors.debug",
|
||||
"django.template.context_processors.i18n",
|
||||
"django.template.context_processors.media",
|
||||
"django.template.context_processors.static",
|
||||
"django.template.context_processors.tz",
|
||||
"django.contrib.messages.context_processors.messages"
|
||||
)
|
||||
}
|
||||
},
|
||||
]
|
||||
|
||||
STATIC_URL = '/static/'
|
||||
#SESSION_ENGINE = "django.contrib.sessions.backends.signed_cookies"
|
||||
|
|
|
|||
|
|
@ -1,23 +1,10 @@
|
|||
try:
|
||||
from django.conf.urls import patterns, include, url
|
||||
except ImportError:
|
||||
from django.conf.urls.defaults import patterns, include, url
|
||||
|
||||
from django.conf.urls import patterns, include, url
|
||||
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
|
||||
|
||||
# Uncomment the next two lines to enable the admin:
|
||||
from django.contrib import admin
|
||||
admin.autodiscover()
|
||||
|
||||
urlpatterns = patterns('',
|
||||
# Examples:
|
||||
# url(r'^$', 'testproject.views.home', name='home'),
|
||||
# url(r'^testproject/', include('testproject.foo.urls')),
|
||||
|
||||
# Uncomment the admin/doc line below to enable admin documentation:
|
||||
# url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
|
||||
|
||||
# Uncomment the next line to enable the admin:
|
||||
urlpatterns = patterns(
|
||||
'',
|
||||
url(r'^admin/', include(admin.site.urls)),
|
||||
url(r'^rosetta/', include('rosetta.urls'))
|
||||
)
|
||||
|
|
|
|||
14
tox.ini
14
tox.ini
|
|
@ -1,8 +1,7 @@
|
|||
[tox]
|
||||
envlist =
|
||||
{py26,py27}-django14,
|
||||
{py26,py27,py34}-django{15,16},
|
||||
{py27,py34}-django{17,18},
|
||||
py27-django17,
|
||||
{py27,py35}-django{18,19},
|
||||
gettext,docs
|
||||
|
||||
skipsdist = True
|
||||
|
|
@ -17,13 +16,12 @@ setenv =
|
|||
PYTHONDONTWRITEBYTECODE=1
|
||||
|
||||
deps =
|
||||
django14: Django==1.4.22
|
||||
django15: Django==1.5.12
|
||||
django16: Django==1.6.11
|
||||
django17: Django==1.7.10
|
||||
django18: Django==1.8.4
|
||||
{py26,py27}-django{14,15,16,17,18}: python-memcached
|
||||
py34-django{14,15,16,17,18}: python3-memcached
|
||||
django19: Django==1.9a1
|
||||
py27-django{17,18,19}: python-memcached
|
||||
py35-django{17,18,19}: python3-memcached
|
||||
py27-django18: pudb
|
||||
requests
|
||||
polib>=1.0.6
|
||||
microsofttranslator==0.5
|
||||
|
|
|
|||
Loading…
Reference in a new issue