Exemple #1
0
 def get_context_data(self, **kwargs):
     logger = logging.getLogger('webapp')
     logger.info('run get_context_data run')
     context = super(ListAreaView, self).get_context_data(**kwargs)
     context['object_list'] = list(Area.objects.all())
     new = Area()
     new.name = "new"
     context['object_list'].append(new)
     return context
Exemple #2
0
    def get_area(self, location_name, area_name):
        location = self.get_location(location_name)

        try:
            area = Area.objects.get(name=area_name, location=location)
        except:
            area = Area(name=area_name, location=location)
            area.save()

        return area
Exemple #3
0
def add(request):
    if request.POST:
        area_name = request.POST.get("name")
        
        # 保存区域信息
        area = Area();
        area.name = area_name
        area.save()
        
        # 生成对应的权限字段
        p = Permission()
        p.codename = area2AuthStr(area.id)
        p.desc = area.name + u'工单管理权限'
        p.type = 4
        p.save()
        
        return HttpResponse(simplejson.dumps({"statusCode":200,"url": "/area/index", "message":u'添加成功'}), mimetype='application/json')
    return render_to_response('area/add.html')
Exemple #4
0
def handle_area(request):
    logger = logging.getLogger('webapp')
    logger.info('run handle_area run')

    if request.method == 'POST':

        form = AreaForm(request.POST, request.FILES)

        if form.is_valid():
            a = Area()
            a.adminEmail = form.cleaned_data['adminEmail']
            a.areaStatus = form.cleaned_data['areaStatus']
            a.createdDate = form.cleaned_data['createdDate']
            a.folderName = form.cleaned_data['folderName']
            a.language = form.cleaned_data['language']
            a.logoFile = form.cleaned_data['logoFile']
            a.name = form.cleaned_data['name']
            a.paymentIntegration = form.cleaned_data['paymentIntegration']
            a.paymentId = form.cleaned_data['paymentId']
            a.plan = form.cleaned_data['plan']

            a.save()

            return HttpResponseRedirect('/areas/')

    else:
        form = AreaForm()
    return render(request, 'area/area_detail.html', {'form': form, 'action':'/area/', 'http_method':'POST'})