-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
1,214 additions
and
642 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
# -*- coding: utf-8 -*- | ||
from __future__ import unicode_literals | ||
|
||
from django.db import models, migrations | ||
import sorl.thumbnail.fields | ||
import akvo.rsr.fields | ||
from django.conf import settings | ||
import akvo.rsr.models.indicator | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('rsr', '0049_auto_20160128_1605'), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='IndicatorPeriodData', | ||
fields=[ | ||
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), | ||
('created_at', models.DateTimeField(db_index=True, auto_now_add=True, null=True)), | ||
('last_modified_at', models.DateTimeField(db_index=True, auto_now=True, null=True)), | ||
('relative_data', models.BooleanField(default=False, verbose_name='relative data')), | ||
('data', akvo.rsr.fields.ValidXMLCharField(max_length=300, verbose_name='data')), | ||
('status', akvo.rsr.fields.ValidXMLCharField(default=b'D', choices=[(b'D', 'draft'), (b'P', 'pending approval'), (b'R', 'return for revision'), (b'A', 'approved')], max_length=1, blank=True, verbose_name='status', db_index=True)), | ||
('text', akvo.rsr.fields.ValidXMLTextField(verbose_name='text', blank=True)), | ||
('photo', sorl.thumbnail.fields.ImageField(upload_to=akvo.rsr.models.indicator.image_path, verbose_name='photo', blank=True)), | ||
('file', models.FileField(upload_to=akvo.rsr.models.indicator.file_path, verbose_name='file', blank=True)), | ||
('update_method', akvo.rsr.fields.ValidXMLCharField(default=b'W', choices=[(b'W', 'web'), (b'M', 'mobile')], max_length=1, blank=True, verbose_name='update method', db_index=True)), | ||
('period', models.ForeignKey(related_name='data', verbose_name='indicator period', to='rsr.IndicatorPeriod')), | ||
('user', models.ForeignKey(verbose_name='user', to=settings.AUTH_USER_MODEL)), | ||
], | ||
options={ | ||
'verbose_name': 'indicator period data', | ||
'verbose_name_plural': 'indicator period data', | ||
}, | ||
bases=(models.Model,), | ||
), | ||
migrations.CreateModel( | ||
name='IndicatorPeriodDataComment', | ||
fields=[ | ||
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), | ||
('created_at', models.DateTimeField(db_index=True, auto_now_add=True, null=True)), | ||
('last_modified_at', models.DateTimeField(db_index=True, auto_now=True, null=True)), | ||
('comment', akvo.rsr.fields.ValidXMLTextField(verbose_name='comment', blank=True)), | ||
('data', models.ForeignKey(related_name='comments', verbose_name='indicator period data', to='rsr.IndicatorPeriodData')), | ||
('user', models.ForeignKey(verbose_name='user', to=settings.AUTH_USER_MODEL)), | ||
], | ||
options={ | ||
'verbose_name': 'indicator period data comment', | ||
'verbose_name_plural': 'indicator period data comments', | ||
}, | ||
bases=(models.Model,), | ||
), | ||
migrations.AddField( | ||
model_name='indicatorperiod', | ||
name='locked', | ||
field=models.BooleanField(default=True, db_index=True, verbose_name='locked'), | ||
preserve_default=True, | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# -*- coding: utf-8 -*- | ||
from __future__ import unicode_literals | ||
|
||
from django.db import models, migrations | ||
|
||
|
||
def move_indicator_period_data(apps, schema_editor): | ||
""" | ||
Move the indicator period data from the ProjectUpdate model to the IndicatorPeriodData model | ||
and delete the old indicator 'updates'. | ||
""" | ||
ProjectUpdate = apps.get_model('rsr', 'ProjectUpdate') | ||
IndicatorPeriodData = apps.get_model('rsr', 'IndicatorPeriodData') | ||
|
||
indicator_updates = ProjectUpdate.objects.exclude(indicator_period=None) | ||
for update in indicator_updates: | ||
# Create new indicater period data object | ||
IndicatorPeriodData.objects.create( | ||
period=update.indicator_period, | ||
user=update.user, | ||
relative_data=True, | ||
data=str(update.period_update), | ||
text=update.text, | ||
photo=update.photo, | ||
update_method=update.update_method, | ||
created_at=update.created_at, | ||
last_modified_at=update.last_modified_at, | ||
) | ||
# Delete all (old) indicator 'updates' | ||
indicator_updates.delete() | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('rsr', '0050_auto_20160201_1513'), | ||
] | ||
|
||
operations = [ | ||
migrations.RunPython( | ||
move_indicator_period_data | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# -*- coding: utf-8 -*- | ||
from __future__ import unicode_literals | ||
|
||
from django.db import models, migrations | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('rsr', '0051_auto_20160201_1534'), | ||
] | ||
|
||
operations = [ | ||
migrations.RemoveField( | ||
model_name='projectupdate', | ||
name='indicator_period', | ||
), | ||
migrations.RemoveField( | ||
model_name='projectupdate', | ||
name='period_update', | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.