@@ -70,36 +70,43 @@ class BusinessArea(NaturalKeyModel, TimeStampedUUIDModel):
70
70
code_to_cash_assist_mapping = {"575RE00000" : "SLVK" }
71
71
cash_assist_to_code_mapping = {v : k for k , v in code_to_cash_assist_mapping .items ()}
72
72
code = models .CharField (max_length = 10 , unique = True )
73
- name = models .CharField (max_length = 255 )
74
- long_name = models .CharField (max_length = 255 )
75
- region_code = models .CharField (max_length = 8 )
76
- region_name = models .CharField (max_length = 8 )
77
- kobo_username = models .CharField (max_length = 255 , null = True , blank = True )
78
- kobo_token = models .CharField (max_length = 255 , null = True , blank = True )
79
- kobo_url = models .URLField (max_length = 255 , null = True , blank = True )
80
- rapid_pro_host = models .URLField (null = True , blank = True )
81
- rapid_pro_payment_verification_token = models .CharField (max_length = 40 , null = True , blank = True )
82
- rapid_pro_messages_token = models .CharField (max_length = 40 , null = True , blank = True )
83
- rapid_pro_survey_token = models .CharField (max_length = 40 , null = True , blank = True )
84
73
slug = models .CharField (
85
74
max_length = 250 ,
86
75
unique = True ,
87
76
db_index = True ,
88
77
)
89
- custom_fields = JSONField (default = dict , blank = True )
90
-
91
- has_data_sharing_agreement = models .BooleanField (default = False )
78
+ name = models .CharField (max_length = 255 )
79
+ long_name = models .CharField (max_length = 255 )
92
80
parent = models .ForeignKey (
93
81
"self" ,
94
82
related_name = "children" ,
95
83
on_delete = models .SET_NULL ,
96
84
null = True ,
97
85
blank = True ,
98
86
)
87
+ partners = models .ManyToManyField (
88
+ to = "account.Partner" , through = BusinessAreaPartnerThrough , related_name = "business_areas"
89
+ )
90
+ countries = models .ManyToManyField ("geo.Country" , related_name = "business_areas" )
91
+
99
92
is_split = models .BooleanField (default = False )
93
+ region_code = models .CharField (max_length = 8 )
94
+ region_name = models .CharField (max_length = 8 )
95
+ has_data_sharing_agreement = models .BooleanField (default = False )
96
+ is_accountability_applicable = models .BooleanField (default = False )
97
+ active = models .BooleanField (default = False )
98
+ enable_email_notification = models .BooleanField (default = True , verbose_name = "Automatic Email notifications enabled" )
99
+
100
+ kobo_username = models .CharField (max_length = 255 , null = True , blank = True )
101
+ kobo_token = models .CharField (max_length = 255 , null = True , blank = True )
102
+ kobo_url = models .URLField (max_length = 255 , null = True , blank = True )
103
+
104
+ rapid_pro_host = models .URLField (null = True , blank = True )
105
+ rapid_pro_payment_verification_token = models .CharField (max_length = 40 , null = True , blank = True )
106
+ rapid_pro_messages_token = models .CharField (max_length = 40 , null = True , blank = True )
107
+ rapid_pro_survey_token = models .CharField (max_length = 40 , null = True , blank = True )
100
108
101
109
postpone_deduplication = models .BooleanField (default = False )
102
- countries = models .ManyToManyField ("geo.Country" , related_name = "business_areas" )
103
110
deduplication_duplicate_score = models .FloatField (
104
111
default = 6.0 ,
105
112
validators = [MinValueValidator (0.0 )],
@@ -134,13 +141,8 @@ class BusinessArea(NaturalKeyModel, TimeStampedUUIDModel):
134
141
help_text = "Threshold for Face Image Deduplication" ,
135
142
validators = [MinValueValidator (0.0 ), MaxValueValidator (100.0 )],
136
143
)
137
- is_accountability_applicable = models .BooleanField (default = False )
138
- active = models .BooleanField (default = False )
139
- enable_email_notification = models .BooleanField (default = True , verbose_name = "Automatic Email notifications enabled" )
140
144
141
- partners = models .ManyToManyField (
142
- to = "account.Partner" , through = BusinessAreaPartnerThrough , related_name = "business_areas"
143
- )
145
+ custom_fields = JSONField (default = dict , blank = True )
144
146
145
147
def save (self , * args : Any , ** kwargs : Any ) -> None :
146
148
unique_slugify (self , self .name , slug_field_name = "slug" )
@@ -226,9 +228,12 @@ class FlexibleAttribute(SoftDeletableModel, NaturalKeyModel, TimeStampedUUIDMode
226
228
(ASSOCIATED_WITH_INDIVIDUAL , _ ("Individual" )),
227
229
)
228
230
229
- type = models .CharField (max_length = 16 , choices = TYPE_CHOICE )
230
231
name = models .CharField (max_length = 255 )
231
- required = models .BooleanField (default = False )
232
+ group = models .ForeignKey (
233
+ "core.FlexibleAttributeGroup" , on_delete = models .CASCADE , related_name = "flex_attributes" , null = True , blank = True
234
+ )
235
+ type = models .CharField (max_length = 16 , choices = TYPE_CHOICE )
236
+ associated_with = models .SmallIntegerField (choices = ASSOCIATED_WITH_CHOICES )
232
237
program = models .ForeignKey (
233
238
"program.Program" ,
234
239
on_delete = models .CASCADE ,
@@ -243,12 +248,9 @@ class FlexibleAttribute(SoftDeletableModel, NaturalKeyModel, TimeStampedUUIDMode
243
248
null = True ,
244
249
related_name = "flex_field" ,
245
250
)
251
+ required = models .BooleanField (default = False )
246
252
label = JSONField (default = dict , validators = [label_contains_english_en_validator ])
247
253
hint = JSONField (default = dict )
248
- group = models .ForeignKey (
249
- "core.FlexibleAttributeGroup" , on_delete = models .CASCADE , related_name = "flex_attributes" , null = True , blank = True
250
- )
251
- associated_with = models .SmallIntegerField (choices = ASSOCIATED_WITH_CHOICES )
252
254
253
255
class Meta :
254
256
constraints = [
@@ -347,8 +349,8 @@ class PeriodicFieldData(models.Model):
347
349
)
348
350
349
351
subtype = models .CharField (max_length = 16 , choices = TYPE_CHOICES )
350
- number_of_rounds = models .IntegerField ()
351
352
rounds_names = ArrayField (models .CharField (max_length = 255 ), default = list )
353
+ number_of_rounds = models .IntegerField ()
352
354
353
355
class Meta :
354
356
verbose_name = "Periodic Field Data"
@@ -540,12 +542,10 @@ class Type(models.TextChoices):
540
542
STANDARD = "STANDARD" , "Standard"
541
543
SOCIAL = "SOCIAL" , "Social Workers"
542
544
543
- label = models .CharField (max_length = 32 , blank = True )
544
545
code = models .CharField (max_length = 32 )
546
+ label = models .CharField (max_length = 32 , blank = True )
545
547
type = models .CharField (choices = Type .choices , null = True , blank = True , max_length = 32 )
546
548
description = models .TextField (blank = True )
547
- compatible_types = models .ManyToManyField ("self" , blank = True , symmetrical = False )
548
- limit_to = models .ManyToManyField (to = "BusinessArea" , related_name = "data_collecting_types" , blank = True )
549
549
active = models .BooleanField (default = True )
550
550
deprecated = models .BooleanField (
551
551
default = False , help_text = "Cannot be used in new programs, totally hidden in UI, only admin have access"
@@ -554,6 +554,8 @@ class Type(models.TextChoices):
554
554
household_filters_available = models .BooleanField (default = True )
555
555
recalculate_composition = models .BooleanField (default = False )
556
556
weight = models .PositiveSmallIntegerField (default = 0 )
557
+ compatible_types = models .ManyToManyField ("self" , blank = True , symmetrical = False )
558
+ limit_to = models .ManyToManyField (to = "BusinessArea" , related_name = "data_collecting_types" , blank = True )
557
559
558
560
def __str__ (self ) -> str :
559
561
return self .label
0 commit comments