CRM鍏崇郴琛ㄧ殑鏋勫缓

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了CRM鍏崇郴琛ㄧ殑鏋勫缓相关的知识,希望对你有一定的参考价值。

鏍囩锛?a href='http://www.mamicode.com/so/1/als' title='als'>als   涔嬩竴   any   rom   end   璁板綍   unique   day   瀹樼綉   

from django.db import models    #瀵煎叆models杩欎釜绫?/span>
from django.contrib.auth.models import User   #瀵煎叆鍦╠jango鍚庡彴涓嚜宸卞垱寤虹殑鐢ㄦ埛
# Create your models here.

#-----------瀹㈡埛淇℃伅琛?--------#
class Customer(models.Model):    #鎵€鏈夌殑model妯″瀷閮借缁ф壙models.Model杩欎釜绫?/span>
    鈥樷€樷€?/span>瀹㈡埛淇℃伅琛?/span>鈥樷€樷€?/span>
    source_choices = (
        (0,鈥?/span>杞粙缁?/span>鈥?/span>),
        (1,鈥?/span>QQ缇?/span>鈥?/span>),
        (2,鈥?/span>瀹樼綉鈥?/span>),
        (3,鈥?/span>鐧惧害鎺ㄥ箍鈥?/span>),
        (4,鈥?/span>51CTO鈥?/span>),
        (5,鈥?/span>鐭ヤ箮鈥?/span>),
        (6,鈥?/span>甯傚満鎺ㄥ箍鈥?/span>)
    )#绗竴涓€兼槸鍦ㄦ暟鎹簱涓瓨鐨勫€硷紝绗簩涓€兼槸鍦ㄥ悗鍙扮晫闈笂鏄剧ず鐨勫€?/span>
    name = models.CharField(max_length=32,blank=True,null=True)
    #32涓瓧鑺傦紝鏈€澶氳兘瀛?2涓瓧绗?blank=True琛ㄦ槑鍦╝dmin琛ㄥ崟涓彲浠ヤ负绌?null琛ㄦ槑鏁版嵁搴撳彲浠ヤ负绌猴紝涓や釜閮介粯璁や负False
    qq = models.CharField(max_length=32,unique=True)
    #unique琛ㄦ槑杩欎釜瀛楁鏁版嵁鍦ㄦ暟鎹簱涓繀椤诲敮涓€
    qq_name = models.CharField(max_length=64,blank=True,null=True)
    #瀹㈡埛鐨剄q鍚嶇О
    phone = models.CharField(max_length=64,blank=True,null=True)
    #瀹㈡埛鐨勭數璇?/span>
    source = models.SmallIntegerField(choices=source_choices)
    #瀹㈡埛鐨勬潵婧愶紝灏忔暣鏁般€係mallIntegerField鍖呭惈-32768鍒?2767銆?/span>
    referral_from = models.CharField(verbose_name="杞粙缁嶄汉qq",max_length=64,blank=True)
    #杞粙缁嶄汉淇℃伅锛寁erbose_name="杞粙缁嶄汉qq"灏嗕俊鎭彲璇诲寲
    consult_course = models.ForeignKey("Course",verbose_name="鍜ㄨ璇剧▼")
    #鍜ㄨ鐨勮绋嬶紝澶氬涓€锛團oreignKey锛夊閿瀹氫箟鍦ㄢ€樺鈥欑殑涓€鏂癸紝娉ㄦ剰鍦╠jango2涓竴瀹氳璁剧疆on_delete杩欎釜灞炴€у€?/span>
    content = models.TextField(verbose_name="鍜ㄨ璇︽儏")
    #鍜ㄨ鐨勫唴瀹?verbose_name="鍜ㄨ璇︽儏"灏嗕俊鎭彲璇诲寲
    tags = models.ManyToManyField("Tag")
    #缁欒繖涓汉鎵撴爣绛?澶氬澶氬叧绯诲湪鏁版嵁搴撲腑涔熸槸闈炲父甯歌鐨勫叧绯荤被鍨嬨€?/span>
    # 姣斿涓€鏈功鍙互鏈夊ソ鍑犱釜浣滆€咃紝涓€涓綔鑰呬篃鍙互鍐欏ソ鍑犳湰涔︺€?/span>
    # 澶氬澶氱殑瀛楁鍙互瀹氫箟鍦ㄤ换浣曠殑涓€鏂癸紝璇峰敖閲忓畾涔夊湪绗﹀悎浜轰滑鎬濈淮涔犳儻鐨勪竴鏂癸紝浣嗕笉瑕佸悓鏃堕兘瀹氫箟
    #null鍙傛暟瀵筂anyToManyField澶氬澶氬瓧娈垫棤鏁堬紒璁剧疆null=True姣棤鎰忎箟
    consultant = models.ForeignKey("UserProfile",verbose_name="鍜ㄨ鐨勪汉鍛?/span>")
    #鍜ㄨ浜嗛偅涓€涓攢鍞汉鍛?澶栭敭鍏宠仈鐢ㄦ埛锛屾敞鎰忓湪django2涓璅oreignKey涓€瀹氳璁剧疆on_delete杩欎釜灞炴€у€?/span>
    note = models.TextField(blank=True,null=True)
    #缁欒繖涓汉鍋氫竴浜涚瑪璁?
    date = models.DateTimeField(auto_now_add=True)
    #瀹㈡埛淇℃伅鏃堕棿琛?/span>
    # auto_now:姣忓綋瀵硅薄琚繚瀛樻椂灏嗗瓧娈佃涓哄綋鍓嶆棩鏈燂紝甯哥敤浜庝繚瀛樻渶鍚庝慨鏀规椂闂淬€?/span>
    # auto_now_add锛氭瘡褰撳璞¤鍒涘缓鏃讹紝璁句负褰撳墠鏃ユ湡锛屽父鐢ㄤ簬淇濆瓨鍒涘缓鏃ユ湡(娉ㄦ剰锛屽畠鏄笉鍙慨鏀圭殑)銆?/span>
    status_choices = (
        (0,"鏈姤鍚?/span>"),
        (1,"宸叉姤鍚?/span>"),
    )
    status = models.SmallIntegerField(choices=status_choices,default=0)
    #灏忔暣鏁帮紝鍖呭惈 - 32768鍒?2767銆?/span>
    def __str__(self):
        return self.name
    # 榄旀硶鏂规硶,缁欏璞¤繑鍥炲悕绉?/span>

    class Meta:
        # verbose_name = "瀹㈡埛淇℃伅琛?
        verbose_name_plural = "07瀹㈡埛淇℃伅琛?/span>"
        # verbose_name锛氱敤浜庤缃ā鍨嬪璞$殑鐩磋銆佷汉绫诲彲璇诲悕濡傛灉涓嶆寚瀹氾紝浼氫娇鐢ㄥ皬鍐欐ā鍨嬪悕浣滀负榛樿鍊?/span>
        # verbose_name_plural濡傛灉涓嶆寚瀹氳閫夐」锛岄偅涔堥粯璁ょ殑澶嶆暟鍚嶅瓧鏄痸erbose_name鍔犱笂鈥榮鈥?/span>

