How to use the weblate.utils.messages.success function in weblate

To help you get started, we’ve selected a few weblate examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github WeblateOrg / weblate / weblate / accounts / views.py View on Github external
if hasattr(form, 'audit'):
                    form.audit(request)
                form.save()

            # Change language
            set_lang(request, request.user.profile)

            # Redirect after saving (and possibly changing language)
            response = redirect_profile(request.POST.get('activetab'))

            # Set language cookie and activate new language (for message below)
            lang_code = profile.language
            response.set_cookie(settings.LANGUAGE_COOKIE_NAME, lang_code)
            translation.activate(lang_code)

            messages.success(request, _('Your profile has been updated.'))

            return response
    else:
        if not request.user.has_usable_password() and 'email' in all_backends:
            messages.warning(
                request, render_to_string('accounts/password-warning.html')
            )

    social = request.user.social_auth.all()
    social_names = [assoc.provider for assoc in social]
    new_backends = [x for x in all_backends if x == 'email' or x not in social_names]
    license_projects = (
        Component.objects.filter(project__in=request.user.allowed_projects)
        .exclude(license='')
        .order_project()
    )
github WeblateOrg / weblate / weblate / screenshots / views.py View on Github external
def remove_source(request, pk):
    obj = get_screenshot(request, pk)

    obj.units.remove(request.POST['source'])

    messages.success(request, _('Source has been removed.'))

    return redirect(obj)
github WeblateOrg / weblate / weblate / trans / views / lock.py View on Github external
def unlock_component(request, project, component):
    obj = get_component(request, project, component)

    if not request.user.has_perm('component.lock', obj):
        raise PermissionDenied()

    obj.do_lock(request.user, False)

    messages.success(
        request,
        _('Component is now open for translation updates.')
    )

    return redirect_param(obj, '#repository')
github WeblateOrg / weblate / weblate / trans / views / settings.py View on Github external
def change_component(request, project, component):
    obj = get_component(request, project, component)

    if not request.user.has_perm('component.edit', obj):
        raise Http404()

    if request.method == 'POST':
        form = ComponentSettingsForm(request, request.POST, instance=obj)
        if form.is_valid():
            form.save()
            messages.success(request, _('Settings saved'))
            return redirect(
                'settings', project=obj.project.slug, component=obj.slug
            )
        else:
            messages.error(
                request,
                _('Invalid settings, please check the form for errors!')
            )
    else:
        form = ComponentSettingsForm(request, instance=obj)

    return render(
        request,
        'component-settings.html',
        {
            'project': obj.project,
github WeblateOrg / weblate / weblate / trans / views / manage.py View on Github external
def remove_project(request, project):
    obj = get_project(request, project)

    if not request.user.has_perm('project.edit', obj):
        raise PermissionDenied()

    form = DeleteForm(obj, request.POST)
    if not form.is_valid():
        show_form_errors(request, form)
        return redirect_param(obj, '#delete')

    project_removal.delay(obj.pk, request.user.pk)
    messages.success(request, _('Project was scheduled for removal.'))
    return redirect('home')
github WeblateOrg / weblate / weblate / trans / views / lock.py View on Github external
def lock_component(request, project, component):
    obj = get_component(request, project, component)

    if not request.user.has_perm('component.lock', obj):
        raise PermissionDenied()

    obj.do_lock(request.user)

    messages.success(
        request,
        _('Component is now locked for translation updates!')
    )

    return redirect_param(obj, '#repository')
github WeblateOrg / weblate / weblate / trans / views / edit.py View on Github external
def comment(request, pk):
    """Add new comment."""
    scope = unit = get_object_or_404(Unit, pk=pk)
    request.user.check_access(unit.translation.component.project)

    if not request.user.has_perm('comment.add', unit.translation):
        raise PermissionDenied()

    form = CommentForm(request.POST)

    if form.is_valid():
        if form.cleaned_data['scope'] == 'global':
            scope = unit.source_info
        Comment.objects.add(scope, request.user, form.cleaned_data['comment'])
        messages.success(request, _('Posted new comment'))
    else:
        messages.error(request, _('Failed to add comment!'))

    return redirect_next(request.POST.get('next'), unit)
github WeblateOrg / weblate / weblate / wladmin / views.py View on Github external
form = BackupForm(request.POST)
            if form.is_valid():
                form.save()
                return redirect('manage-backups')
        elif 'remove' in request.POST:
            service = BackupService.objects.get(pk=request.POST['service'])
            service.delete()
            return redirect('manage-backups')
        elif 'toggle' in request.POST:
            service = BackupService.objects.get(pk=request.POST['service'])
            service.enabled = not service.enabled
            service.save()
            return redirect('manage-backups')
        elif 'trigger' in request.POST:
            backup_service.delay(pk=request.POST['service'])
            messages.success(request, _('Backup has been triggered'))
            return redirect('manage-backups')

    context = {
        'services': BackupService.objects.all(),
        'menu_items': MENU,
        'menu_page': 'backups',
        'form': form,
        'activate_form': ActivateForm(),
    }
    return render(request, "manage/backups.html", context)
github WeblateOrg / weblate / weblate / memory / views.py View on Github external
def form_valid(self, form):
        if not check_perm(self.request.user, 'memory.edit', self.objects):
            raise PermissionDenied()
        try:
            TranslationMemory.import_file(
                self.request, form.cleaned_data['file'], **self.objects
            )
            messages.success(
                self.request,
                _('File processed, the entries will appear shortly.')
            )
        except MemoryImportError as error:
            messages.error(self.request, force_text(error))
        return super(UploadView, self).form_valid(form)