-
Notifications
You must be signed in to change notification settings - Fork 1
/
models.py
192 lines (135 loc) · 5.46 KB
/
models.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
from django.db import models
class Districts(models.Model):
district_id = models.IntegerField(unique=True)
name = models.CharField(max_length=200)
code = models.CharField(max_length=200)
class Meta:
verbose_name_plural = "Districts"
def __unicode__(self):
return self.name
class Years(models.Model):
yearly = models.IntegerField()
class Meta:
verbose_name_plural = "Years"
def __unicode__(self):
return u"%s" % self.yearly
class Months(models.Model):
monthly = models.CharField(max_length=200)
class Meta:
verbose_name_plural = "Months"
def __unicode__(self):
return self.monthly
class LivelihoodZones(models.Model):
description = models.CharField(max_length=200)
class Meta:
verbose_name_plural = "Livelihood Zones"
def __unicode__(self):
return self.description
class Sectors(models.Model):
description = models.CharField(max_length=200)
class Meta:
verbose_name_plural = "Sectors"
def __unicode__(self):
return self.description
class RiskOfDrought(models.Model):
description = models.CharField(max_length=200)
risk_of_drought_id = models.IntegerField(unique=True )
class Meta:
verbose_name_plural = "Risk of Drought"
def __unicode__(self):
return self.description
class Trends(models.Model):
description = models.CharField(max_length=200)
trends_id = models.IntegerField(unique=True )
class Meta:
verbose_name_plural = "Trends"
def __unicode__(self):
return self.description
class Indicators(models.Model):
description = models.CharField(max_length=200)
sector = models.ForeignKey(Sectors)
indicator_id = models.IntegerField(unique=True)
class Meta:
verbose_name_plural = "Indicators"
def __unicode__(self):
return self.description
class Phase(models.Model):
description = models.CharField(max_length=200)
phase_id = models.IntegerField(unique=True)
class Meta:
verbose_name_plural = "Phase"
def __unicode__(self):
return self.description
class Report(models.Model):
pdf = models.FileField(upload_to="reports")
description = models.CharField(max_length=300)
district = models.ForeignKey(Districts)
month = models.ForeignKey(Months)
year = models.ForeignKey(Years)
class Admin:
list_display = ('description')
def __unicode__(self):
return self.description
class Documentation (models.Model):
file = models.FileField(upload_to="docs")
description = models.CharField(max_length=300)
class Meta:
verbose_name_plural = "Documentation"
class Admin:
list_display = ('description')
def __unicode__(self):
return self.description
class Map(models.Model):
image = models.FileField(upload_to="maps")
description = models.CharField(max_length=300)
district = models.ForeignKey(Districts)
month = models.ForeignKey(Months)
year = models.ForeignKey(Years)
class Admin:
list_display = ('description')
def __unicode__(self):
return self.description
class LivelihoodZonePhaseClassification(models.Model):
district = models.ForeignKey(Districts, to_field='district_id')
years = models.ForeignKey(Years)
months = models.ForeignKey(Months)
riskofdrought = models.ForeignKey(RiskOfDrought, to_field='risk_of_drought_id')
livelihoodzones = models.ForeignKey(LivelihoodZones)
phase = models.ForeignKey(Phase, to_field='phase_id')
trends = models.ForeignKey(Trends, to_field='trends_id')
created = models.DateTimeField(auto_now_add=True)
sequenceid = models.BigIntegerField()
dews_created = models.DateTimeField()
livestock_sector_phase = models.ForeignKey(Phase, to_field='phase_id', related_name='livestock_sector_phase')
crops_sector_phase = models.ForeignKey(Phase, to_field='phase_id', related_name='crops_sector_phase')
water_sector_phase = models.ForeignKey(Phase, to_field='phase_id', related_name='water_sector_phase')
livelihoods_sector_phase = models.ForeignKey(Phase, to_field='phase_id', related_name='livelihoods_sector_phase')
access_to_pasture = models.FloatField()
animals_in_good_body_condition = models.FloatField()
disease_incidence_in_livestock = models.FloatField()
livestock_migration = models.FloatField()
germination_of_crops = models.FloatField()
crops_affected_by_pests_and_diseases = models.FloatField()
borehole_useage = models.FloatField()
average_time_to_fetch_water = models.FloatField()
average_water_qty_fetched_daily = models.FloatField()
price_of_bull = models.FloatField()
price_of_sorghum = models.FloatField()
price_of_charcoal = models.FloatField()
price_of_firewood = models.FloatField()
freedom_of_movement_daytime = models.FloatField()
freedom_of_movement_nightime = models.FloatField()
casual_labor_rate = models.FloatField()
gam_rate = models.FloatField()
def __unicode__(self):
return unicode(self.created) or u''
class VulnerabilityIndicators(models.Model):
district = models.IntegerField()
years = models.ForeignKey(Years)
months = models.ForeignKey(Months)
livelihoodzones = models.ForeignKey(LivelihoodZones)
sectors = models.ForeignKey(Sectors)
indicators = models.ForeignKey(Indicators)
phase = models.ForeignKey(Phase)
datavalue = models.IntegerField(default=0)
sequenceid = models.BigIntegerField()