예제 #1
0
def launch_build(request, build_name):
    context = {}
    if request.method == 'POST':
        name = request.POST.get('name')
        build = Build.objects.get(name=build_name)
        result = build_task.delay(build, name)
        context['result'] = result
    template = 'aws/build.html'
    return render(request, template, context)
예제 #2
0
    def launch_view(self, request):
        LaunchForm = modelform_factory(
            Build,
            exclude=('name', ),
            widgets={'security_groups': forms.CheckboxSelectMultiple()})
        if request.method == 'POST':
            form = LaunchForm(request.POST)
            if form.is_valid():
                # What to do, what to do
                # ...
                result = build_task.delay(form=form)
                return HttpResponseRedirect(
                    '/admin/aws/instance/launching/?id=%s' %
                    result)  # Redirect after POST
        else:
            form = LaunchForm()

        context = {
            'current_app': self.admin_site.name,
            'app_label': 'aws',
            'form': form,
        }
        template = 'admin/aws/instance/launch.html'
        return render(request, template, context)