码迷,mamicode.com
首页 > 其他好文 > 详细

day30

时间:2017-03-31 12:53:10      阅读:239      评论:0      收藏:0      [点我收藏+]

标签:auth   unique   menus   menu   客户   content   roles   ted   elf   

crm

from django.db import models
from django.contrib.auth.models import User

# Create your models here.


#客户信息表
class Customer(models.Model):
    test = models.CharField(max_length=32)
    name = models.CharField(max_length=32,blank=True,null=True)
    qq = models.CharField(max_length=64,unique=True)    #unique 字段唯一
    weixin = models.CharField(max_length=64,blank=True,null=True)
    age = models.PositiveSmallIntegerField(blank=True,null=True)
    gender = models.PositiveSmallIntegerField(choices=((0,‘Female‘),(1,‘Male‘)),blank=True,null=True)
    phone = models.PositiveIntegerField(blank=True,null=True)
    source_choices = (
        (0,‘商桥‘),
        (1,‘51CTO‘),
        (2,‘QQ群‘),
        (3,‘知乎‘),
        (4,‘SOGO‘),
        (5,‘转介绍‘),
        (6,‘其他‘),
    )

    source = models.SmallIntegerField(choices=source_choices)
    referral_from = models.ForeignKey("Customer",related_name="my_referrals",blank=True,null=True)
    consult_courses = models.ManyToManyField("Course")
    status_choices = ((0,‘已报名 ‘),(1,‘未报名‘),(2,‘已退学‘))
    status = models.SmallIntegerField(choices=status_choices)
    consultant = models.ForeignKey("UserProfile", verbose_name="课程顾问")
    date = models.DateTimeField(auto_now_add=True)

    def __str__(self):
        return self.name


#学员报名信息(后面的学习记录,学员上课记录)
class Enrollment(models.Model):
    customer = models.ForeignKey(‘Customer‘)
    class_grade = models.ForeignKey(‘ClassList‘)
    enrollment_date = models.DateField()

    def __str__(self):
        return self.customer
    class Meta:
        unique_together = ("customer","class_grade")



#学员跟进记录
class FollowUpRecord(models.Model):
    customer = models.ForeignKey(‘Customer‘)
    content = models.TextField(max_length=1024)
    status =(
        (0,‘不报名‘),
        (1,‘一个月内报名‘),
        (2,‘两周内报名‘),
    )
    # consultant = models.Foreignkey("UserProfile",verbose_name="课程顾问")
    consultant = models.ForeignKey("UserProfile",verbose_name="课程顾问")
    date = models.DateTimeField(auto_now_add=True)

#课程表
class Course(models.Model):
    name = models.CharField(unique=True,max_length=64)
    price = models.PositiveIntegerField(default=198000)
    outline = models.TextField()

    def __str__(self):
        return self.name


#班级列表
class ClassList(models.Model):
    course = models.ForeignKey("Course")
    semester = models.PositiveSmallIntegerField()
    start_date = models.DateField()
    end_date = models.DateField()
    teachers = models.ManyToManyField("UserProfile")
    class_type_choices = ((0,‘脱产‘),(1,‘周末‘),(2,‘网络‘))
    branch= models.ForeignKey("Branch")

#每节课上课记录
class CourseRecord(models.Model):
    class_grade = models.ForeignKey("ClassList")
    day_number = models.PositiveSmallIntegerField(verbose_name="节次")
    teacher  = models.ForeignKey("UserProfile")
    CourseCoutent = models.TextField(verbose_name="课程内容",max_length=1024)
    # 有没有作业
    has_homework = models.BooleanField(default=True)
    # 作业标题
    homework_title = models.CharField(max_length=128,blank=True,null=True)
    #作业需求
    homework_requirement = models.CharField(verbose_name="作业需求",max_length=1025,blank=True,null=True)
    def __str__(self):
        return "%s dayum:%s"%(self.class_grade,self.day_number)

    class Meta:
        unique_together = ("class_grade","day_number")


#每个学生上的每节课的成绩记录
class StudyRecord(models.Model):
    course_record = models.ForeignKey("CourseRecord")
    student = models.ForeignKey("Enrollment")
    score_choices = ((100,"A+"),
                     (90,"A"),
                     (85,"B+"),
                     (80,"B"),
                     (75,"B-"),
                     (70,"C+"),
                     (65,"C"),
                     (40,"C-"),
                     (-20,"D"),
                     (-50,"COPY"),
                     (0,"N/A"),
                     )
    score = models.SmallIntegerField(choices=score_choices)
    show_status_choices = ((0,"缺勤"),(1,"已签到"),(2,"迟到"))
    grade_comment = models.TextField(max_length=1024,blank=True,null=True)
    def __str__(self):
        return "%s daynum:%s" %(self.student,self.day_number)
    class Meta:
        unique_together = ("course_record","student")


#员工
class UserProfile(models.Model):
    user = models.OneToOneField(User)
    name = models.CharField(max_length=32)
    roles = models.ManyToManyField("Role",blank=True,null=True)
    def __str__(self):
        return self.name

#角色表
class Role(models.Model):
    name = models.CharField(unique=True,max_length=32)
    menus = models.ManyToManyField("Menu")
    def __str__(self):
        return self.name


#分校
class Branch(models.Model):
    name = models.CharField(unique=True,max_length=128)
    def __str__(self):
        return self.name


#菜单表
class Menu(models.Model):
    name = models.CharField(unique=True,max_length=32)
    url_type = models.SmallIntegerField(choices=((0,‘relative_name‘),(1,‘absolute_url‘)))
    url_name = models.CharField(unique=True,max_length=128)
    def __str__(self):
        return self.name

 

day30

标签:auth   unique   menus   menu   客户   content   roles   ted   elf   

原文地址:http://www.cnblogs.com/topaz1618/p/6650754.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!