#-----------瀹㈡埛鏍囩琛?--------#
class Tag(models.Model):
    name = models.CharField(unique=True,max_length=32)
    #瀛楃鍨嬶紝蹇呴』瑕佸~max_length,unique=True琛ㄦ槑鏍囩鍚嶅瓧蹇呴』鍞竴
    def __str__(self):
        return self.name
    # 榄旀硶鏂规硶,缁欏璞¤繑鍥炲悕绉?/span>

    class Meta:
        verbose_name_plural = "09鏍囩"

#-----------瀹㈡埛鏍囪窡杩涜〃---------#
class CustomerFollowUp(models.Model):
    鈥樷€樷€?/span>瀹㈡埛璺熻繘琛?/span>鈥樷€樷€?/span>
    intention_choices = (
        (0,鈥?/span>2鍛ㄥ唴鎶ュ悕鈥?/span>),
        (1,鈥?/span>1涓湀鍐呮姤鍚?/span>鈥?/span>),
        (2,鈥?/span>杩戞湡鏃犳姤鍚嶈鍒?/span>鈥?/span>),
        (3,鈥?/span>宸插湪鍏跺畠鏈烘瀯鎶ュ悕鈥?/span>),
        (4,鈥?/span>宸叉姤鍚?/span>鈥?/span>),
        (5,鈥?/span>宸叉媺榛?/span>鈥?/span>),
    )
    customer = models.ForeignKey("Customer")#璺熻繘鍝竴涓鎴?澶栭敭鍏宠仈
    content = models.TextField(verbose_name="璺熻繘鍐呭")#璺熻繘浜嗛偅浜涘唴瀹?/span>
    consultant = models.ForeignKey("UserProfile")#閭d釜浜鸿窡杩涚殑锛屽叧鑱斿埌鐢ㄦ埛
    date = models.DateTimeField(auto_now_add=True)#璺熻繘鐨勬椂闂达紝鍒涘缓鍚庝笉淇敼銆侱ateTimeField绮剧‘鍒板勾鏈?/span>
    intention = models.SmallIntegerField(choices=intention_choices)#鎶ュ悕鐘舵€?/span>

    def __str__(self):
        return "<%s : %s>" % (self.customer.qq,self.intention)

    class Meta:
        verbose_name_plural = "05璇炬埛璺熻繘璁板綍"

