Skip to content

Commit

Permalink
Migrations to delete broken Sapelli projects
Browse files Browse the repository at this point in the history
  • Loading branch information
Julius O committed Dec 11, 2015
1 parent 6adde94 commit f4c2c65
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions geokey_sapelli/migrations/0007_deleted_projects.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.db import migrations


def check_projects(apps, schema_editor):
Project = apps.get_model('projects', 'Project')
SapelliProject = apps.get_model('geokey_sapelli', 'SapelliProject')

for sapelli_project in SapelliProject.objects.all():
try:
project = Project.objects.get(pk=sapelli_project.project.id)

if project.status == 'deleted':
sapelli_project.delete()
except Project.DoesNotExist:
sapelli_project.delete()


class Migration(migrations.Migration):

dependencies = [
('geokey_sapelli', '0006_sapelliproject_sapelli_fingerprint'),
]

operations = [
migrations.RunPython(check_projects),
]

0 comments on commit f4c2c65

Please sign in to comment.