1
+ from django .db import models
2
+ from django .contrib .auth .models import User
3
+ from .commit import Commit
4
+
5
+ class Categorization (models .Model ):
6
+ sha = models .CharField (max_length = 40 , blank = False , null = False )
7
+ is_func_fix = models .BooleanField ()
8
+ func_fix_comment = models .TextField (blank = True , null = True )
9
+ problem_category = models .ForeignKey ('ProblemCategory' , models .DO_NOTHING , db_column = 'problem_category' , blank = True , null = True )
10
+ category_comment = models .TextField (blank = True , null = True )
11
+ problem_cause = models .ForeignKey ('ProblemCause' , models .DO_NOTHING , db_column = 'problem_cause' , blank = True , null = True )
12
+ cause_comment = models .TextField (blank = True , null = True )
13
+ problem_symptom = models .ForeignKey ('ProblemSymptom' , models .DO_NOTHING , db_column = 'problem_symptom' , blank = True , null = True )
14
+ symptom_comment = models .TextField (blank = True , null = True )
15
+ problem_fix = models .ForeignKey ('ProblemFix' , models .DO_NOTHING , db_column = 'problem_fix' , blank = True , null = True )
16
+ fix_comment = models .TextField (blank = True , null = True )
17
+ categorizer = models .ForeignKey ('Categorizer' , models .DO_NOTHING , db_column = 'categorizer' )
18
+ should_discuss = models .BooleanField (blank = True , null = True )
19
+ bug_fix = models .ForeignKey ('BugFix' , models .DO_NOTHING , blank = True , null = True )
20
+
21
+ class Meta :
22
+ db_table = 'categorizations'
23
+
24
+ def get_sha (self ):
25
+ project = Commit .objects .values ('project' ).filter (sha = self .sha )[0 ]
26
+ return "https://github.com/" + str (project ['project' ])+ "/commit/" + str (self .sha )
27
+
28
+ def get_absolute_url (self ):
29
+ return "bug_fixes/" + str (self .bug_fix )
30
+
31
+ def email_categorizer (self ):
32
+ user = User .objects .get (username = self .categorizer )
33
+ return "mailto:" + user .email
34
+
35
+
36
+ class Categorizer (models .Model ):
37
+ name = models .CharField (max_length = 254 )
38
+ initials = models .CharField (unique = True , max_length = 3 )
39
+ user = models .OneToOneField (User , to_field = "username" , db_column = 'user' , on_delete = models .DO_NOTHING )
40
+
41
+ class Meta :
42
+ db_table = 'categorizers'
43
+
44
+ def __str__ (self ):
45
+ return str (self .user )
0 commit comments