Skip to content

Commit

Permalink
Merge pull request #1307 from unicef/staging
Browse files Browse the repository at this point in the history
Staging
  • Loading branch information
ntrncic authored Mar 29, 2018
2 parents 21840ac + 070fbe1 commit 6737f04
Show file tree
Hide file tree
Showing 286 changed files with 2,442 additions and 13,413 deletions.
38 changes: 38 additions & 0 deletions EquiTrack/EquiTrack/management/commands/clear-migrations-table.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import logging

from django.core.management import BaseCommand
from django.db import connection, transaction

from users.models import Country

logger = logging.getLogger(__name__)


class Command(BaseCommand):
help = 'Clear Migration Table'

def add_arguments(self, parser):
parser.add_argument('--schema', dest='schema')

@transaction.atomic
def handle(self, *args, **options):

logger.info(u'Command started')

countries = Country.objects.exclude(name__iexact='global')
if options['schema']:
countries = countries.filter(schema_name=options['schema'])

etools_apps = ','.join(["'audit'", "'activities'", "'attachments'", "'environment'", "'firms'", "'funds'",
"'locations'", "'hact'", "'management'", "'notification'", "'partners'", "'publics'",
"'purchase_order'", "'reports'", "'snapshot'", "'t2f'", "'tpm'", "'tpmpartners'",
"'users'", "'vision'",
"'trips'", "'supplies'", "'workplan'" # TODO remove these apps
])
for country in countries:
connection.set_tenant(country)
logger.info(u'Clear table for %s' % country.name)
with connection.cursor() as cursor:
cursor.execute("DELETE FROM django_migrations WHERE app IN ({})".format(etools_apps))

logger.info(u'Command finished')
3 changes: 0 additions & 3 deletions EquiTrack/EquiTrack/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,11 +198,8 @@ def str2bool(value):
'reports',
'partners',
'hact',
'trips',
'supplies',
'activities',
't2f',
'workplan',
'attachments',
'tpm',
'audit',
Expand Down
10 changes: 1 addition & 9 deletions EquiTrack/activities/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.10 on 2017-12-14 07:45
# Generated by Django 1.10.8 on 2018-03-26 16:05
from __future__ import unicode_literals

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

initial = True

dependencies = [
('partners', '0054_auto_20171013_2147'),
('reports', '0014_auto_20171013_2147'),
('locations', '0004_auto_20170112_2051'),
]

operations = [
Expand All @@ -22,10 +18,6 @@ class Migration(migrations.Migration):
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('date', models.DateField(blank=True, null=True, verbose_name='Date')),
('cp_output', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='reports.Result', verbose_name='CP Output')),
('intervention', models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to='partners.Intervention', verbose_name='Intervention')),
('locations', models.ManyToManyField(related_name='_activity_locations_+', to='locations.Location', verbose_name='Locations')),
('partner', models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to='partners.PartnerOrganization', verbose_name='Implementing Partner')),
],
),
]
41 changes: 41 additions & 0 deletions EquiTrack/activities/migrations/0002_auto_20180326_1605.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.10.8 on 2018-03-26 16:05
from __future__ import unicode_literals

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

initial = True

dependencies = [
('activities', '0001_initial'),
('locations', '0001_initial'),
('reports', '0001_initial'),
('partners', '0001_initial'),
]

operations = [
migrations.AddField(
model_name='activity',
name='cp_output',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='reports.Result', verbose_name='CP Output'),
),
migrations.AddField(
model_name='activity',
name='intervention',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to='partners.Intervention', verbose_name='Intervention'),
),
migrations.AddField(
model_name='activity',
name='locations',
field=models.ManyToManyField(related_name='_activity_locations_+', to='locations.Location', verbose_name='Locations'),
),
migrations.AddField(
model_name='activity',
name='partner',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to='partners.PartnerOrganization', verbose_name='Implementing Partner'),
),
]
44 changes: 34 additions & 10 deletions EquiTrack/attachments/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.10 on 2017-06-20 13:31
# Generated by Django 1.10.8 on 2018-03-26 16:05
from __future__ import unicode_literals

