Commit 40c9b935 authored by Michal Čihař's avatar Michal Čihař

Do not allow users without email to edit translations

We need this for VCS commits.
Signed-off-by: default avatarMichal Čihař <michal@cihar.com>
parent c177c4da
......@@ -29,6 +29,7 @@ from django.db import models
from django.dispatch import receiver
from django.conf import settings
from django.contrib.auth.signals import user_logged_in, user_logged_out
from django.contrib import messages
from django.db.models.signals import post_save, post_migrate
from django.utils.translation import ugettext_lazy as _
from django.utils.encoding import python_2_unicode_compatible, force_text
......@@ -863,6 +864,16 @@ def post_login_handler(sender, request, user, **kwargs):
# Set language for session based on preferences
set_lang(request, profile)
# Warn about not set email
if not user.email:
messages.error(
request,
_(
'You can not submit translations as '
'you do not have assigned any email address.'
)
)
@receiver(user_logged_out)
def post_logout_handler(sender, request, user, **kwargs):
......
......@@ -121,6 +121,8 @@ def can_edit(user, translation, permission):
"""
if translation.subproject.locked:
return False
if not user.email:
return False
if check_owner(user, translation.subproject.project, permission):
return True
if not has_group_perm(user, permission, translation):
......
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