#-----------璇剧▼琛?--------#
class Course(models.Model):
    鈥樷€樷€?/span>璇剧▼琛?/span>鈥樷€樷€?/span>
    name = models.CharField(max_length=64,unique=True)#鍚嶅瓧蹇呴』鍞竴
    price = models.PositiveSmallIntegerField()
    #PositiveSmallIntegerField杈冨皬鐨勬鏁存暟瀛楁锛屼粠0鍒?2767銆?/span>
    period = models.PositiveSmallIntegerField(verbose_name="鍛ㄦ湡(鏈?")
    #PositiveSmallIntegerField    杈冨皬鐨勬鏁存暟瀛楁锛屼粠0鍒?2767銆?/span>
    outline = models.TextField()
    #璇剧▼澶х翰

    def __str__(self):
        return self.name

    class Meta:
        verbose_name_plural = "04璇剧▼琛?/span>"
    #妯″瀷鐨勫厓鏁版嵁锛屾寚鐨勬槸鈥滈櫎浜嗗瓧娈靛鐨勬墍鏈夊唴瀹光€濓紝渚嬪鎺掑簭鏂瑰紡銆佹暟鎹簱琛ㄥ悕銆佷汉绫诲彲璇荤殑鍗曟暟鎴栬€呭鏁板悕绛夌瓑銆?/span>
    #鎯冲湪妯″瀷涓鍔犲厓鏁版嵁锛屾柟娉曞緢绠€鍗曪紝鍦ㄦā鍨嬬被涓坊鍔犱竴涓瓙绫伙紝鍚嶅瓧鏄浐瀹氱殑Meta

#-----------鏍″尯琛?--------#
class Branch(models.Model):
    鈥樷€樷€?/span>鏍″尯鈥樷€樷€?/span>
    name = models.CharField(max_length=128,unique=True)
    addr = models.CharField(max_length=128)
    def __str__(self):
        return self.name

    class Meta:
        verbose_name_plural = "01鏍″尯"

