CRM权限管理报名流程3-销售审核信息
Posted fqh202
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了CRM权限管理报名流程3-销售审核信息相关的知识,希望对你有一定的参考价值。
审核列表
urls
from django.conf.urls import url,include
from crm import views
urlpatterns = [
url(r'^audit_list/$', views.audit_list, name='audit_list'),
]
views.py
from django.shortcuts import render
@login_required
def audit_list(request):
"""待审核学员列表页面"""
# 1、直接从 StudentEnrollment 筛选出所有同意合同但是没有审核通过的对象
audit_stu_list = StudentEnrollment.objects.filter(contract_agreed=1,contract_approved=0)
return render(request,'crm/audit_list.html',locals())
audit_list.html
# 页面1
<table class="table table-bordered">
<thead>
<tr>
<td>学号</td>
<td >姓名</td>
<td >班级</td>
</tr>
</thead>
<tbody>
{% for stu in audit_stu_list %}
<tr>
<td><a href="{% url 'audit' stu.id %}">{{ stu.id }}</a></td>
<td>{{ stu.customer.name }}</td>
<td>{{ stu.class_grade }}</td>
</tr>
{% endfor %}
</tbody>
</table>
审核详情页
urls.py
from django.conf.urls import url,include
from crm import views
urlpatterns = [
url(r'^audit_list/(d+)/$', views.audit, name='audit')
]
forms.py
class StudentEnrollForm(ModelForm):
"""信息完善form"""
class Meta:
model = StudentEnrollment
fields = '__all__'
readonly_fields = ['customer', 'consultant', 'class_grade', 'contract_agreed', 'contract_signed_time']
def __new__(cls, *args, **kwargs):
"""方法2:在实例化类对象(model_form())的时候给input框增加样式"""
for field_name, field_obj in cls.base_fields.items():
field_obj.widget.attrs.update({'class': 'form-control'})
# 设定只读字段disabled属性
if field_name in cls.Meta.readonly_fields:
field_obj.widget.attrs.update({'disabled': True})
return ModelForm.__new__(cls)
views.py
from django.shortcuts import render
from django.contrib.auth.decorators import login_required
from crm.models import StudentEnrollment
@login_required
def audit(request,id):
"""审核学员"""
student_enroll = StudentEnrollment.objects.filter(id=int(id)).first()
customer_obj = student_enroll.customer
from .forms import StudentEnrollForm
student_enroll_form = StudentEnrollForm(instance=student_enroll)
if request.method=='POST':
student_enroll_form = StudentEnrollForm(instance=student_enroll,data=request.POST)
if student_enroll.contract_approved:
return HttpResponse('该学员已经通过审核')
if student_enroll_form.data.get('contract_approved',''):
student_enroll.contract_approved=True
student_enroll.contract_approved_time=datetime.datetime.now()
# 修改咨询客户的报名状态
customer_obj.status=1
customer_obj.save()
student_enroll.save()
return redirect('/crm/audit_list/')
return render(request,'crm/audit_student_enroll.html',locals())
前端页面
<form method="post">
{% csrf_token %}
{% for input_obj in student_enroll_form %}
<div class="form-group">
<label for="inputEmail3" class="col-sm-2 control-label">{{ input_obj.label }}</label>
<div class="col-sm-10">
{{ input_obj }}
</div>
</div>
{% endfor %}
<input class="btn btn-success btn-block" type="submit" value="审核通过">
</form>
以上是关于CRM权限管理报名流程3-销售审核信息的主要内容,如果未能解决你的问题,请参考以下文章