예제 #1
0
파일: edit.py 프로젝트: Yixf-Self/weblate
def check_suggestion_permissions(request, mode, translation):
    """
    Checks permission for suggestion handling.
    """
    if mode in ('accept', 'accept_edit'):
        if not can_accept_suggestion(request.user, translation):
            messages.error(
                request,
                _('You do not have privilege to accept suggestions!')
            )
            return False
    elif mode == 'delete':
        if not can_delete_suggestion(request.user, translation):
            messages.error(
                request,
                _('You do not have privilege to delete suggestions!')
            )
            return False
    elif mode in ('upvode', 'downvote'):
        if not can_vote_suggestion(request.user, translation):
            messages.error(
                request,
                _('You do not have privilege to vote for suggestions!')
            )
            return False
    return True
예제 #2
0
파일: edit.py 프로젝트: fwalch/weblate
def check_suggestion_permissions(request, mode, translation):
    """
    Checks permission for suggestion handling.
    """
    if mode in ('accept', 'accept_edit'):
        if not can_accept_suggestion(request.user, translation):
            messages.error(
                request,
                _('You do not have privilege to accept suggestions!')
            )
            return False
    elif mode == 'delete':
        if not can_delete_suggestion(request.user, translation):
            messages.error(
                request,
                _('You do not have privilege to delete suggestions!')
            )
            return False
    elif mode in ('upvode', 'downvote'):
        if not can_vote_suggestion(request.user, translation):
            messages.error(
                request,
                _('You do not have privilege to vote for suggestions!')
            )
            return False
    return True
예제 #3
0
파일: edit.py 프로젝트: addaleax/weblate
def check_suggestion_permissions(request, mode, translation):
    """
    Checks permission for suggestion handling.
    """
    if (translation.is_template() and not
            request.user.has_perm('trans.save_template')):
        # Need privilege to save
        messages.error(
            request,
            _('You don\'t have privileges to save templates!')
        )
        return False
    if mode in ('accept', 'accept_edit'):
        if not can_accept_suggestion(request.user, translation):
            messages.error(
                request,
                _('You do not have privilege to accept suggestions!')
            )
            return False
    elif mode == 'delete':
        if not can_delete_suggestion(request.user, translation):
            messages.error(
                request,
                _('You do not have privilege to delete suggestions!')
            )
            return False
    elif mode in ('upvode', 'downvote'):
        if not can_vote_suggestion(request.user, translation):
            messages.error(
                request,
                _('You do not have privilege to vote for suggestions!')
            )
            return False
    return True
예제 #4
0
파일: edit.py 프로젝트: matejcik/weblate
def check_suggestion_permissions(request, mode, translation):
    """
    Checks permission for suggestion handling.
    """
    if mode in ("accept", "accept_edit"):
        if not can_accept_suggestion(request.user, translation):
            messages.error(request, _("You do not have privilege to accept suggestions!"))
            return False
    elif mode == "delete":
        if not can_delete_suggestion(request.user, translation):
            messages.error(request, _("You do not have privilege to delete suggestions!"))
            return False
    elif mode in ("upvode", "downvote"):
        if not can_vote_suggestion(request.user, translation):
            messages.error(request, _("You do not have privilege to vote for suggestions!"))
            return False
    return True