#-----------鐝骇琛?--------#
class ClassList(models.Model):
    鈥樷€樷€?/span>鐝骇琛?/span>鈥樷€樷€?/span>
    class_type_choices = (
        (0,鈥?/span>闈㈡巿(鑴变骇)鈥?/span>),
        (1,鈥?/span>闈㈡巿(鍛ㄦ湯)鈥?/span>),
        (2,鈥?/span>缃戠粶鐝?/span>鈥?/span>)
    )
    branch = models.ForeignKey("Branch",verbose_name="鏍″尯")
    course = models.ForeignKey("Course")#璇剧▼琛ㄥ叧鑱斿埌璇剧▼
    semester = models.PositiveSmallIntegerField(verbose_name="瀛︽湡")#绗嚑涓鏈?/span>
    teacher = models.ManyToManyField("UserProfile",blank=True)#璁插笀鍏宠仈璧锋潵
    class_type = models.SmallIntegerField(choices=class_type_choices,verbose_name="涓婅绫诲瀷")
    strat_date = models.DateField(verbose_name="寮€鐝棩鏈?/span>")#涓嶅寘鍚椂鍒嗙
    end_date = models.DateField(verbose_name="缁撲笟鏃ユ湡",blank=True,null=True)

    def __str__(self):
        return "%s %s %s" % (self.branch,self.course,self.semester)
        #杩斿洖鍒扮晫闈笂鏄剧ず鐨勫€?/span>

    class Meta:
        unique_together = (鈥?/span>branch鈥?/span>,鈥?/span>course鈥?/span>,鈥?/span>semester鈥?/span>)  #鑱斿悎鍞竴
        #unique_together锛屽悓涓€涓牎鍖虹殑璇剧▼鍜屽鏈熸槸涓嶈兘鐩稿悓鐨勩€?/span>
        #姣忎竴涓厓绱犻兘鏄竴涓厓缁勶紝琛ㄧず涓€缁勮仈鍚堝敮涓€绾︽潫锛屽彲浠ュ悓鏃惰缃缁勭害鏉熴€?/span>
        # 涓轰簡鏂逛究锛屽浜庡彧鏈変竴缁勭害鏉熺殑鎯呭喌涓嬶紝鍙互绠€鍗曞湴浣跨敤涓€缁村厓绱狅紝渚嬪锛歶nique_together = (鈥榥ame鈥? 鈥榖irth_day鈥? 鈥榓ddress鈥?
        #涓や釜浜虹殑鍚嶅瓧銆佺敓鏃ュ拰鍑虹敓鍦颁笉鑳戒负鍚屼竴澶┿€?/span>
        verbose_name_plural = "02鐝骇琛?/span>"

#-----------涓婅璁板綍琛?--------#
class CourseRecord(models.Model):
    鈥樷€樷€?/span>涓婅璁板綍鈥樷€樷€?/span>
    from_class = models.ForeignKey("ClassList",verbose_name="鐝骇")#鏉ヨ嚜浜庡摢涓彮绾э紝鍏蜂綋鍝釜鐝骇
    day_num = models.PositiveSmallIntegerField(verbose_name="绗嚑鑺?澶?")
    #杈冨皬鐨勬鏁存暟瀛楁锛屼粠0鍒?2767銆?/span>
    teacher = models.ForeignKey("UserProfile")
    #鍏宠仈鐢ㄦ埛锛岀敤鎴蜂腑鏈夊緢澶氫汉锛屽鐢熴€佽€佸笀銆侀攢鍞瓑
    has_homework = models.BooleanField(default=True)
    #甯冨皵鍊肩被鍨嬨€傞粯璁ゅ€兼槸None銆傚湪html琛ㄥ崟涓綋鐜颁负CheckboxInput鏍囩
    homework_title = models.CharField(max_length=128,blank=True,null=True)
    homework_content = models.TextField(blank=True,null=True)
    #澶ч噺鏂囨湰鍐呭锛屽湪HTML涓〃鐜颁负Textarea鏍囩锛屾渶甯哥敤鐨勫瓧娈电被鍨嬩箣涓€锛?/span>
    # 濡傛灉浣犱负瀹冭缃竴涓猰ax_length鍙傛暟锛岄偅涔堝湪鍓嶇椤甸潰涓細鍙楀埌杈撳叆瀛楃鏁伴噺闄愬埗锛岀劧鑰屽湪妯″瀷鍜屾暟鎹簱灞傞潰鍗翠笉鍙楀奖鍝嶃€?/span>
    outline = models.TextField(verbose_name="璇剧▼澶х翰")
    date = models.DateField(auto_now_add=True)
    #涓婅鐨勬棩鏈?涓嶆樉绀烘椂鍒嗙

    def __str__(self):
        return "%s %s" % (self.from_class,self.day_num)

    class Meta:
        unique_together = ("from_class","day_num")#鑱斿悎鍞竴,鍙兘鏈夊悓涓€涓绋嬪拰澶╂暟瑕佸敮涓€
        verbose_name_plural = "03涓婅璁板綍"

