示例#1
0
文件: views.py 项目: athulcr/medclap
 def post(self, request, *args, **kwargs):
     form = Customerform(request.POST, request.FILES)
     if form.is_valid():
         form.save()
         return redirect('customerlist')
     else:
         return redirect('customercreate')
示例#2
0
文件: views.py 项目: athulcr/medclap
 def post(self, request, *args, **kwargs):
     id = kwargs.get("pk")
     qs = self.model.objects.get(id=id)
     form = Customerform(instance=qs, data=request.POST, files=request.FILES)
     if form.is_valid():
         form.save()
         return redirect('customerlist')
     else:
         return render(request, self.template_name, self.context)
示例#3
0
文件: views.py 项目: athulcr/medclap
class Customerdelete(DeleteView):
    model = Customerprofile
    template_name = "Customer/customerdelete.html"
    form_class = Customerform()
    context = {}

    def get(self, request, *args, **kwargs):
        id = kwargs.get("pk")
        qs = self.model.objects.get(id=id)
        self.context['form'] = Customerform(instance=qs)
        return render(request, self.template_name, self.context)

    def post(self, request, *args, **kwargs):
        id = kwargs.get("pk")
        qs = self.model.objects.get(id=id)
        qs.delete()
        return redirect('customerlist')      
示例#4
0
文件: views.py 项目: athulcr/medclap
class Customercreate(CreateView):
    model = Customerprofile
    form_class = Customerform()
    template_name = "Customer/customercreate.html"
    context = {}

    def get(self, request, *args, **kwargs):
        self.context['form'] = self.form_class
        return render(request, self.template_name, self.context)

    def post(self, request, *args, **kwargs):
        form = Customerform(request.POST, request.FILES)
        if form.is_valid():
            form.save()
            return redirect('customerlist')
        else:
            return redirect('customercreate')
示例#5
0
文件: views.py 项目: athulcr/medclap
class Customeredit(TemplateView):
    model = Customerprofile
    form_class = Customerform()
    template_name = "Customer/customeredit.html"
    context = {}

    def get(self, request, *args, **kwargs):
        id = kwargs.get('pk')
        qs = self.model.objects.get(id=id)
        form = Customerform(instance=qs)
        self.context['form'] = form
        return render(request, self.template_name, self.context)

    def post(self, request, *args, **kwargs):
        id = kwargs.get("pk")
        qs = self.model.objects.get(id=id)
        form = Customerform(instance=qs, data=request.POST, files=request.FILES)
        if form.is_valid():
            form.save()
            return redirect('customerlist')
        else:
            return render(request, self.template_name, self.context)
示例#6
0
文件: views.py 项目: athulcr/medclap
 def get(self, request, *args, **kwargs):
     id = kwargs.get('pk')
     qs = self.model.objects.get(id=id)
     form = Customerform(instance=qs)
     self.context['form'] = form
     return render(request, self.template_name, self.context)