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鑿滃崟"