Skip to content
Snippets Groups Projects
Commit b09fafd8 authored by martinburchell's avatar martinburchell
Browse files

Merge pull request #14 from aptivate/rumor_columns

Rumor columns
parents 2c245169 7ef8f92f
No related branches found
No related tags found
No related merge requests found
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations
RAPIDPRO_CONFIG = {
"label": "rapidpro",
"name": "RapidPro",
"format": "excel",
"type": "rumor",
"columns": [
{
"name": "Phone",
"type": "ignore",
"field": "ignore"
},
{
"name": "Name",
"type": "ignore",
"field": "ignore"
},
{
"name": "Groups",
"type": "ignore",
"field": "ignore"
},
{
"name": "Last Seen",
"type": "date",
"field": "timestamp",
"date_format": "%m/%d/%y %H:%M:%S"
},
{
"name": "Rumors (Text) - DEY Say sample flow",
"type": "text",
"field": "body"
},
{
"name": "Channel",
"type": "text",
"field": "network_provider"
}
],
"skip_header": 1
}
def update_rapidpro_config(apps, schema_editor):
Profile = apps.get_model('chn_spreadsheet', 'SheetProfile')
Profile.objects.filter(label='rapidpro').update(profile=RAPIDPRO_CONFIG)
class Migration(migrations.Migration):
dependencies = [
('chn_spreadsheet', '0006_update_rapidpro_config'),
]
operations = [
migrations.RunPython(update_rapidpro_config)
]
......@@ -27,6 +27,7 @@ def test_items_imported(importer):
assert items[0]['body'] == "That there is a special budget to give money to the family of each dead in Liberia since the Ebola outbreak."
assert items[0]['timestamp'] == pytz.utc.localize(
datetime.datetime(2015, 4, 19, 21, 35, 20))
assert items[0]['network_provider'] == '8737 (Cellcom)'
item_types = transport.taxonomies.term_itemcount(
slug='item-types')
......
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
class Migration(migrations.Migration):
dependencies = [
('data_layer', '0005_message_last_modified'),
]
operations = [
migrations.AddField(
model_name='message',
name='network_provider',
field=models.CharField(max_length=200, blank=True),
),
]
......@@ -21,6 +21,7 @@ class Message(DataLayerModel):
body = models.TextField()
timestamp = models.DateTimeField(null=True)
terms = models.ManyToManyField(Term, related_name="items")
network_provider = models.CharField(max_length=200, blank=True)
def apply_term(self, term):
# TODO: test this
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment