-
Notifications
You must be signed in to change notification settings - Fork 8
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
35 changed files
with
3,002 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
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,177 @@ | ||
<h:html xmlns:h="http://www.w3.org/1999/xhtml" xmlns:orx="http://openrosa.org/jr/xforms" xmlns="http://www.w3.org/2002/xforms" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:jr="http://openrosa.org/javarosa"> | ||
<h:head> | ||
<h:title>Screening</h:title> | ||
<model> | ||
<instance> | ||
<data xmlns:jrm="http://dev.commcarehq.org/jr/xforms" xmlns="http://openrosa.org/formdesigner/14E94611-71B6-439E-9930-F5537CC14FC7" uiVersion="1" version="1" name="Screening"> | ||
<date /> | ||
<time /> | ||
<selected_village/> | ||
<selected_group/> | ||
<selected_video/> | ||
<selected_mediator /> | ||
<attendee_ids /> | ||
<number_of_attendees_display/> | ||
<num_people/> | ||
<attendance_record jr:template=""> | ||
<index /> | ||
<attendee_name_display/> | ||
<attendee_id /> | ||
<attendee_name /> | ||
<attended /> | ||
<interested /> | ||
<question_asked/> | ||
</attendance_record> | ||
</data> | ||
</instance> | ||
|
||
<instance id="village" src="jr://fixture/item-list:village"/> | ||
<instance id="group" src="jr://fixture/item-list:group"/> | ||
<instance id="person" src="jr://fixture/item-list:person"/> | ||
<instance id="mediator" src="jr://fixture/item-list:mediator"/> | ||
<instance id="video" src="jr://fixture/item-list:video"/> | ||
|
||
<bind nodeset="/data/date" type="xsd:date" required="true()"/> | ||
<!-- Time widget: remove required="true()" because that doesn't work in the preview --> | ||
<bind nodeset="/data/time" type="xsd:time" /> | ||
<bind nodeset="/data/selected_village" /> | ||
<bind nodeset="/data/selected_group" /> | ||
<bind nodeset="/data/selected_video" /> | ||
<bind nodeset="/data/attendee_ids" calculate="if(/data/selected_group = '', '', join(' ', instance('person')/person_list/person[selected(/data/selected_group,group_id)]/id))"/> | ||
<bind nodeset="/data/number_of_attendees_display"/> | ||
<bind nodeset="/data/attendance_record"/> | ||
<bind nodeset="/data/attendance_record/index" type="xsd:string" calculate="position(..)"/> | ||
<bind nodeset="/data/attendance_record/attendee_name_display"/> | ||
<bind nodeset="/data/attendance_record/attendee_id" calculate="selected-at(/data/attendee_ids, current()/../index)"/> | ||
<bind nodeset="/data/attendance_record/attendee_name" calculate="instance('person')/person_list/person[selected(/data/selected_group,group_id) and id=current()/../attendee_id]/name"/> | ||
<bind nodeset="/data/attendance_record/attended" required="true()"/> | ||
<bind nodeset="/data/attendance_record/interested" relevant="/data/attendance_record/attended > 0"/> | ||
<bind nodeset="/data/attendance_record/question_asked" type="xsd:string" relevant="/data/attendance_record/attended > 0"/> | ||
<bind nodeset="/data/num_people" calculate="if(/data/selected_group = '',0, int(count(instance('person')/person_list/person[selected(/data/selected_group,group_id)])))"/> | ||
<itext> | ||
<translation lang="en" default=""> | ||
<text id="number_of_attendees_display-label"> | ||
<value>Enter Attendance</value> | ||
</text> | ||
<text id="attendance_record-label"> | ||
<value>Attendance Record</value> | ||
</text> | ||
<text id="index-label"> | ||
<value>Current Index</value> | ||
</text> | ||
<!--text id="attendee_name_display-label"> | ||
<value><output ref="/data/attendance_record/attendee_name" /></value> | ||
</text--> | ||
<text id="question_asked-label"> | ||
<value>Question Asked</value> | ||
</text> | ||
<text id="attended-label"> | ||
<value><output ref="/data/attendance_record/attendee_name" /></value> | ||
</text> | ||
<text id="attended_yes-label"> | ||
<value>Yes</value> | ||
</text> | ||
<text id="attended_no-label"> | ||
<value>No</value> | ||
</text> | ||
<text id="interested-label"> | ||
<value>Interested</value> | ||
</text> | ||
<text id="interested_yes-label"> | ||
<value>Yes</value> | ||
</text> | ||
<text id="interested_no-label"> | ||
<value>No</value> | ||
</text> | ||
<text id="selected_village-label"> | ||
<value>Village</value> | ||
</text> | ||
<text id="selected_mediator-label"> | ||
<value>Mediator</value> | ||
</text> | ||
<text id="selected_group-label"> | ||
<value>Group</value> | ||
</text> | ||
<text id="selected_video-label"> | ||
<value>Video</value> | ||
</text> | ||
<text id="date-label"> | ||
<value>Date</value> | ||
</text> | ||
<text id="time-label"> | ||
<value>Time</value> | ||
</text> | ||
</translation> | ||
</itext> | ||
</model> | ||
</h:head> | ||
<h:body> | ||
<input ref="/data/date"> | ||
<label ref="jr:itext('date-label')"/> | ||
</input> | ||
<input ref="/data/time"> | ||
<label ref="jr:itext('time-label')"/> | ||
</input> | ||
<select1 ref="/data/selected_village"> | ||
<label ref="jr:itext('selected_village-label')"/> | ||
<itemset nodeset="instance('village')/village_list/village"> | ||
<label ref="name"/> | ||
<value ref="id"/> | ||
</itemset> | ||
</select1> | ||
<select1 ref="/data/selected_mediator"> | ||
<label ref="jr:itext('selected_mediator-label')"/> | ||
<itemset nodeset="instance('mediator')/mediator_list/mediator[village_id=/data/selected_village]"> | ||
<label ref="name"/> | ||
<value ref="id"/> | ||
</itemset> | ||
</select1> | ||
<select ref="/data/selected_group"> | ||
<label ref="jr:itext('selected_group-label')"/> | ||
<itemset nodeset="instance('group')/group_list/group[village_id=/data/selected_village]"> | ||
<label ref="name"/> | ||
<value ref="id"/> | ||
</itemset> | ||
</select> | ||
<select ref="/data/selected_video"> | ||
<label ref="jr:itext('selected_video-label')"/> | ||
<itemset nodeset="instance('video')/video_list/video[date(low) <=/data/date and date(high) >=/data/date]"> | ||
<label ref="name"/> | ||
<value ref="id"/> | ||
</itemset> | ||
</select> | ||
<trigger ref="/data/number_of_attendees_display"> | ||
<label ref="jr:itext('number_of_attendees_display-label')"/> | ||
</trigger> | ||
<group> | ||
<label ref="jr:itext('attendance_record-label')"/> | ||
<repeat nodeset="/data/attendance_record" jr:count="/data/num_people"> | ||
<select1 ref="/data/attendance_record/attended"> | ||
<label ref="jr:itext('attended-label')"/> | ||
<item> | ||
<label ref="jr:itext('attended_yes-label')"/> | ||
<value>1</value> | ||
</item> | ||
<item> | ||
<label ref="jr:itext('attended_no-label')"/> | ||
<value>0</value> | ||
</item> | ||
</select1> | ||
<select1 ref="/data/attendance_record/interested"> | ||
<label ref="jr:itext('interested-label')"/> | ||
<item> | ||
<label ref="jr:itext('interested_yes-label')"/> | ||
<value>1</value> | ||
</item> | ||
<item> | ||
<label ref="jr:itext('interested_no-label')"/> | ||
<value>0</value> | ||
</item> | ||
</select1> | ||
<input ref="/data/attendance_record/question_asked"> | ||
<label ref="jr:itext('question_asked-label')"/> | ||
</input> | ||
</repeat> | ||
</group> | ||
</h:body> | ||
</h:html> |
Binary file not shown.
Binary file not shown.
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,36 @@ | ||
# -*- coding: utf-8 -*- | ||
import datetime | ||
from south.db import db | ||
from south.v2 import SchemaMigration | ||
from django.db import models | ||
|
||
|
||
class Migration(SchemaMigration): | ||
|
||
def forwards(self, orm): | ||
# Adding model 'XMLSubmission' | ||
db.create_table('dimagi_xmlsubmission', ( | ||
('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), | ||
('submission_time', self.gf('django.db.models.fields.DateTimeField')(auto_now=True, blank=True)), | ||
('modification_time', self.gf('django.db.models.fields.DateTimeField')(auto_now_add=True, blank=True)), | ||
('xml_data', self.gf('django.db.models.fields.TextField')()), | ||
)) | ||
db.send_create_signal('dimagi', ['XMLSubmission']) | ||
|
||
|
||
def backwards(self, orm): | ||
# Deleting model 'XMLSubmission' | ||
db.delete_table('dimagi_xmlsubmission') | ||
|
||
|
||
models = { | ||
'dimagi.xmlsubmission': { | ||
'Meta': {'object_name': 'XMLSubmission'}, | ||
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), | ||
'modification_time': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}), | ||
'submission_time': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}), | ||
'xml_data': ('django.db.models.fields.TextField', [], {}) | ||
} | ||
} | ||
|
||
complete_apps = ['dimagi'] |
42 changes: 42 additions & 0 deletions
42
...migrations/0002_auto__add_field_xmlsubmission_error_code__add_field_xmlsubmission_erro.py
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,42 @@ | ||
# -*- coding: utf-8 -*- | ||
import datetime | ||
from south.db import db | ||
from south.v2 import SchemaMigration | ||
from django.db import models | ||
|
||
|
||
class Migration(SchemaMigration): | ||
|
||
def forwards(self, orm): | ||
# Adding field 'XMLSubmission.error_code' | ||
db.add_column('dimagi_xmlsubmission', 'error_code', | ||
self.gf('django.db.models.fields.IntegerField')(null=True), | ||
keep_default=False) | ||
|
||
# Adding field 'XMLSubmission.error_message' | ||
db.add_column('dimagi_xmlsubmission', 'error_message', | ||
self.gf('django.db.models.fields.TextField')(null=True), | ||
keep_default=False) | ||
|
||
|
||
def backwards(self, orm): | ||
# Deleting field 'XMLSubmission.error_code' | ||
db.delete_column('dimagi_xmlsubmission', 'error_code') | ||
|
||
# Deleting field 'XMLSubmission.error_message' | ||
db.delete_column('dimagi_xmlsubmission', 'error_message') | ||
|
||
|
||
models = { | ||
'dimagi.xmlsubmission': { | ||
'Meta': {'object_name': 'XMLSubmission'}, | ||
'error_code': ('django.db.models.fields.IntegerField', [], {'null': 'True'}), | ||
'error_message': ('django.db.models.fields.TextField', [], {'null': 'True'}), | ||
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), | ||
'modification_time': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}), | ||
'submission_time': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}), | ||
'xml_data': ('django.db.models.fields.TextField', [], {}) | ||
} | ||
} | ||
|
||
complete_apps = ['dimagi'] |
53 changes: 53 additions & 0 deletions
53
...migrations/0003_auto__add_field_xmlsubmission_username__add_field_xmlsubmission_start_.py
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,53 @@ | ||
# -*- coding: utf-8 -*- | ||
import datetime | ||
from south.db import db | ||
from south.v2 import SchemaMigration | ||
from django.db import models | ||
|
||
|
||
class Migration(SchemaMigration): | ||
|
||
def forwards(self, orm): | ||
# Adding field 'XMLSubmission.username' | ||
db.add_column('dimagi_xmlsubmission', 'username', | ||
self.gf('django.db.models.fields.TextField')(default='', blank=True), | ||
keep_default=False) | ||
|
||
# Adding field 'XMLSubmission.start_time' | ||
db.add_column('dimagi_xmlsubmission', 'start_time', | ||
self.gf('django.db.models.fields.DateTimeField')(null=True, blank=True), | ||
keep_default=False) | ||
|
||
# Adding field 'XMLSubmission.end_time' | ||
db.add_column('dimagi_xmlsubmission', 'end_time', | ||
self.gf('django.db.models.fields.DateTimeField')(null=True, blank=True), | ||
keep_default=False) | ||
|
||
|
||
def backwards(self, orm): | ||
# Deleting field 'XMLSubmission.username' | ||
db.delete_column('dimagi_xmlsubmission', 'username') | ||
|
||
# Deleting field 'XMLSubmission.start_time' | ||
db.delete_column('dimagi_xmlsubmission', 'start_time') | ||
|
||
# Deleting field 'XMLSubmission.end_time' | ||
db.delete_column('dimagi_xmlsubmission', 'end_time') | ||
|
||
|
||
models = { | ||
'dimagi.xmlsubmission': { | ||
'Meta': {'object_name': 'XMLSubmission'}, | ||
'end_time': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}), | ||
'error_code': ('django.db.models.fields.IntegerField', [], {'null': 'True'}), | ||
'error_message': ('django.db.models.fields.TextField', [], {'null': 'True'}), | ||
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), | ||
'modification_time': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}), | ||
'start_time': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}), | ||
'submission_time': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}), | ||
'username': ('django.db.models.fields.TextField', [], {'blank': 'True'}), | ||
'xml_data': ('django.db.models.fields.TextField', [], {}) | ||
} | ||
} | ||
|
||
complete_apps = ['dimagi'] |
Empty file.
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,19 @@ | ||
from django.db import models | ||
error_list = dict({'UNIDENTIFIED_FORM' : -1, | ||
'SCREENING_SAVE_ERROR' : -2, | ||
'SCREENING_READ_ERROR' : -3, | ||
'ADOPTION_SAVE_ERROR' : -4, | ||
'ADOPTION_READ_ERROR' : -5, | ||
'PMA_SAVE_ERROR' : -6, | ||
}) | ||
|
||
class XMLSubmission(models.Model): | ||
submission_time = models.DateTimeField(auto_now=True) | ||
modification_time = models.DateTimeField(auto_now_add=True) | ||
xml_data = models.TextField() | ||
username = models.TextField(blank=True) | ||
start_time = models.DateTimeField(null=True, blank=True) | ||
end_time = models.DateTimeField(null=True, blank=True) | ||
error_code = models.IntegerField(null=True) | ||
error_message = models.TextField(null=True) | ||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Empty file.
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,16 @@ | ||
# -*- coding: utf-8 -*- | ||
import settings | ||
from django.core.management import setup_environ | ||
setup_environ(settings) | ||
from userfile_functions import read_userfile, make_upload_file, upload_file | ||
|
||
data = read_userfile('userfile.json') | ||
for entry in data: | ||
print entry['username'] | ||
villages = entry['villages'] | ||
filename = entry['username'] + '.xml' | ||
file_to_upload = make_upload_file(villages, filename) | ||
break | ||
|
||
|
||
|
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,28 @@ | ||
import urllib2 | ||
|
||
print "Fetching ..." | ||
opener = urllib2.build_opener(urllib2.HTTPHandler) | ||
opener.addheaders =[('User-agent', 'Mozilla/5.0'), | ||
('user', 'nandini@digitalgreen:digitalgreen'), | ||
('Cookie', 'csrftoken=97a5a243ad2abf742d6efb8c8d761c4f; sessionid=2b175aad09329500ba61126ecc88cf20; __utma=166502700.872983835.1346667629.1354086932.1354120837.88; __utmb=166502700.3.10.1354120837; __utmc=166502700; __utmz=166502700.1352897150.78.5.utmcsr=google|utmccn=(organic)|utmcmd=organic|utmctr=(not%20provided)')] | ||
response = opener.open('https://www.commcarehq.org/a/digitalgreen/fixtures/data-types/') | ||
print "Data Types Retrieved" | ||
string_response = response.read() | ||
|
||
types = string_response.split('fields') | ||
ids_to_delete = [] | ||
for i in range(len(types)-1): | ||
ids_to_delete.append(types[i+1].partition('_id": "')[2].partition('"}')[0]) | ||
print ids_to_delete | ||
if len(ids_to_delete) == 0: | ||
print "Nothing to delete" | ||
else: | ||
for id in ids_to_delete: | ||
try: | ||
request_string = 'https://www.commcarehq.org/a/digitalgreen/fixtures/data-types/' + str(id) | ||
request = urllib2.Request(request_string) | ||
request.get_method = lambda: 'DELETE' | ||
url = opener.open(request) | ||
print "Deleted item : " + str(id) | ||
except Exception as ex: | ||
print " Could not delete item : " + str (id) |
Oops, something went wrong.