Skip to content

Commit

Permalink
Merge pull request #1134 from yilmazbekdemir/issue-453
Browse files Browse the repository at this point in the history
refactor siteprofile model
  • Loading branch information
jefmoura authored Aug 17, 2018
2 parents 9b12a36 + 2564e53 commit 7d0f2cb
Show file tree
Hide file tree
Showing 2 changed files with 285 additions and 28 deletions.
277 changes: 277 additions & 0 deletions workflow/migrations/0028_auto_20180816_0141.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,277 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.3 on 2018-08-16 08:41
from __future__ import unicode_literals

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('workflow', '0027_auto_20180814_0045'),
]

operations = [
migrations.RemoveField(
model_name='historicalsiteprofile',
name='admin_level_three',
),
migrations.RemoveField(
model_name='historicalsiteprofile',
name='animal_type',
),
migrations.RemoveField(
model_name='historicalsiteprofile',
name='avg_household_size',
),
migrations.RemoveField(
model_name='historicalsiteprofile',
name='avg_landholding_size',
),
migrations.RemoveField(
model_name='historicalsiteprofile',
name='classify_land',
),
migrations.RemoveField(
model_name='historicalsiteprofile',
name='contact_leader',
),
migrations.RemoveField(
model_name='historicalsiteprofile',
name='contact_number',
),
migrations.RemoveField(
model_name='historicalsiteprofile',
name='date_of_firstcontact',
),
migrations.RemoveField(
model_name='historicalsiteprofile',
name='households_owning_livestock',
),
migrations.RemoveField(
model_name='historicalsiteprofile',
name='info_source',
),
migrations.RemoveField(
model_name='historicalsiteprofile',
name='literacy_rate',
),
migrations.RemoveField(
model_name='historicalsiteprofile',
name='literate_females',
),
migrations.RemoveField(
model_name='historicalsiteprofile',
name='literate_males',
),
migrations.RemoveField(
model_name='historicalsiteprofile',
name='num_members',
),
migrations.RemoveField(
model_name='historicalsiteprofile',
name='office',
),
migrations.RemoveField(
model_name='historicalsiteprofile',
name='populations_owning_land',
),
migrations.RemoveField(
model_name='historicalsiteprofile',
name='status',
),
migrations.RemoveField(
model_name='historicalsiteprofile',
name='total_agricultural_land',
),
migrations.RemoveField(
model_name='historicalsiteprofile',
name='total_female',
),
migrations.RemoveField(
model_name='historicalsiteprofile',
name='total_horticultural_land',
),
migrations.RemoveField(
model_name='historicalsiteprofile',
name='total_land',
),
migrations.RemoveField(
model_name='historicalsiteprofile',
name='total_literate_peoples',
),
migrations.RemoveField(
model_name='historicalsiteprofile',
name='total_male',
),
migrations.RemoveField(
model_name='historicalsiteprofile',
name='total_num_households',
),
migrations.RemoveField(
model_name='historicalsiteprofile',
name='total_population',
),
migrations.RemoveField(
model_name='historicalsiteprofile',
name='total_rainfed_land',
),
migrations.RemoveField(
model_name='siteprofile',
name='admin_level_three',
),
migrations.RemoveField(
model_name='siteprofile',
name='animal_type',
),
migrations.RemoveField(
model_name='siteprofile',
name='approval',
),
migrations.RemoveField(
model_name='siteprofile',
name='avg_household_size',
),
migrations.RemoveField(
model_name='siteprofile',
name='avg_landholding_size',
),
migrations.RemoveField(
model_name='siteprofile',
name='classify_land',
),
migrations.RemoveField(
model_name='siteprofile',
name='contact_leader',
),
migrations.RemoveField(
model_name='siteprofile',
name='contact_number',
),
migrations.RemoveField(
model_name='siteprofile',
name='date_of_firstcontact',
),
migrations.RemoveField(
model_name='siteprofile',
name='households_owning_livestock',
),
migrations.RemoveField(
model_name='siteprofile',
name='info_source',
),
migrations.RemoveField(
model_name='siteprofile',
name='literacy_rate',
),
migrations.RemoveField(
model_name='siteprofile',
name='literate_females',
),
migrations.RemoveField(
model_name='siteprofile',
name='literate_males',
),
migrations.RemoveField(
model_name='siteprofile',
name='num_members',
),
migrations.RemoveField(
model_name='siteprofile',
name='office',
),
migrations.RemoveField(
model_name='siteprofile',
name='populations_owning_land',
),
migrations.RemoveField(
model_name='siteprofile',
name='status',
),
migrations.RemoveField(
model_name='siteprofile',
name='total_agricultural_land',
),
migrations.RemoveField(
model_name='siteprofile',
name='total_female',
),
migrations.RemoveField(
model_name='siteprofile',
name='total_horticultural_land',
),
migrations.RemoveField(
model_name='siteprofile',
name='total_land',
),
migrations.RemoveField(
model_name='siteprofile',
name='total_literate_peoples',
),
migrations.RemoveField(
model_name='siteprofile',
name='total_male',
),
migrations.RemoveField(
model_name='siteprofile',
name='total_num_households',
),
migrations.RemoveField(
model_name='siteprofile',
name='total_population',
),
migrations.RemoveField(
model_name='siteprofile',
name='total_rainfed_land',
),
migrations.AddField(
model_name='historicalsiteprofile',
name='address_line1',
field=models.CharField(blank=True, max_length=255, null=True),
),
migrations.AddField(
model_name='historicalsiteprofile',
name='address_line2',
field=models.CharField(blank=True, max_length=255, null=True),
),
migrations.AddField(
model_name='historicalsiteprofile',
name='address_line3',
field=models.CharField(blank=True, max_length=255, null=True),
),
migrations.AddField(
model_name='historicalsiteprofile',
name='address_line4',
field=models.CharField(blank=True, max_length=255, null=True),
),
migrations.AddField(
model_name='historicalsiteprofile',
name='postcode',
field=models.CharField(blank=True, max_length=20, null=True),
),
migrations.AddField(
model_name='siteprofile',
name='address_line1',
field=models.CharField(blank=True, max_length=255, null=True),
),
migrations.AddField(
model_name='siteprofile',
name='address_line2',
field=models.CharField(blank=True, max_length=255, null=True),
),
migrations.AddField(
model_name='siteprofile',
name='address_line3',
field=models.CharField(blank=True, max_length=255, null=True),
),
migrations.AddField(
model_name='siteprofile',
name='address_line4',
field=models.CharField(blank=True, max_length=255, null=True),
),
migrations.AddField(
model_name='siteprofile',
name='postcode',
field=models.CharField(blank=True, max_length=20, null=True),
),
]
36 changes: 8 additions & 28 deletions workflow/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -906,46 +906,26 @@ def __unicode__(self):

class SiteProfileManager(models.Manager):
def get_queryset(self):
return super(SiteProfileManager, self).get_queryset().prefetch_related().select_related('country','province','district','admin_level_three','type')
return super(SiteProfileManager, self).get_queryset().prefetch_related().select_related('country','province','district',
'type')


class SiteProfile(models.Model):

site_uuid = models.CharField(max_length=255, verbose_name='Site UUID', default=uuid.uuid4, unique=True)
name = models.CharField("Site Name", max_length=255, blank=False)
type = models.ForeignKey(ProfileType, blank=True, null=True)
office = models.ForeignKey(Office, blank=True, null=True)
contact_leader = models.CharField("Contact Name", max_length=255, blank=True, null=True)
date_of_firstcontact = models.DateTimeField("Date of First Contact", null=True, blank=True)
contact_number = models.CharField("Contact Number", max_length=255, blank=True, null=True)
num_members = models.CharField("Number of Members", max_length=255, blank=True, null=True)
info_source = models.CharField("Data Source",max_length=255, blank=True, null=True)
total_num_households = models.IntegerField("Total # Households", help_text="", null=True, blank=True)
avg_household_size = models.DecimalField("Average Household Size", decimal_places=14,max_digits=25, default=Decimal("0.00"), null=True, blank=True)
total_population = models.IntegerField(null=True, blank=True)
total_male = models.IntegerField(null=True, blank=True)
total_female = models.IntegerField(null=True, blank=True)
classify_land = models.ForeignKey(LandType, blank=True, null=True)
total_land = models.IntegerField("Total Land", help_text="In hectares/jeribs", null=True, blank=True)
total_agricultural_land = models.IntegerField("Total Agricultural Land", help_text="In hectares/jeribs", null=True, blank=True)
total_rainfed_land = models.IntegerField("Total Rain-fed Land", help_text="In hectares/jeribs", null=True, blank=True)
total_horticultural_land = models.IntegerField("Total Horticultural Land", help_text="In hectares/jeribs", null=True, blank=True)
total_literate_peoples = models.IntegerField("Total Literate People", help_text="", null=True, blank=True)
literate_males = models.IntegerField("% of Literate Males", help_text="%", null=True, blank=True)
literate_females = models.IntegerField("% of Literate Females", help_text="%", null=True, blank=True)
literacy_rate = models.IntegerField("Literacy Rate (%)", help_text="%", null=True, blank=True)
populations_owning_land = models.IntegerField("Households Owning Land", help_text="(%)", null=True, blank=True)
avg_landholding_size = models.DecimalField("Average Landholding Size", decimal_places=14,max_digits=25, help_text="In hectares/jeribs", default=Decimal("0.00"))
households_owning_livestock = models.IntegerField("Households Owning Livestock", help_text="(%)", null=True, blank=True)
animal_type = models.CharField("Animal Types", help_text="List Animal Types", max_length=255, null=True, blank=True)
address_line1 = models.CharField(max_length=255, null=True, blank=True)
address_line2 = models.CharField(max_length=255, null=True, blank=True)
address_line3 = models.CharField(max_length=255, null=True, blank=True)
address_line4 = models.CharField(max_length=255, null=True, blank=True)
postcode = models.CharField(max_length=20, null=True, blank=True)
country = models.ForeignKey(Country)
province = models.ForeignKey(AdminLevelOne, verbose_name="Administrative Level 1", null=True, blank=True)
district = models.ForeignKey(AdminLevelTwo, verbose_name="Administrative Level 2", null=True, blank=True)
admin_level_three = models.ForeignKey(AdminLevelThree, verbose_name="Administrative Level 3", null=True, blank=True, related_name="site_level3")
village = models.ForeignKey(AdminLevelThree, verbose_name="Administrative Level 4", null=True, blank=True)
latitude = models.DecimalField("Latitude (Decimal Coordinates)", decimal_places=16,max_digits=25, default=Decimal("0.00"))
longitude = models.DecimalField("Longitude (Decimal Coordinates)", decimal_places=16,max_digits=25, default=Decimal("0.00"))
status = models.BooleanField("Site Active", default=True)
approval = models.ManyToManyField(ApprovalWorkflow, blank=True)
create_date = models.DateTimeField(null=True, blank=True)
edit_date = models.DateTimeField(null=True, blank=True)
organization = models.ForeignKey(Organization, null=True, blank=True)
Expand Down

0 comments on commit 7d0f2cb

Please sign in to comment.