#--------璁板綍瀛︾敓瀛︿範璁板綍琛?-----#
class StudyRecord(models.Model):
    鈥樷€樷€?/span>瀛︿範璁板綍琛?/span>鈥樷€樷€?/span>
    attendance_choices = (
        (0,鈥?/span>宸茬鍒?/span>鈥?/span>),
        (1,鈥?/span>杩熷埌鈥?/span>),
        (2,鈥?/span>缂哄嫟鈥?/span>),
        (3,鈥?/span>鏃╅€€鈥?/span>),
    )
    score_choices = (
        (100,"A+"),
        (90,"A"),
        (85,"B+"),
        (80,"B"),
        (75,"B-"),
        (70,"C+"),
        (60,"C"),
        (40,"C-"),
        (-50,"D"),
        (-100,"Copy"),
        (0,"N/A"),
    )
    student = models.ForeignKey("Enrollment")#鍏宠仈鍒版姤鍚嶇殑浜?/span>
    course_record = models.ForeignKey("CourseRecord")#鍏宠仈鍒颁笂璇剧殑浜?/span>
    attendance = models.SmallIntegerField(choices=attendance_choices, default=0)#灏忔暣鏁帮紝鍖呭惈-32768鍒?2767銆?/span>
    scorce = models.SmallIntegerField(choices=score_choices,default=0)#    灏忔暣鏁帮紝鍖呭惈-32768鍒?2767銆?/span>
    memo = models.TextField(blank=True,null=True)#澶囨敞锛屼笂璇炬儏鍐靛浣曠瓑
    date = models.DateField(auto_now_add=True)#涓嶅寘鍚椂鍒嗙

    def __str__(self):
        return "%s %s %s" % (self.student,self.course_record,self.scorce)

    class Meta:
        verbose_name_plural = "06瀛︿範璁板綍"

#-----------鎶ュ悕琛?--------#
class Enrollment(models.Model):
    鈥樷€樷€?/span>鎶ュ悕琛?/span>鈥樷€樷€?/span>
    customer = models.ForeignKey("Customer")#璺熻釜鐨勫鎴凤紝鏈夊鎴峰苟涓嶄唬琛ㄨ繖涓鎴锋姤鍚嶄簡
    enrolled_class = models.ForeignKey("ClassList",verbose_name="鎵€鎶ョ彮绾?/span>")#鍏宠仈鐝骇琛?/span>
    consultant = models.ForeignKey("UserProfile",verbose_name="璇剧▼椤鹃棶")
    contract_agreed = models.BooleanField(default=False,verbose_name="瀛﹀憳宸插悓鎰忔潯娆?/span>")
    #甯冨皵鍊肩被鍨嬨€傞粯璁ゅ€兼槸None銆傚湪HTML琛ㄥ崟涓綋鐜颁负CheckboxInput鏍囩銆傚鏋滆鎺ユ敹null鍊硷紝璇蜂娇鐢∟ullBooleanField銆?/span>
    contract_approved = models.BooleanField(default=False,verbose_name="鍚堝悓宸插凡瀹℃牳")#鐪嬪悎鍚屾槸鍚﹀凡缁忓鏍?/span>
    date = models.DateField(auto_now_add=True)

    def __str__(self):
        return "%s %s"%(self.customer,self.enrolled_class)
    class Meta:
        unique_together = ("customer","enrolled_class")#瀹㈡埛涓庢姤鍚嶇殑鐝骇蹇呴』鍞竴
        verbose_name_plural = "08鎶ュ悕琛?/span>"

#-----------缂磋垂璁板綍琛?--------#
class Payment(models.Model):
    鈥樷€樷€?/span>缂磋垂璁板綍鈥樷€樷€?/span>
    customer = models.ForeignKey("Customer")
    course = models.ForeignKey("Course",verbose_name="鎵€鎶ヨ绋?/span>")#鎵€鎶ヨ绋嬭鍏宠仈璧锋潵
    amount = models.PositiveIntegerField(verbose_name="鏁伴",default=500)#姝f暣鏁板瓧娈碉紝鍖呭惈0,鏈€澶?147483647銆?/span>
    consulant = models.ForeignKey("UserProfile")#蹇呴』鍏宠仈鍒扮敤鎴?鍜ㄨ鐨勪汉蹇呴』鍏宠仈鐢ㄦ埛琛?/span>
    date = models.DateTimeField(auto_now_add=True)#鏄剧ず鏃跺垎绉?/span>

    def __str__(self):
        return "%s %s"%(self.customer,self.amount)#瀹㈡埛鐨勫悕瀛楀拰鏁伴,

    class Meta:
        verbose_name_plural = "10缂磋垂璁板綍"

