-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathmodels.py
executable file
·148 lines (126 loc) · 7.21 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
from __future__ import unicode_literals
from django.db import models
from django.contrib import admin
from datetime import datetime
from workflow.models import Program, SiteProfile, ProjectAgreement, Office, Province
try:
from django.utils import timezone
except ImportError:
from datetime import datetime as timezone
class TrainingAttendance(models.Model):
training_name = models.CharField(max_length=255)
program = models.ForeignKey(Program, null=True, blank=True)
project_agreement = models.ForeignKey(ProjectAgreement, null=True, blank=True, verbose_name="Project Initiation")
implementer = models.CharField(max_length=255, null=True, blank=True)
reporting_period = models.CharField(max_length=255, null=True, blank=True)
total_participants = models.IntegerField(null=True, blank=True)
location = models.CharField(max_length=255, null=True, blank=True)
community = models.CharField(max_length=255, null=True, blank=True)
training_duration = models.CharField(max_length=255, null=True, blank=True)
start_date = models.CharField(max_length=255, null=True, blank=True)
end_date = models.CharField(max_length=255, null=True, blank=True)
trainer_name = models.CharField(max_length=255, null=True, blank=True)
trainer_contact_num = models.CharField(max_length=255, null=True, blank=True)
form_filled_by = models.CharField(max_length=255, null=True, blank=True)
form_filled_by_contact_num = models.CharField(max_length=255, null=True, blank=True)
total_male = models.IntegerField(null=True, blank=True)
total_female = models.IntegerField(null=True, blank=True)
total_age_0_14_male = models.IntegerField(null=True, blank=True)
total_age_0_14_female = models.IntegerField(null=True, blank=True)
total_age_15_24_male = models.IntegerField(null=True, blank=True)
total_age_15_24_female = models.IntegerField(null=True, blank=True)
total_age_25_59_male = models.IntegerField(null=True, blank=True)
total_age_25_59_female = models.IntegerField(null=True, blank=True)
create_date = models.DateTimeField(null=True, blank=True)
edit_date = models.DateTimeField(null=True, blank=True)
class Meta:
ordering = ('training_name',)
# on save add create date or update edit date
def save(self, *args, **kwargs):
if self.create_date == None:
self.create_date = datetime.now()
self.edit_date = datetime.now()
super(TrainingAttendance, self).save()
# displayed in admin templates
def __unicode__(self):
return unicode(self.training_name)
class TrainingAttendanceAdmin(admin.ModelAdmin):
list_display = ('training_name', 'program', 'project_agreement', 'create_date', 'edit_date')
display = 'Training Attendance'
list_filter = ('program__country','program')
class Distribution(models.Model):
distribution_name = models.CharField(max_length=255)
program = models.ForeignKey(Program, null=True, blank=True)
initiation = models.ForeignKey(ProjectAgreement, null=True, blank=True, verbose_name="Project Initiation")
office_code = models.ForeignKey(Office, null=True, blank=True)
distribution_indicator = models.CharField(max_length=255)
distribution_implementer = models.CharField(max_length=255, null=True, blank=True)
reporting_period = models.CharField(max_length=255, null=True, blank=True)
province = models.ForeignKey(Province, null=True, blank=True)
total_beneficiaries_received_input = models.IntegerField(null=True, blank=True)
distribution_location = models.CharField(max_length=255, null=True, blank=True)
input_type_distributed = models.CharField(max_length=255, null=True, blank=True)
distributor_name_and_affiliation = models.CharField(max_length=255, null=True, blank=True)
distributor_contact_number = models.CharField(max_length=255, null=True, blank=True)
start_date = models.DateTimeField(null=True, blank=True)
end_date = models.DateTimeField(null=True, blank=True)
form_filled_by = models.CharField(max_length=255, null=True, blank=True)
form_filled_by_position = models.CharField(max_length=255, null=True, blank=True)
form_filled_by_contact_num = models.CharField(max_length=255, null=True, blank=True)
form_filled_date = models.CharField(max_length=255, null=True, blank=True)
form_verified_by = models.CharField(max_length=255, null=True, blank=True)
form_verified_by_position = models.CharField(max_length=255, null=True, blank=True)
form_verified_by_contact_num = models.CharField(max_length=255, null=True, blank=True)
form_verified_date = models.CharField(max_length=255, null=True, blank=True)
total_received_input = models.CharField(max_length=255, null=True, blank=True)
total_male = models.IntegerField(null=True, blank=True)
total_female = models.IntegerField(null=True, blank=True)
total_age_0_14_male = models.IntegerField(null=True, blank=True)
total_age_0_14_female = models.IntegerField(null=True, blank=True)
total_age_15_24_male = models.IntegerField(null=True, blank=True)
total_age_15_24_female = models.IntegerField(null=True, blank=True)
total_age_25_59_male = models.IntegerField(null=True, blank=True)
total_age_25_59_female = models.IntegerField(null=True, blank=True)
create_date = models.DateTimeField(null=True, blank=True)
edit_date = models.DateTimeField(null=True, blank=True)
class Meta:
ordering = ('distribution_name',)
def save(self, *args, **kwargs):
if self.create_date == None:
self.create_date = datetime.now()
self.edit_date = datetime.now()
super(Distribution, self).save()
# displayed in admin templates
def __unicode__(self):
return unicode(self.distribution_name)
class DistributionAdmin(admin.ModelAdmin):
list_display = ('distribution_name', 'program', 'initiation', 'create_date', 'edit_date')
display = 'Program Dashboard'
class Beneficiary(models.Model):
beneficiary_name = models.CharField(max_length=255, null=True, blank=True)
training = models.ManyToManyField(TrainingAttendance, blank=True)
distribution = models.ManyToManyField(Distribution, blank=True)
father_name = models.CharField(max_length=255, null=True, blank=True)
age = models.IntegerField(null=True, blank=True)
gender = models.CharField(max_length=255, null=True, blank=True)
site = models.ForeignKey(SiteProfile, null=True, blank=True)
signature = models.BooleanField(default=True)
remarks = models.CharField(max_length=255, null=True, blank=True)
program = models.ManyToManyField(Program, blank=True)
create_date = models.DateTimeField(null=True, blank=True)
edit_date = models.DateTimeField(null=True, blank=True)
class Meta:
ordering = ('beneficiary_name',)
# on save add create date or update edit date
def save(self, *args, **kwargs):
if self.create_date == None:
self.create_date = datetime.now()
self.edit_date = datetime.now()
super(Beneficiary, self).save()
# displayed in admin templates
def __unicode__(self):
return unicode(self.beneficiary_name)
class BeneficiaryAdmin(admin.ModelAdmin):
list_display = ('site','beneficiary_name',)
display = 'Beneficiary'
list_filter = ('site','beneficiary_name')