示例#1
0
    def post(self, request):
        context = {}
        form = AppForm(request.POST)
        default, plans = self.plans(request)
        form.fields['plan'].choices = plans
        form.fields['platform'].choices = self.platforms(request)
        form.fields['teamOwner'].choices = self.teams(request)
        form.fields['pool'].choices = self.pools(request)
        if form.is_valid():
            authorization = {'authorization': request.session.get('tsuru_token')}

            data = form.data.dict()
            if data.get("plan"):
                data["plan"] = {"name": data["plan"]}

            data = json.dumps(data)

            url = '{}/apps'.format(settings.TSURU_HOST)
            response = requests.post(url, data=data, headers=authorization)

            if response.status_code == 200:
                messages.success(request, u"App was successfully created", fail_silently=True)
                return redirect(reverse('list-app'))

            context['errors'] = response.content

        form.fields['plan'].initial = default
        context['app_form'] = form
        return self.render(request, context)
示例#2
0
    def post(self, request):
        context = {}
        form = AppForm(request.POST)
        default, plans = self.plans(request)
        form.fields['plan'].choices = plans
        form.fields['platform'].choices = self.platforms(request)
        form.fields['teamOwner'].choices = self.teams(request)
        form.fields['pool'].choices = self.pools(request)
        if form.is_valid():
            authorization = {'authorization': request.session.get('tsuru_token')}

            # removing keys with empty values
            data = {key: value for key, value in form.cleaned_data.items() if value}

            if 'plan' in data:
                data['plan'] = {'name': data['plan']}

            data = json.dumps(data)

            url = '{}/apps'.format(settings.TSURU_HOST)
            response = requests.post(url, data=data, headers=authorization)

            if response.status_code == 200:
                messages.success(request, u'App was successfully created', fail_silently=True)
                return redirect(reverse('list-app'))

            messages.error(request, response.content, fail_silently=True)

        form.fields['plan'].initial = default
        context['app_form'] = form
        return self.render(request, context)
示例#3
0
文件: views.py 项目: hfeeki/abyss
 def post(self, request):
     context = {}
     form = AppForm(request.POST)
     if form.is_valid():
         authorization = {'authorization': request.session.get('tsuru_token')}
         response = requests.post('%s/apps' % settings.TSURU_HOST,
                 data=json.dumps(form.data),
                 headers=authorization)
         if response.status_code == 200:
             context.update({'message': "App was successfully created"})
         else:
             context.update({'errors': response.content})
     context.update({'app_form': form})
     return TemplateResponse(request, 'apps/create.html', context)
示例#4
0
   def step3(self,request):
 
       appform3=AppForm3()
       
       if request.is_ajax():
           form=AppForm(request.POST)
           if form.is_valid():
               
               if  form.save(request) :
                   messages.success(request,'You App is Created !')
                   return render_to_response("admin/partials/wizardform3.html",{'appform3':appform3 })
               else:
                   return render_to_response("admin/partials/wizardform3.html",{'appform3':appform3 })
           return render_to_response("admin/partials/wizardform3.html",{'appform3':appform3})    
示例#5
0
 def post(self, request):
     context = {}
     form = AppForm(request.POST)
     if form.is_valid():
         authorization = {
             'authorization': request.session.get('tsuru_token')
         }
         response = requests.post('%s/apps' % settings.TSURU_HOST,
                                  data=json.dumps(form.data),
                                  headers=authorization)
         if response.status_code == 200:
             context['message'] = "App was successfully created"
             context['platforms'] = self._get_platforms(request)
         else:
             context['errors'] = response.content
             context['platforms'] = self._get_platforms(request)
     else:
         context['platforms'] = self._get_platforms(request)
     context['app_form'] = form
     return TemplateResponse(request, 'apps/create.html', context)
示例#6
0
 def get(self, request):
     form = AppForm()
     default, plans = self.plans(request)
     form.fields['plan'].choices = plans
     form.fields['plan'].initial = default
     form.fields['platform'].choices = self.platforms(request)
     form.fields['teamOwner'].choices = self.teams(request)
     form.fields['pool'].choices = self.pools(request)
     context = {
         'app_form': form,
     }
     return self.render(request, context)
示例#7
0
def manageApk(request):
    if request.method == 'POST':
        appForm = AppForm(request.POST, request.FILES)
        if appForm.is_valid():
            appForm.save()

    fun = request.GET.get('fun')
    id = request.GET.get('id')
    if fun:
        if fun == 'del' and id:
            try:
                apk = Apk.objects.get(id=id)
                apk.delete()
            except Exception as e:
                pass

    files = Apk.objects.all()
    context = {
        'appForm': AppForm(),
        'files': files,
        'records': getRecords(),
        'checkIp': checkIp(),
    }
    updateRecordsIp()
    return render(request, 'manageApk.html', context)
示例#8
0
    def post(self, request):
        context = {}
        form = AppForm(request.POST)
        default, plans = self.plans(request)
        form.fields['plan'].choices = plans
        form.fields['platform'].choices = self.platforms(request)
        form.fields['teamOwner'].choices = self.teams(request)
        form.fields['pool'].choices = self.pools(request)
        if form.is_valid():
            authorization = {
                'authorization': request.session.get('tsuru_token')
            }

            # removing keys with empty values
            data = {
                key: value
                for key, value in form.cleaned_data.items() if value
            }

            if 'plan' in data:
                data['plan'] = {'name': data['plan']}

            data = json.dumps(data)

            url = '{}/apps'.format(settings.TSURU_HOST)
            response = requests.post(url, data=data, headers=authorization)

            if response.status_code == 200:
                messages.success(request,
                                 u'App was successfully created',
                                 fail_silently=True)
                return redirect(reverse('list-app'))

            messages.error(request, response.content, fail_silently=True)

        form.fields['plan'].initial = default
        context['app_form'] = form
        return self.render(request, context)
示例#9
0
 def get(self, request):
     context = {
         "app_form": AppForm(),
         "platforms": self._get_platforms(request),
     }
     return TemplateResponse(request, "apps/create.html", context)