mirror of
https://github.com/Hopiu/django-rosetta.git
synced 2026-05-28 13:58:19 +00:00
removed quite a few warnings on Django 1.8
This commit is contained in:
parent
ba5b821e3c
commit
67f5803687
5 changed files with 36 additions and 14 deletions
|
|
@ -1,7 +1,10 @@
|
|||
from django.conf import settings
|
||||
from rosetta.conf import settings as rosetta_settings
|
||||
|
||||
from django.utils import importlib
|
||||
try:
|
||||
import importlib
|
||||
except ImportError:
|
||||
from django.utils import importlib
|
||||
|
||||
|
||||
def can_translate(user):
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ ROSETTA_CACHE_NAME = getattr(settings, 'ROSETTA_CACHE_NAME', 'default'
|
|||
ROSETTA_REQUIRES_AUTH = getattr(settings, 'ROSETTA_REQUIRES_AUTH', True)
|
||||
|
||||
# Exclude paths defined in this list from being searched (usually ends with "locale")
|
||||
ROSETTA_EXCLUDED_PATHS = getattr(settings, 'ROSETTA_EXCLUDED_PATHS', ())
|
||||
ROSETTA_EXCLUDED_PATHS = getattr(settings, 'ROSETTA_EXCLUDED_PATHS', ())
|
||||
|
||||
# Set to True to enable language-specific groups, which can be used to give
|
||||
# different translators access to different languages. Instead of creating a
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
from datetime import datetime
|
||||
from django.conf import settings
|
||||
from django.core.cache import get_cache
|
||||
from rosetta.conf import settings as rosetta_settings
|
||||
import django
|
||||
import os
|
||||
|
|
@ -20,7 +19,12 @@ if django.VERSION[0:2] >= (1, 7):
|
|||
from django.apps import AppConfig
|
||||
from django.apps import apps
|
||||
|
||||
cache = get_cache(rosetta_settings.ROSETTA_CACHE_NAME)
|
||||
try:
|
||||
from django.core.cache import caches
|
||||
cache = caches[rosetta_settings.ROSETTA_CACHE_NAME]
|
||||
except ImportError:
|
||||
from django.core.cache import get_cache
|
||||
cache = get_cache(rosetta_settings.ROSETTA_CACHE_NAME)
|
||||
|
||||
|
||||
def timestamp_with_timezone(dt=None):
|
||||
|
|
|
|||
|
|
@ -1,6 +1,4 @@
|
|||
from django.core.cache import get_cache
|
||||
from django.conf import settings
|
||||
from django.utils import importlib
|
||||
from django.core.exceptions import ImproperlyConfigured
|
||||
from rosetta.conf import settings as rosetta_settings
|
||||
import hashlib
|
||||
|
|
@ -9,7 +7,17 @@ import six
|
|||
import django
|
||||
|
||||
|
||||
cache = get_cache(rosetta_settings.ROSETTA_CACHE_NAME)
|
||||
try:
|
||||
from django.core.cache import caches
|
||||
cache = caches[rosetta_settings.ROSETTA_CACHE_NAME]
|
||||
except ImportError:
|
||||
from django.core.cache import get_cache
|
||||
cache = get_cache(rosetta_settings.ROSETTA_CACHE_NAME)
|
||||
|
||||
try:
|
||||
import importlib
|
||||
except ImportError:
|
||||
from django.utils import importlib
|
||||
|
||||
|
||||
class BaseRosettaStorage(object):
|
||||
|
|
|
|||
|
|
@ -54,6 +54,13 @@ def home(request):
|
|||
out_ = out_.rstrip()
|
||||
return out_
|
||||
|
||||
def _request_request(key, default=None):
|
||||
if key in request.GET:
|
||||
return request.GET.get(key)
|
||||
elif key in request.POST:
|
||||
return request.POST.get(key)
|
||||
return default
|
||||
|
||||
storage = get_storage(request)
|
||||
query = ''
|
||||
if storage.has('rosetta_i18n_fn'):
|
||||
|
|
@ -67,8 +74,8 @@ def home(request):
|
|||
for entry in rosetta_i18n_pofile:
|
||||
entry.md5hash = hashlib.md5(
|
||||
(six.text_type(entry.msgid) +
|
||||
six.text_type(entry.msgstr) +
|
||||
six.text_type(entry.msgctxt or "")).encode('utf8')
|
||||
six.text_type(entry.msgstr) +
|
||||
six.text_type(entry.msgctxt or "")).encode('utf8')
|
||||
).hexdigest()
|
||||
|
||||
else:
|
||||
|
|
@ -163,7 +170,7 @@ def home(request):
|
|||
'mod_wsgi.process_group' in request.environ and \
|
||||
request.environ.get('mod_wsgi.process_group', None) and \
|
||||
'SCRIPT_FILENAME' in request.environ and \
|
||||
int(request.environ.get('mod_wsgi.script_reloading', '0')):
|
||||
int(request.environ.get('mod_wsgi.script_reloading', '0')):
|
||||
try:
|
||||
os.utime(request.environ.get('SCRIPT_FILENAME'), None)
|
||||
except OSError:
|
||||
|
|
@ -184,15 +191,15 @@ def home(request):
|
|||
|
||||
# Retain query arguments
|
||||
query_arg = '?_next=1'
|
||||
if 'query' in request.GET or 'query' in request.POST:
|
||||
query_arg += '&query=%s' % request.REQUEST.get('query')
|
||||
if _request_request('query', False):
|
||||
query_arg += '&query=%s' % _request_request('query')
|
||||
if 'page' in request.GET:
|
||||
query_arg += '&page=%d&_next=1' % int(request.GET.get('page'))
|
||||
return HttpResponseRedirect(reverse('rosetta-home') + iri_to_uri(query_arg))
|
||||
rosetta_i18n_lang_code = storage.get('rosetta_i18n_lang_code')
|
||||
|
||||
if 'query' in request.REQUEST and request.REQUEST.get('query', '').strip():
|
||||
query = request.REQUEST.get('query').strip()
|
||||
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)
|
||||
else:
|
||||
|
|
|
|||
Loading…
Reference in a new issue