diff --git a/ZOOM/api/indicator/serializers.py b/ZOOM/api/indicator/serializers.py
index 184f7519..bdf8053b 100644
--- a/ZOOM/api/indicator/serializers.py
+++ b/ZOOM/api/indicator/serializers.py
@@ -83,5 +83,6 @@ class Meta:
'date_value',
'source_id',
"measure_value",
+ "unit_of_measure",
'other',
)
diff --git a/ZOOM/api/indicator/views.py b/ZOOM/api/indicator/views.py
index d65c78d4..17cb0e2b 100644
--- a/ZOOM/api/indicator/views.py
+++ b/ZOOM/api/indicator/views.py
@@ -34,6 +34,7 @@ class IndicatorDataList(ListAPIView):
'date_value',
'source_id',
'measure_value',
+ 'unit_of_measure'
'other',
)
@@ -125,6 +126,9 @@ class IndicatorDataAggregations(AggregationView):
),
GroupBy(
query_param="country_id__region__name",
- fields="country_id__region__name",
- ),
+ fields="country_id__region__name"),
+ GroupBy(
+ query_param="unit_of_measure",
+ fields="unit_of_measure",
+ ),
)
diff --git a/ZOOM/api/manual_map/__init__.py b/ZOOM/api/manual_map/__init__.py
new file mode 100644
index 00000000..e69de29b
diff --git a/ZOOM/api/manual_map/admin.py b/ZOOM/api/manual_map/admin.py
new file mode 100644
index 00000000..8c38f3f3
--- /dev/null
+++ b/ZOOM/api/manual_map/admin.py
@@ -0,0 +1,3 @@
+from django.contrib import admin
+
+# Register your models here.
diff --git a/ZOOM/api/manual_map/apps.py b/ZOOM/api/manual_map/apps.py
new file mode 100644
index 00000000..b5f1b12c
--- /dev/null
+++ b/ZOOM/api/manual_map/apps.py
@@ -0,0 +1,7 @@
+from __future__ import unicode_literals
+
+from django.apps import AppConfig
+
+
+class ManualMappingConfig(AppConfig):
+ name = 'manual_mapping'
diff --git a/ZOOM/api/manual_map/models.py b/ZOOM/api/manual_map/models.py
new file mode 100644
index 00000000..bd4b2abe
--- /dev/null
+++ b/ZOOM/api/manual_map/models.py
@@ -0,0 +1,5 @@
+from __future__ import unicode_literals
+
+from django.db import models
+
+# Create your models here.
diff --git a/ZOOM/api/manual_map/templates/manual_mapping/manual_mapping.html b/ZOOM/api/manual_map/templates/manual_mapping/manual_mapping.html
new file mode 100644
index 00000000..0f8ed527
--- /dev/null
+++ b/ZOOM/api/manual_map/templates/manual_mapping/manual_mapping.html
@@ -0,0 +1,618 @@
+
+
+
+ {% load staticfiles %}
+
+
+ Manual Mapping example
+
+
+
+
+
+
+
+
+
+ZOOM
+{{error_messages}}
+
+
+
\ No newline at end of file
diff --git a/ZOOM/api/manual_map/templates/manual_mapping/output.html b/ZOOM/api/manual_map/templates/manual_mapping/output.html
new file mode 100644
index 00000000..536730d8
--- /dev/null
+++ b/ZOOM/api/manual_map/templates/manual_mapping/output.html
@@ -0,0 +1,38 @@
+
+
+
+
+
+
+
+ ZOOM
+
+
+ id | file_source | data created | indicator_type | indicator | subgroup | country_id | date | source | value | footnote |
+
+ {% for line in data_check %}
+
+ {{line.id}} |
+ {{line.file_source}} |
+ {{line.date_created}} |
+ {{line.indicator_category}} |
+ {{line.indicator}} |
+ {{line.subgroup}} |
+ {{line.country_id}} |
+ {{line.date_value}} |
+ {{line.source}} |
+ {{line.measure_value}} |
+ {{line.other}} |
+
+ {% endfor %}
+
+
+
\ No newline at end of file
diff --git a/ZOOM/api/manual_map/templates/manual_mapping/tags.html b/ZOOM/api/manual_map/templates/manual_mapping/tags.html
new file mode 100644
index 00000000..bced8e41
--- /dev/null
+++ b/ZOOM/api/manual_map/templates/manual_mapping/tags.html
@@ -0,0 +1,97 @@
+{% load staticfiles %}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Add the tags list related to the file source
+
+
+
+
+
+
+
+
+
+
File Tagger "{{file_name}}"
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {% for tg in tags_array %}
+
+ {% endfor %}
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/ZOOM/api/manual_map/tests.py b/ZOOM/api/manual_map/tests.py
new file mode 100644
index 00000000..7ce503c2
--- /dev/null
+++ b/ZOOM/api/manual_map/tests.py
@@ -0,0 +1,3 @@
+from django.test import TestCase
+
+# Create your tests here.
diff --git a/ZOOM/api/manual_map/urls.py b/ZOOM/api/manual_map/urls.py
new file mode 100644
index 00000000..5fa4ba87
--- /dev/null
+++ b/ZOOM/api/manual_map/urls.py
@@ -0,0 +1,10 @@
+from django.conf.urls import url
+
+from . import views
+from rest_framework.urlpatterns import format_suffix_patterns
+
+urlpatterns = [
+ url(r'^manual_map/$', views.manual_mapping, name='manual_map'),
+]
+
+urlpatterns = format_suffix_patterns(urlpatterns)
\ No newline at end of file
diff --git a/ZOOM/api/manual_map/views.py b/ZOOM/api/manual_map/views.py
index f80411cb..328fb69d 100644
--- a/ZOOM/api/manual_map/views.py
+++ b/ZOOM/api/manual_map/views.py
@@ -8,6 +8,10 @@
from django.conf import settings
from sqlalchemy import create_engine
from lib.tools import check_column_data, correct_data, convert_df
+from django.http import Http404
+from rest_framework.views import APIView
+from rest_framework.response import Response
+from rest_framework import status
from rest_framework.decorators import api_view
import numpy as np
import pandas as pd
@@ -17,25 +21,28 @@
import time
import os
-
@api_view(['GET', 'POST'])
-def begin_map(request):
-
- if request.method == 'POST':
+def manual_mapping(request):
+ print('Recieved request')
+ print(request)
+ if request.method == 'POST':
+ print('Rewuest Recieved')
#check data types
-
+ print(request)
# add validation check here
if 'dict' in request.POST:
- mappings = json.loads(request.POST['dict'])
+ print('here')
+ mappings = json.loads(request.data['dict'])
mappings.pop("null", None)
mappings.pop("unit_measure", None)#change later
mappings.pop("validate_store", None) # remove??
- df_data = pd.read_csv(request.session['files'][0]) # change to use with multiple files
+ df_data = pd.read_csv(request.data['file_id']) # change to use with multiple files
found_dtype = []
convert_to_dtype = []
error_message = []
correction_mappings = {}
- dict_name = request.session['dtypes']
+
+ dict_name = mappings.pop("empty_indicator", None)#request.session['dtypes']
indicator_value = mappings.pop("empty_indicator", None)
country_value = mappings.pop("empty_country", None)
indicator_category_value = mappings.pop("empty_indicator_cat", None)
@@ -147,14 +154,12 @@ def begin_map(request):
#cache.clear() # check if necessary for ctrf token?
context = {}
missing = []
- for heading in request.session['missing_list']: #why not just pass missing list instead of missing
- missing.append(heading.replace(" ", "~"))#check this
- #context = {"files" : request.session['files'], "missing_headings" : missing, "remaining_headings" : request.session['remaining_headings'], "error_messages" : error_message}
- context = {'success': 0, "error_messages" : error_message}
- return Response(context)
+ #for heading in request.session['missing_list']: #why not just pass missing list instead of missing
+ # missing.append(heading.replace(" ", "~"))#check this
+ context = {"error_messages" : error_message, "success" : 0}
#return render(request, 'manual_mapping/manual_mapping.html', context)
#return HttpResponse(error_message)
-
+ return Response(context)
df_data = correct_data(df_data, correction_mappings)
#df_data = df_data[1:len(df_data)]
@@ -163,7 +168,7 @@ def begin_map(request):
bulk_list = []
#cycle through dataset and save each line
- order["file_source_id"] = request.session['files'][0]
+ order["file_source_id"] = request.data['file_id'];#request.session['files'][0]
instance = FileSource(file_name = order['file_source_id'])
instance.save()
file_id = instance.id
@@ -262,7 +267,7 @@ def begin_map(request):
#instance = MeasureValue(value = order['measure_value'], value_type =order['unit_measure'], name="")
#bulk_measure_value.append(instance)
- #del order['unit_measure'] # temporary fix
+ #del order['unit_measure'] # temporary fix
#add measure unit
#order['measure_value'] = instance
#add foreign keys to indicator datapoint model
@@ -287,20 +292,15 @@ def begin_map(request):
#os.remove(dict_name)#remove tmp file with datatypes
#Transgender people: HIV prevalence,
#convert_to_JSON("Transgender people: HIV prevalence", "Transgender people: Population size estimate")#allow user to choose these
- context = {'success': 1}
+
+ #return HttpResponseRedirect('tags/%d'%file_id)
+ #return nothing
+ context = {"success" : 1}
+ #return render(request, 'manual_mapping/manual_mapping.html', context)
+ #return HttpResponse(error_message)
+ return Response(context)
+ else:
+ context = {"error_messages" : "No data in dictionary sent", "success" : 0}
return Response(context)
- #return nothing
else:
- #cache.clear() # check if necessary for ctrf token?
- #error
-
- #context = {}
- #missing = []
- #dict_values = []
- #for heading in request.session['missing_list']: #why not just pass missing list instead of missing
- # missing.append(heading.replace(" ", "~"))
- # dict_values.append(heading)
-
- #context = {"files" : request.session['files'], "missing_headings" : missing, "remaining_headings" : request.session['remaining_headings'], "dict_values" : dict_values}
- #return render(request, 'manual_mapping/manual_mapping.html', context)
- return Response("Error")
\ No newline at end of file
+ return Response("No file selected");
diff --git a/ZOOM/api/urls.py b/ZOOM/api/urls.py
index 1d5f32bb..db19cff0 100644
--- a/ZOOM/api/urls.py
+++ b/ZOOM/api/urls.py
@@ -10,5 +10,6 @@
url(r'^file/', include('api.file.urls')),
url(r'^file-source/', include('api.file_source.urls', namespace='file_source')),
url(r'^validate/', include('api.validate.urls')),
+ url(r'^manual_map/', include('api.manual_map.urls'))
]