Django项目:CRM(客户关系管理系统)--70--60PerfectCRM实现CRM学生上课记录
Posted 颜言
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Django项目:CRM(客户关系管理系统)--70--60PerfectCRM实现CRM学生上课记录相关的知识,希望对你有一定的参考价值。
1 #urls.py 2 3 """PerfectCRM URL Configuration 4 5 The `urlpatterns` list routes URLs to views. For more information please see: 6 https://docs.djangoproject.com/en/2.0/topics/http/urls/ 7 Examples: 8 Function views 9 1. Add an import: from my_app import views 10 2. Add a URL to urlpatterns: path(\'\', views.home, name=\'home\') 11 Class-based views 12 1. Add an import: from other_app.views import Home 13 2. Add a URL to urlpatterns: path(\'\', Home.as_view(), name=\'home\') 14 Including another URLconf 15 1. Import the include() function: from django.urls import include, path 16 2. Add a URL to urlpatterns: path(\'blog/\', include(\'blog.urls\')) 17 """ 18 from django.contrib import admin 19 from django.urls import path 20 21 # ————————02PerfectCRM创建ADMIN页面———————— 22 from django.conf.urls import url # URL 23 from django.conf.urls import include # 分发URL 24 # ————————02PerfectCRM创建ADMIN页面———————— 25 26 # ————————46PerfectCRM实现登陆后页面才能访问———————— 27 from PerfectCRM import main_views 28 # ————————46PerfectCRM实现登陆后页面才能访问———————— 29 30 urlpatterns = [ 31 path(\'admin/\', admin.site.urls), 32 33 # ————————02PerfectCRM创建ADMIN页面———————— 34 url(r\'^king_admin/\', include("king_admin.king_urls")), # 自定义admin 35 # ————————02PerfectCRM创建ADMIN页面———————— 36 37 # ————————03PerfectCRM创建基本数据———————— 38 url(r\'^DBadd/\', include("DBadd.DBadd_urls")), # 添加随机数据 39 # ————————03PerfectCRM创建基本数据———————— 40 # ————————38PerfectCRM实现全局账号登录注销———————— 41 url(r\'^gbacc/\', include("gbacc.gbacc_urls")), # 全局账号登录注销 42 # ————————38PerfectCRM实现全局账号登录注销———————— 43 44 # ————————42PerfectCRM实现AJAX全局账号注册———————— 45 url(r\'^gbacc/\', include("gbacc.gbacc_ajax_urls")), # 全局账号登录注销 46 # ————————42PerfectCRM实现AJAX全局账号注册———————— 47 48 # ————————46PerfectCRM实现登陆后页面才能访问———————— 49 url(r\'^$\', main_views.PortalView.as_view()), 50 # ————————46PerfectCRM实现登陆后页面才能访问———————— 51 52 # ————————47PerfectCRM实现CRM客户报名流程———————— 53 url(r\'^bpm/\', include("bpm.sales.sales_urls")), # 业务流程 #学生报名 54 # ————————47PerfectCRM实现CRM客户报名流程———————— 55 56 # ————————53PerfectCRM实现CRM客户报名流程缴费———————— 57 url(r\'^bpm/\', include("bpm.financial.financial_urls")), # 业务流程 #财务缴费 58 # ————————53PerfectCRM实现CRM客户报名流程缴费———————— 59 60 # ————————60PerfectCRM实现CRM学生上课记录———————— 61 url(r\'^bpm/\', include("bpm.student.student_urls")), # 业务流程 # 学生上课记录 62 # ————————60PerfectCRM实现CRM学生上课记录———————— 63 ]
1 # student_urls.py 2 # ————————60PerfectCRM实现CRM学生上课记录———————— 3 from django.conf.urls import url 4 from bpm.student import student_views 5 6 urlpatterns = [ 7 url(r\'^student_course/$\', student_views.student_course, name=\'student_course\'), #学生报名的课程 8 url(r\'^studyrecords/(\\d+)/$\', student_views.studyrecords, name=\'studyrecords\'), # #学生上课记录列表StudyRecord 9 10 ] 11 # ————————60PerfectCRM实现CRM学生上课记录————————
1 # student_views.py 2 # ————————60PerfectCRM实现CRM学生上课记录———————— 3 from django.shortcuts import render #页面返回 4 from crm import models #数据库 5 from django.contrib.auth.decorators import login_required # 登陆后页面才能访问 6 #学生报名的课程 7 @login_required # 登陆后页面才能访问 8 def student_course(request): 9 if request.user.stu_account: 10 enrollmentlist=request.user.stu_account.enrollment_set.all()#根据账号表关联的ID获取06学员报名信息表 11 return render(request, \'bpm_student/student_course.html\', locals()) 12 13 #学生上课记录列表 14 @login_required # 登陆后页面才能访问 15 def studyrecords(request,enroll_obj_id): 16 enroll_obj=models.Enrollment.objects.get(id=enroll_obj_id)#根据ID获取06学员报名信息表 17 studyrecordlist=enroll_obj.studyrecord_set.all()#根据06学员报名信息表的ID获取09学习纪录 18 return render(request,\'bpm_student/studyrecords.html\',locals()) 19 20 # ————————60PerfectCRM实现CRM学生上课记录————————
1 # bpm_tags.py 2 3 # ————————48PerfectCRM实现CRM客户报名流程学生合同———————— 4 from django import template 5 register = template.Library() #模板库 6 7 #合同格式 8 @register.simple_tag 9 def render_enrolled_contract(enroll_obj):#合同格式 10 if enroll_obj.enrolled_class.contract.template: 11 return enroll_obj.enrolled_class.contract.template.format(course_name=enroll_obj.enrolled_class,stu_name=enroll_obj.customer.name) 12 else: 13 return \'\' 14 15 # ————————48PerfectCRM实现CRM客户报名流程学生合同———————— 16 17 # ————————60PerfectCRM实现CRM学生上课记录———————— 18 19 # from django import template 20 # register = template.Library() #模板库 21 from django.db.models import Sum 22 #分数统计#我的成绩 23 @register.simple_tag 24 def get_score(enroll_obj,customer_obj): 25 study_records=enroll_obj.studyrecord_set.filter(course_record__from_class_id=enroll_obj.enrolled_class.id)#根据班级ID 取09学习纪录的信息(包含\'score\') 26 sum_score= study_records.aggregate(Sum(\'score\')) #aggregate #总 #返回一个字典,其中包含的计算(聚合) #Sum #合计值 27 return sum_score 28 29 # ————————60PerfectCRM实现CRM学生上课记录————————
1 {#student_course.html#} 2 {## ————————60PerfectCRM实现CRM学生上课记录————————#} 3 {% extends \'bpm_master/bpm_sample.html\' %} 4 {% load bpm_tags %} 5 {% block right-container-content %} {#自定义内容开始 右边页面内容#} 6 <div class="panel-default"> 7 <div class="panel-body"> 8 <h4>当前用户: {{ request.user }} | 学员名字:{{ request.user.stu_account.name }} | 9 学员QQ:{{ request.user.stu_account }}</h4> 10 <ol class="breadcrumb"> 11 <li><a href="/bpm/student_course/">我的课程</a></li> 12 </ol> 13 <table class="table table-striped table-responsive"> 14 <thead> 15 <tr> 16 <th>校区班级</th> 17 <th>班级类型</th> 18 <th>课程进度</th> 19 <th>课程成绩</th> 20 <th>开课日期</th> 21 <th>结业日期</th> 22 </tr> 23 </thead> 24 25 26 <tbody> 27 {% for enroll_obj in enrollmentlist %} 28 <tr> 29 <td>{{ enroll_obj.enrolled_class }}</td> 30 {#校区班级#} 31 <td>{{ enroll_obj.enrolled_class.get_class_type_display }}</td> 32 {#班级类型#} 33 <td> 34 <a href="{% url \'studyrecords\' enroll_obj.id %}">已上: {{ enroll_obj.enrolled_class.courserecord_set.all.count }}节</a> 35 </td> 36 {#课程进度#} 37 <td> 38 {% get_score enroll_obj request.user.stu_account as score_data %}{{ score_data.score__sum }}</td> 39 {#课程成绩#} 40 <td>{{ enroll_obj.enrolled_class.start_date }}</td> 41 {#开课日期#} 42 <td>{{ enroll_obj.enrolled_class.end_date }}</td> 43 {#结业日期#} 44 </tr> 45 {% endfor %} 46 </tbody> 47 </table> 48 </div> 49 </div> 50 {% endblock %} 51 {## ————————60PerfectCRM实现CRM学生上课记录————————#}
1 {#studyrecords.html#} 2 {## ————————60PerfectCRM实现CRM学生上课记录————————#} 3 {% extends \'bpm_master/bpm_sample.html\' %} 4 {% load bpm_tags %} 5 {% block right-container-content %} {#自定义内容开始 右边页面内容#} 6 <div class="panel-default"> 7 <div class="panel-body"> 8 <h4>当前用户: {{ request.user }} | 学员名字:{{ request.user.stu_account.name }} | 9 学员QQ:{{ request.user.stu_account }}</h4> 10 <ol class="breadcrumb"> 11 <li><a href="/bpm/student_course/">我的课程</a></li> 12 <li><a href="/bpm/studyrecords/{{ enroll_obj.id }}/">{{ enroll_obj.enrolled_class }}</a></li> 13 </ol> 14 15 <table class="table table-striped table-responsive "> 16 <thead> 17 <tr> 18 <th>课程节次</th> 19 <th>签到状态</th> 20 <th>本节作业</th> 21 <th>本节成绩</th> 22 <th>本节讲师</th> 23 <th>上课日期</th> 24 <th>本节大纲</th> 25 <th>作业标题</th> 26 <th>作业要求</th> 27 </tr> 28 </thead> 29 30 31 <tbody> 32 {% for studyrecord in studyrecordlist %} 33 <tr> 34 <td>{{ studyrecord.course_record.day_num }}</td> 35 {#课程节次#} 36 <td>{{ studyrecord.get_attendance_display }}</td> 37 {#签到状态#} 38 <td> {{ studyrecord.course_record.has_homework }}</td> 39 {#本节作业#} 40 <td>{{ studyrecord.get_score_display }}</td> 41 {#本节成绩#} 42 <td>{{ studyrecord.course_record.teacher }}</td> 43 {#本节讲师#} 44 <td>{{ studyrecord.course_record.date }}</td> 45 {#上课日期#} 46 <td> 47 <pre style="width: 240px;height: 60px">{{ studyrecord.course_record.outline }}</pre> 48 {#本节大纲#} 49 </td> 50 <td> 51 <pre style="width: 240px;height: 60px">{{ studyrecord.course_record.homework_title }}</pre> 52 {#作业标题#} 53 </td> 54 <td> 55 <pre style="width: 240px;height: 60px">{{ studyrecord.course_record.homework_content }}</pre> 56 {#作业要求#} 57 </td> 58 </tr> 59 {% endfor %} 60 </tbody> 61 </table> 62 </div> 63 </div> 64 {% endblock %} 65 {## ————————60PerfectCRM实现CRM学生上课记录————————#}
1 #models.py 2 3 # ————————01PerfectCRM基本配置ADMIN———————— 4 5 from django.db import models 6 # Create your models here. 7 8 """ 9 #运行 Terminal 10 # 生成 数据表 11 # python manage.py makemigrations 12 # 数据表 迁移 13 # python manage.py migrate 14 """ 15 16 """01校区表""" 17 class Branch(models.Model): 18 name = models.CharField(max_length=128,unique=True) #校区名#CharField作用是保存文本,定长的变量类型 19 addr = models.CharField(max_length=128) #地址 20 def __str__(self):#__str__()是Python的一个“魔幻”方法,这个方法定义了当object调用str()时应该返回的值。 21 return self.name #返回 #校区名 22 class Meta: #通过一个内嵌类 "class Meta" 给你的 model 定义元数据 23 verbose_name_plural = "01校区表" #verbose_name_plural给你的模型类起一个更可读的名字 24 Django项目:CRM(客户关系管理系统)--66--56PerfectCRM实现CRM客户报名缴费链接Django项目:CRM(客户关系管理系统)--65--55PerfectCRM实现CRM客户报名状态颜色变化
Django项目:CRM(客户关系管理系统)--45--36PerfectCRM实现CRM用户登陆注销02