pfitzpaddy / ngm-reportDesk

The workdesk for ReportHub
1 stars 6 forks source link

Activities: Update activities / indicators to HRP 2020 #339

Closed pfitzpaddy closed 4 years ago

pfitzpaddy commented 4 years ago

Activity/Description/SO

ESNFI In-Kind

ESNFI in Cash

ESNFI mixed (Cash + In-Kind)

Partial ESNFI kit

Emergency Shelter Repair kits (Full)

Emergency Shelter Repair kits (Partial)

Cash for Shelter/rent

Minor Shelter Repair kits

Cash for Shelter- communal shelters

Cash for partial repair-Minor

Emergency Shelter Repair Kits Mixed (Cash + In-Kind)

pfitzpaddy commented 4 years ago

Adding the new activity types to active ET projects

// add new activities
db.getCollection('project').find({ admin0pcode:'ET', cluster_id:'esnfi', project_end_date: { $gte: new ISODate('2020-01-01') } }).forEach(function(d){
    var esnfi = {
        "cluster_id" : "esnfi",
        "cluster" : "ESNFI",
        "activity_type_id" : "esnfi_distribution",
        "activity_type_name" : "ESNFI Distribution"
    }
    var shelter = {
        "cluster_id" : "esnfi",
        "cluster" : "ESNFI",
        "activity_type_id" : "shelter_reconstruction_repair",
        "activity_type_name" : "Shelter Reconstruction/Repair"
    }
    d.activity_type.push(esnfi)
    d.activity_type.push(shelter)
    db.getCollection('project').save(d);
});

Adding the new activity types to all projects

// add disabled
db.getCollection('project').find({ admin0pcode: 'ET', cluster_id:'esnfi' }).forEach(function(d){
    // update activities to disabled
    for (i = 0; i < d.activity_type.length; i++) {
        if ( d.activity_type[ i ].activity_type_id !== "esnfi_distribution" &&
                d.activity_type[ i ].activity_type_id !== "shelter_reconstruction_repair" ) {
                        d.activity_type[ i ].disabled = 1;
        }
    }
    db.getCollection('project').save(d);
});
pfitzpaddy commented 4 years ago

@drfaustusfade, @fakhrihawari, I have made a temporary workaround for new lists in this commit

  1. I have included the attribute active in the activities.csv
  2. As a workaround for existing projects for ET, I have added the new activity types required for 2020 and set disabled tag in the existing project.definition.activity_types that are no longer required (db update above)
  3. On new projects, only active activities will be available for selection (this actually needs a small update)
  4. Then, for Target Beneficiaries / Monthly Reports, 2 select templates are implemented. For new beneficiaries (no beneficiary.id), only the active:1 lists are available, whereas for existing beneficiaries (benficiary.id exists), the entire list is displayed so that the dropdown will display correctly.

Its extra code in the HTML but I was running out of time - and it works for now.

pfitzpaddy commented 4 years ago

Scrap that last comment (horrible idea), I have removed the duplicate select html templates from the commit above, now there is just custom filters here.