import attachments.models
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
import django.utils.timezone
Expand All @@ -14,6 +16,7 @@ class Migration(migrations.Migration):

dependencies = [
('contenttypes', '0002_remove_content_type_name'),
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]

operations = [
Expand All @@ -23,23 +26,39 @@ class Migration(migrations.Migration):
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('created', model_utils.fields.AutoCreatedField(default=django.utils.timezone.now, editable=False, verbose_name='created')),
('modified', model_utils.fields.AutoLastModifiedField(default=django.utils.timezone.now, editable=False, verbose_name='modified')),
('file', models.FileField(blank=True, null=True, upload_to='files')),
('hyperlink', models.CharField(blank=True, max_length=255, null=True)),
('object_id', models.IntegerField()),
('code', models.CharField(blank=True, max_length=20)),
('content_type', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='contenttypes.ContentType')),
('file', models.FileField(blank=True, max_length=1024, null=True, upload_to=attachments.models.generate_file_path, verbose_name='File Attachment')),
('hyperlink', models.CharField(blank=True, max_length=255, null=True, verbose_name='Hyperlink')),
('object_id', models.IntegerField(verbose_name='Object ID')),
('code', models.CharField(blank=True, max_length=64, verbose_name='Code')),
('content_type', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='contenttypes.ContentType', verbose_name='Content Type')),
],
options={
'abstract': False,
'ordering': ['id'],
},
),
migrations.CreateModel(
name='AttachmentFlat',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('partner', models.CharField(blank=True, max_length=255, verbose_name='Partner')),
('partner_type', models.CharField(blank=True, max_length=150, verbose_name='Partner Type')),
('vendor_number', models.CharField(blank=True, max_length=50, verbose_name='Vendor Number')),
('pd_ssfa_number', models.CharField(blank=True, max_length=64, verbose_name='PD SSFA Number')),
('file_type', models.CharField(blank=True, max_length=100, verbose_name='File Type')),
('file_link', models.CharField(blank=True, max_length=1024, verbose_name='File Link')),
('uploaded_by', models.CharField(blank=True, max_length=255, verbose_name='Uploaded by')),
('created', models.CharField(max_length=50, verbose_name='Created')),
('attachment', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='attachments.Attachment')),
],
),
migrations.CreateModel(
name='FileType',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('order', models.PositiveIntegerField(db_index=True, editable=False)),
('name', models.CharField(max_length=64)),
('code', models.CharField(default='', max_length=64)),
('name', models.CharField(max_length=64, verbose_name='Name')),
('label', models.CharField(max_length=64, verbose_name='Label')),
('code', models.CharField(default='', max_length=64, verbose_name='Code')),
],
options={
'ordering': ('code', 'order'),
Expand All @@ -52,6 +71,11 @@ class Migration(migrations.Migration):
migrations.AddField(
model_name='attachment',
name='file_type',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='attachments.FileType'),
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='attachments.FileType', verbose_name='Document Type'),
),
migrations.AddField(
model_name='attachment',
name='uploaded_by',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='attachments', to=settings.AUTH_USER_MODEL, verbose_name='Uploaded By'),
),
]
25 changes: 0 additions & 25 deletions EquiTrack/attachments/migrations/0002_auto_20170824_1319.py

This file was deleted.

38 changes: 0 additions & 38 deletions EquiTrack/attachments/migrations/0003_filetype_label.py

This file was deleted.

52 changes: 0 additions & 52 deletions EquiTrack/attachments/migrations/0004_auto_20171122_1533.py

This file was deleted.

34 changes: 0 additions & 34 deletions EquiTrack/attachments/migrations/0005_auto_20180206_1700.py

This file was deleted.

31 changes: 0 additions & 31 deletions EquiTrack/attachments/migrations/0006_attachmentflat.py

This file was deleted.

Loading

0 comments on commit 6737f04

Please sign in to comment.