Skip to content

Commit

Permalink
Merge pull request #926 from medic/testing
Browse files Browse the repository at this point in the history
Release Medic Collect SMS parser
  • Loading branch information
abbyad committed May 21, 2015
2 parents ca278f0 + d70484f commit 4d217ca
Show file tree
Hide file tree
Showing 21 changed files with 2,076 additions and 1,070 deletions.
17 changes: 13 additions & 4 deletions Changes.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Medic Mobile Release Notes

## 0.4.4

### TBD

- Added support for a new messages parser we're calling Javarosa prefixed with
the `J1` format code.

- Added support for creating records by submitting JSON.

## 0.4.3

### Feb 26, 2015
Expand Down Expand Up @@ -47,17 +56,17 @@

### Sep 4, 2014

- fixed bug when searching for Patient IDs the field was not indexed correctly.
- Fixed bug: When searching for a patient identifier using the free-text search feature, results were not returned properly. Index the field appropriately.

## 0.4.1

### Jul 31, 2014

- minor UI clean up
- Minor UI clean up.

- allow hash symbol to separate form code and data in structured textform message
- Allow hash symbol to separate form code and data in structured textform message.

- modified build to bundle npm dependencies with attached node modules.
- Modified build to bundle npm dependencies with attached node modules.

## 0.4.0

Expand Down
2 changes: 1 addition & 1 deletion api
Submodule api updated 1 files
+1 −1 package.json
2 changes: 1 addition & 1 deletion kanso.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "medic",
"display_name": "Medic Mobile",
"version": "0.4.3",
"version": "0.4.4",
"description": "SMS data collection designed for rural environments.",
"long_description" : "Medic Mobile is a web based SMS data collection and analytics tool focused on community health care workers in rural environments. We help large health organizations collect and analyze data sent from health care workers using ordinary mobile phones.",
"url": "https://github.com/medic/medic-webapp",
Expand Down
37 changes: 31 additions & 6 deletions lib/validate_doc_update.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,18 @@ var allowed = function(newDoc, oldDoc, userCtx, secObj) {

// ensure logged in
if (userCtx.name === null) {
return {
return {
allowed: false,
message: 'You must be logged in to edit documents'
};
}

// admins can do anything
if (isDbAdmin(userCtx, secObj)
|| utils.isUserAdmin(userCtx)
if (isDbAdmin(userCtx, secObj)
|| utils.isUserAdmin(userCtx)
|| utils.isUserDistrictAdmin(userCtx)) {
return {
allowed: true
return {
allowed: true
};
}

Expand All @@ -49,7 +49,7 @@ var allowed = function(newDoc, oldDoc, userCtx, secObj) {
}

// gateway and data_entry users can update
if (utils.hasRole(userCtx, 'kujua_gateway')
if (utils.hasRole(userCtx, 'kujua_gateway')
|| utils.hasRole(userCtx, 'data_entry')) {
return {
allowed: true
Expand All @@ -63,11 +63,36 @@ var allowed = function(newDoc, oldDoc, userCtx, secObj) {
};
};

/**
* Ensure that type='form' documents are created with correctly formatted _id
* property.
*/
var validateForm = function(newDoc, oldDoc) {
var id_parts = newDoc._id.split(':'),
prefix = id_parts[0],
form_id = id_parts.slice(1).join(':');
function _err(msg) {
throw ({forbidden: msg + ' e.g. "form:registration"'});
};
if (prefix !== 'form') {
_err('_id property must be prefixed with "form:".');
};
if (!form_id) {
_err('_id property must define a value after "form:".');
};
if (newDoc._id !== newDoc._id.toLowerCase()) {
_err('_id property must be lower case.');
};
};

module.exports = function(newDoc, oldDoc, userCtx, secObj) {
var result = allowed(newDoc, oldDoc, userCtx, secObj);
if (result.allowed) {
log("User '" + userCtx.name + "' changing document '" + newDoc._id + "'");
} else {
throw { forbidden: result.message };
}
if (newDoc.type === 'form') {
validateForm(newDoc, oldDoc);
}
};
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "medic",
"version": "0.4.3",
"version": "0.4.4",
"repository": {
"type": "git",
"url": "git://github.com/medic/medic-webapp.git"
Expand All @@ -21,7 +21,7 @@
"grunt-contrib-uglify": "^0.5.0",
"grunt-contrib-watch": "^0.6.1",
"grunt-dustjs": "^1.2.1",
"grunt-dustjs-linkedin": "^0.5.0",
"grunt-dustjs-linkedin": "https://github.com/coryroloff/grunt-dustjs-linkedin/archive/v0.5.0.tar.gz",
"grunt-exec": "^0.4.5",
"grunt-karma": "~0.8.0",
"grunt-lesslint": "^1.1.7",
Expand Down
4 changes: 2 additions & 2 deletions packages/kujua-sms/kujua-sms/rewrites.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
exports.rules = [
{from: '/add', to: '_update/add_sms', method: 'POST'},
{from: '/add', to: '_update/add', method: 'POST'},
// by default smssync uses the same URL for tasks polling
{from: '/add',
to: '_list/tasks_pending/tasks_pending',
Expand All @@ -10,7 +10,7 @@ exports.rules = [
method: 'GET'
},
/* use this path if you need to specify the limit */
{from: '/add/limit/*', to: '_update/add_sms', method: 'POST'},
{from: '/add/limit/*', to: '_update/add', method: 'POST'},
{from: '/add/limit/:limit',
to: '_list/tasks_pending/tasks_pending',
query: {
Expand Down
Loading

0 comments on commit 4d217ca

Please sign in to comment.