#------------璐﹀彿琛?-------#
class UserProfile(models.Model):
    鈥樷€樷€?/span>璐﹀彿琛?/span>鈥樷€樷€?/span>
    user = models.OneToOneField(User)#鐢ㄦ埛鏈夊摢浜涗汉
    #灏嗙敤鎴峰閿叧鑱斿埌User
    #杩欑鍏崇郴绫诲瀷澶氭暟鐢ㄤ簬褰撲竴涓ā鍨嬮渶瑕佷粠鍒殑妯″瀷鎵╁睍鑰屾潵鐨勬儏鍐点€?/span>
    # 姣斿锛孌jango鑷甫auth妯″潡鐨刄ser鐢ㄦ埛琛紝濡傛灉浣犳兂鍦ㄨ嚜宸辩殑椤圭洰閲屽垱寤虹敤鎴锋ā鍨嬶紝鍙堟兂鏂逛究鐨勪娇
    #鐢―jango鐨勮璇佸姛鑳斤紝閭d箞涓€涓瘮杈冨ソ鐨勬柟妗堝氨鏄湪浣犵殑鐢ㄦ埛妯″瀷閲岋紝
    # 浣跨敤涓€瀵逛竴鍏崇郴锛屾坊鍔犱竴涓笌auth妯″潡User妯″瀷鐨勫叧鑱斿瓧娈点€?/span>
    name = models.CharField(max_length=32)#瀹冪殑鍚嶅瓧鍙仛浠€涔?/span>
    roles = models.ManyToManyField("Role",blank=True)#瀹冪殑瑙掕壊鏄粈涔?浠€涔堟牱鐨勮鑹茶兘澶熺湅浠€涔堣彍鍗?/span>

    def __str__(self):
        return self.name

    class Meta:
        verbose_name_plural = "12璐﹀彿琛?/span>"

#------------瑙掕壊琛?-------#
class Role(models.Model):
    鈥樷€樷€?/span>瑙掕壊琛?/span>鈥樷€樷€?/span>
    #涓嶅悓瑙掕壊鐪嬪埌鐨勮彍鍗曟槸涓嶅悓鐨?/span>
    name = models.CharField(max_length=32,unique=True)
    menus = models.ManyToManyField("Menu",blank=True)
    def __str__(self):
        return self.name

    class Meta:
        verbose_name_plural = "11瑙掕壊"

#------------鑿滃崟琛?-------#
class Menu(models.Model):
    鈥樷€樷€?/span>涓撻棬瀛樿彍鍗?/span>鈥樷€樷€?/span>
    name = models.CharField(max_length=32)#鍚嶅瓧鏈€澶氫负32涓瓧绗?/span>
    url_name = models.CharField(max_length=64)
    #涓嶅悓鏉冮檺鐨勪汉鐪嬪埌鐨勮彍鍗曟槸涓嶅悓鐨?閫氳繃url鍘绘帶鍒?/span>

    def __str__(self):
        return self.name

    class Meta:
        verbose_name_plural = "13鑿滃崟"

 

以上是关于CRM鍏崇郴琛ㄧ殑鏋勫缓的主要内容,如果未能解决你的问题,请参考以下文章

Linux鍔ㄦ€佸簱鑷姩鏋勫缓Makefile

cocoscreator鏋勫缓鐨刟ndroid宸ョ▼鎶ラ敊

瀹夊崜_鏋勫缓棣栦釜搴旂敤

鍩轰簬Haproxy鏋勫缓璐熻浇鍧囪 闆嗙兢

uwsgi銆亀sgi鍜宯ginx鐨勫尯鍒拰鍏崇郴

浣跨敤buildpack-deps 鏋勫缓鑷繁鐨勫叆瀹瑰櫒闀滃儚