Skip to content

Commit

Permalink
Merge pull request #1151 from akvo/1103_sectors
Browse files Browse the repository at this point in the history
[#1103] Sector de-double and sector mobile view
  • Loading branch information
loicsans committed Feb 20, 2015
2 parents 440bc3a + 0d4a719 commit ea1cd1f
Show file tree
Hide file tree
Showing 3 changed files with 603 additions and 20 deletions.
19 changes: 0 additions & 19 deletions akvo/rsr/migrations/0084_sector_cleanup.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,6 @@ def forwards(self, orm):
sector.vocabulary = 'DAC-3'
sector.save()

for project in orm.Project.objects.all():
# Make sure projects don't have duplicate sector categories (unless it has a percentage specified)
sector_categories = orm.Sector.objects.filter(project=project, vocabulary='2')
if sector_categories.count() > 1:
for sector_category in sector_categories:
similar_sector_categories = orm.Sector.objects.filter(project=project, sector_code=sector_category.sector_code, vocabulary='2').exclude(pk=sector_category.pk)
for similar_sector_category in similar_sector_categories:
if not similar_sector_category.percentage:
similar_sector_category.delete()

# Same for 5-digit sectors
sectors = orm.Sector.objects.filter(project=project, vocabulary='1')
if sectors.count() > 1:
for sector in sectors:
similar_sectors = orm.Sector.objects.filter(project=project, sector_code=sector.sector_code, vocabulary='1').exclude(pk=sector.pk)
for similar_sector in similar_sectors:
if not similar_sector.percentage:
similar_sector.delete()

def backwards(self, orm):
pass

Expand Down
Loading

0 comments on commit ea1cd1f

Please sign in to comment.