Beispiel #1
0
    def post(self, request, pk):
        domain = get_object_or_404(request.website.ndds, pk=pk)

        if 'primary' in request.POST:
            request.website.domain = domain
            request.website.save()
            response = Response(status.HTTP_202_ACCEPTED, 
                                {'location': 'http://%s%s#admin' % 
                                 (domain.domain, request.page.get_absolute_url())})
        else:
            form = DomainWAForm(request.POST, instance=domain)

            if form.is_valid():
                form.save()
                response = Response(status.HTTP_200_OK, {'msg': MESSAGES.get('item_edit_success', "")})
            else:
                html = render_to_string('administration/website/domain.html',
                                        {'form': form,
                                         'edit': True},
                                        context_instance = RequestContext(request))
                
                response = Response(status.HTTP_400_BAD_REQUEST,
                                    {"html": html,
                                     'msg': MESSAGES.get('default_error', "")})
        return self.render(response)
Beispiel #2
0
    def post(self, request, pk):
        domain = get_object_or_404(request.website.ndds, pk=pk)

        if 'primary' in request.POST:
            request.website.domain = domain
            request.website.save()
            response = Response(
                status.HTTP_202_ACCEPTED, {
                    'location':
                    'http://%s%s#admin' %
                    (domain.domain, request.page.get_absolute_url())
                })
        else:
            form = DomainWAForm(request.POST, instance=domain)

            if form.is_valid():
                form.save()
                response = Response(
                    status.HTTP_200_OK,
                    {'msg': MESSAGES.get('item_edit_success', "")})
            else:
                html = render_to_string(
                    'administration/website/domain.html', {
                        'form': form,
                        'edit': True
                    },
                    context_instance=RequestContext(request))

                response = Response(status.HTTP_400_BAD_REQUEST, {
                    "html": html,
                    'msg': MESSAGES.get('default_error', "")
                })
        return self.render(response)
Beispiel #3
0
    def get(self, request, pk=None):
        # Create the form
        if pk is None:
            form = DomainWAForm()
        else:
            site = get_object_or_404(request.website.ndds, pk=pk)
            form = DomainWAForm(instance=site)

        html = render_to_string('administration/website/domain.html', {
            'form': form,
            'edit': pk is not None
        },
                                context_instance=RequestContext(request))

        response = Response(status.HTTP_200_OK, {"html": html})
        return self.render(response)
Beispiel #4
0
    def put(self, request):
        form = DomainWAForm(self.DATA)
        
        if form.is_valid():
            site = form.save()
            request.website.ndds.add(site)
            response = Response(status.HTTP_200_OK, {'msg': MESSAGES.get('item_creation_success', "")})
        else:
            html = render_to_string('administration/website/domain.html',
                                    {'form': form,
                                     'edit': False},
                                    context_instance = RequestContext(request))

            response = Response(status.HTTP_400_BAD_REQUEST,
                                {"html": html,
                                 'msg': MESSAGES.get('default_error', "")})
        return self.render(response)
Beispiel #5
0
    def put(self, request):
        form = DomainWAForm(self.DATA)

        if form.is_valid():
            site = form.save()
            request.website.ndds.add(site)
            response = Response(
                status.HTTP_200_OK,
                {'msg': MESSAGES.get('item_creation_success', "")})
        else:
            html = render_to_string('administration/website/domain.html', {
                'form': form,
                'edit': False
            },
                                    context_instance=RequestContext(request))

            response = Response(status.HTTP_400_BAD_REQUEST, {
                "html": html,
                'msg': MESSAGES.get('default_error', "")
            })
        return self.render(response)