Пример #1
0
 def callback(cls, request, result, context):
     destination = reverse(context['destination'])
     ban_submission = BanSubmission.objects.get(pk=result)
     ban_submission_items = ban_submission.items.all()
     successful_items_count = len(
         [item for item in ban_submission_items if item.success])
     if successful_items_count < len(ban_submission_items):
         return [
             commands.modal(
                 'varnish-bans-manager/core/bans/submit_errors.html', {
                     'expression':
                     ban_submission.expression,
                     'submissions':
                     successful_items_count,
                     'errors': [
                         item for item in ban_submission_items
                         if not item.success
                     ],
                     'destination':
                     destination,
                 },
                 context_instance=RequestContext(request))
         ]
     else:
         messages.success(
             request,
             ungettext(
                 'Your ban has been submitted and successfully processed by '
                 '%(count)d cache.',
                 'Your ban has been submitted and successfully processed by '
                 '%(count)d caches.', successful_items_count) %
             {'count': successful_items_count})
         return [
             commands.navigate(destination),
         ]
Пример #2
0
 def callback(cls, request, result, context):
     destination = reverse(context['destination'])
     ban_submission = BanSubmission.objects.get(pk=result)
     ban_submission_items = ban_submission.items.all()
     successful_items_count = len([
         item for item in ban_submission_items if item.success])
     if successful_items_count < len(ban_submission_items):
         return [
             commands.modal(
                 'varnish-bans-manager/core/bans/submit_errors.html', {
                     'expression': ban_submission.expression,
                     'submissions': successful_items_count,
                     'errors': [
                         item
                         for item in ban_submission_items
                         if not item.success
                     ],
                     'destination': destination,
                 }, context_instance=RequestContext(request))
         ]
     else:
         messages.success(request, ungettext(
             'Your ban has been submitted and successfully processed by '
             '%(count)d cache.',
             'Your ban has been submitted and successfully processed by '
             '%(count)d caches.',
             successful_items_count) % {'count': successful_items_count})
         return [
             commands.navigate(destination),
         ]
Пример #3
0
 def callback(cls, request, result, context):
     if result['deleted'] == 1:
         messages.success(request, _('The user has been deleted.'))
     else:
         messages.error(request, DEFAULT_ERROR_MESSAGE)
     return [
         commands.navigate(context['destination']),
     ]
Пример #4
0
 def callback(cls, request, result, context):
     if result['deleted'] == 1:
         messages.success(request, _('The user has been deleted.'))
     else:
         messages.error(request, DEFAULT_ERROR_MESSAGE)
     return [
         commands.navigate(context['destination']),
     ]
Пример #5
0
 def post(self, request, group):
     try:
         group.delete()
         messages.success(request, _('The group has been deleted. Its nodes are no longer assigned to any group.'))
     except:
         messages.error(request, DEFAULT_ERROR_MESSAGE)
     return HttpResponseAjax([
         commands.navigate(reverse('caches-browse')),
     ], request)
Пример #6
0
 def post(self, request, node):
     try:
         node.delete()
         messages.success(request, _('The node has been deleted.'))
     except:
         messages.error(request, DEFAULT_ERROR_MESSAGE)
     return HttpResponseAjax([
         commands.navigate(reverse('caches-browse')),
     ], request)
Пример #7
0
 def post(self, request):
     form = GeneralForm(data=request.POST)
     if form.is_valid():
         form.save()
         messages.success(request, DEFAULT_SUCCESS_MESSAGE)
         return HttpResponseAjax([commands.navigate(reverse("settings-general"))], request)
     else:
         messages.error(request, DEFAULT_FORM_ERROR_MESSAGE)
         return self._render(form=form)
Пример #8
0
 def post(self, request, node):
     try:
         node.delete()
         messages.success(request, _('The node has been deleted.'))
     except:
         messages.error(request, DEFAULT_ERROR_MESSAGE)
     return HttpResponseAjax([
         commands.navigate(reverse('caches-browse')),
     ], request)
Пример #9
0
 def post(self, request, group):
     form = UpdateForm(data=request.POST, instance=group)
     if form.is_valid():
         form.save()
         messages.success(request, DEFAULT_SUCCESS_MESSAGE)
         return HttpResponseAjax([
             commands.navigate(reverse('caches-browse')),
         ], request)
     else:
         messages.error(request, DEFAULT_FORM_ERROR_MESSAGE)
         return self._render(form)
Пример #10
0
 def post(self, request, user):
     form = UpdateForm(user, data=request.POST, files=request.FILES)
     if form.is_valid():
         form.save()
         messages.success(request, DEFAULT_SUCCESS_MESSAGE)
         return HttpResponseAjax([
             commands.navigate(reverse('users-browse')),
         ], request)
     else:
         messages.error(request, DEFAULT_FORM_ERROR_MESSAGE)
         return self._render(form, user)
Пример #11
0
 def post(self, request, user):
     form = UpdateForm(user, data=request.POST, files=request.FILES)
     if form.is_valid():
         form.save()
         messages.success(request, DEFAULT_SUCCESS_MESSAGE)
         return HttpResponseAjax([
             commands.navigate(reverse('users-browse')),
         ], request)
     else:
         messages.error(request, DEFAULT_FORM_ERROR_MESSAGE)
         return self._render(form, user)
Пример #12
0
 def post(self, request):
     form = GeneralForm(data=request.POST)
     if form.is_valid():
         form.save()
         messages.success(request, DEFAULT_SUCCESS_MESSAGE)
         return HttpResponseAjax([
             commands.navigate(reverse('settings-general')),
         ], request)
     else:
         messages.error(request, DEFAULT_FORM_ERROR_MESSAGE)
         return self._render(form=form)
Пример #13
0
 def post(self, request, node):
     form = UpdateForm(data=request.POST, instance=node)
     if form.is_valid():
         form.save()
         messages.success(request, DEFAULT_SUCCESS_MESSAGE)
         return HttpResponseAjax([
             commands.navigate(reverse('caches-browse')),
         ], request)
     else:
         messages.error(request, DEFAULT_FORM_ERROR_MESSAGE)
         return self._render(form)
Пример #14
0
 def post(self, request, group):
     try:
         group.delete()
         messages.success(
             request,
             _('The group has been deleted. Its nodes are no longer assigned '
               'to any group.'))
     except:
         messages.error(request, DEFAULT_ERROR_MESSAGE)
     return HttpResponseAjax([
         commands.navigate(reverse('caches-browse')),
     ], request)
Пример #15
0
    def post(self, request, user):
        form = PasswordResetConfirmationForm(user, data=request.POST)
        if form.is_valid():
            # Save.
            form.save()

            # Done!
            messages.success(request, _('Your password has been updated.'))
            return HttpResponseAjax([
                commands.navigate(reverse('user-login')),
            ], request)
        else:
            return self._render(form, request)
Пример #16
0
    def post(self, request, user):
        form = PasswordResetConfirmationForm(user, data=request.POST)
        if form.is_valid():
            # Save.
            form.save()

            # Done!
            messages.success(request, _('Your password has been updated.'))
            return HttpResponseAjax([
                commands.navigate(reverse('user-login')),
            ], request)
        else:
            return self._render(form, request)
Пример #17
0
 def delete_callback(cls, request, result, context):
     if result['errors'] == 0:
         messages.success(request, ungettext(
             '%(count)d user has been deleted.',
             '%(count)d users have been deleted.',
             result['deleted']) % {'count': result['deleted']})
     else:
         messages.error(request, ungettext(
             'Failed to delete %(count)d user.',
             'Failed to delete %(count)d users.',
             result['errors']) % {'count': result['errors']})
     return [
         commands.navigate(context['destination']),
     ]
Пример #18
0
    def post(self, request):
        form = PasswordResetForm(data=request.POST)
        if form.is_valid():
            # Save.
            form.save(request)

            # Done!
            messages.success(request, _('An e-mail with password reset instructions has been '
                'delivered to %(email)s. Please, check your inbox and follow the instructions.') %
                {'email': form.user.email})
            return HttpResponseAjax([
                commands.navigate(reverse('user-login')),
            ], request)
        else:
            return self._render(form)
Пример #19
0
 def delete_callback(cls, request, result, context):
     if result['errors'] == 0:
         messages.success(
             request,
             ungettext('%(count)d user has been deleted.',
                       '%(count)d users have been deleted.',
                       result['deleted']) % {'count': result['deleted']})
     else:
         messages.error(
             request,
             ungettext('Failed to delete %(count)d user.',
                       'Failed to delete %(count)d users.',
                       result['errors']) % {'count': result['errors']})
     return [
         commands.navigate(context['destination']),
     ]
Пример #20
0
    def post(self, request):
        form = PasswordResetForm(data=request.POST)
        if form.is_valid():
            # Save.
            form.save(request)

            # Done!
            messages.success(
                request,
                _('An e-mail with password reset instructions has been '
                  'delivered to %(email)s. Please, check your inbox and '
                  'follow the instructions.') % {'email': form.user.email})
            return HttpResponseAjax([
                commands.navigate(reverse('user-login')),
            ], request)
        else:
            return self._render(form)