Commit be5765f9 authored by Weblate's avatar Weblate

Merge remote-tracking branch 'origin/master'

parents 831ff127 472d5440
......@@ -20,12 +20,16 @@
from django.shortcuts import redirect
from django.core.urlresolvers import reverse
from django.contrib.auth.models import User
from django.utils.translation import ugettext as _
import urllib2
import json
from social.pipeline.partial import partial
from social.exceptions import AuthForbidden, AuthMissingParameter
from social.exceptions import (
AuthException, AuthMissingParameter, AuthAlreadyAssociated
)
from weblate.accounts.models import send_notification_email, VerifiedEmail
from weblate import appsettings
......@@ -118,7 +122,21 @@ def verify_open(strategy, backend, user=None, **kwargs):
'''
if not user and not appsettings.REGISTRATION_OPEN:
raise AuthForbidden(backend)
raise AuthException(backend, _('New registrations are disabled!'))
def verify_username(strategy, backend, user, social, details, **kwargs):
"""Verified whether username is still free.
It can happen that user has registered several times or other user has
taken the username meanwhile.
"""
if not user and 'username' in details:
if User.objects.filter(username__iexact=details['username']).exists():
raise AuthAlreadyAssociated(
backend,
_('This username is already taken. Please choose another.')
)
def store_email(strategy, backend, user, social, details, **kwargs):
......
......@@ -224,6 +224,7 @@ SOCIAL_AUTH_PIPELINE = (
'social.pipeline.mail.mail_validation',
'social.pipeline.social_auth.associate_by_email',
'weblate.accounts.pipeline.verify_open',
'weblate.accounts.pipeline.verify_username',
'social.pipeline.user.create_user',
'social.pipeline.social_auth.associate_user',
'social.pipeline.social_auth.load_extra_data',
......
......@@ -197,6 +197,7 @@ SAME_BLACKLIST = frozenset((
'expert',
'explore',
'export',
'expression',
'extension',
'extra',
'extras',
......@@ -397,6 +398,7 @@ SAME_BLACKLIST = frozenset((
'message',
'messages',
'meta',
'metadata',
'metal',
'metre',
'metres',
......@@ -476,6 +478,8 @@ SAME_BLACKLIST = frozenset((
'park',
'parking',
'partition',
'partitions',
'parser',
'party',
'password',
'pause',
......@@ -1131,7 +1135,8 @@ class SameCheck(TargetCheck):
def check_single(self, source, target, unit, cache_slot):
# English variants will have most things not translated
if self.is_language(unit, ('en', )):
# Interlingua is also quite often similar to English
if self.is_language(unit, ('en', 'ia')):
return False
# One letter things are usually labels or decimal/thousand separators
......
......@@ -760,13 +760,16 @@ class CheckFlagsForm(forms.Form):
flags = forms.CharField(
label=_('Check flags'),
required=False,
help_text=_(
)
def __init__(self, *args, **kwargs):
super(CheckFlagsForm, self).__init__(*args, **kwargs)
self.fields['flags'].help_text = ugettext(
'Please enter a comma separated list of check flags, '
'see <a href="{url}">documentation</a> for more details.'
).format(
url=weblate.get_doc_url('admin/checks', 'custom-checks')
)
)
def clean_flags(self):
"""
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment