uoft-tapp / tapp-cp

TA assignment and matching application (TAPP) & Contract Presentment helper (CP) at the Department of Computer Science, University of Toronto
8 stars 6 forks source link

application of ddah templates broken #94

Open jmzaleski opened 7 years ago

jmzaleski commented 7 years ago

This is a really weird one. No sense of whether it's front end or back end.. Basic issue is that when I apply a template for the second time the TA the template was applied to PREVIOUSLY seems to be set back to some empty default condition.

Okay, it's weird, so here's a detailed recipe for the simplest case I could find, namely applying one template to another. BTW, as will become clear below, only happens when you save the second template.

At time of writing HEAD of master was https://github.com/uoft-tapp/tapp-cp/commit/d24fed264dfb5e8d1ecf8418b00b660e522ad326

I started with a clean image. down -v all around.

  1. hack fetch.js to pretend you are some instructor (zaleskim)
    iff --git a/app/javascript/cp/fetch.js b/app/javascript/cp/fetch.js
    index 2a9b57d..1bf48ce 100644
    --- a/app/javascript/cp/fetch.js
    +++ b/app/javascript/cp/fetch.js
    @@ -1274,7 +1274,7 @@ function fetchAuth() {
                 appState.setCurrentUserRoles(['cp_admin', 'hr_assistant', 'instructor']);
                 // default to cp_admin as selected user role
                 appState.selectUserRole('cp_admin');
    -                appState.setCurrentUserName('DEV');
    +                appState.setCurrentUserName('zaleskim'); //HACK: fake shib authentication
             } else {
                 // filter out roles not relevant to this application
                 let roles = resp.roles.filter(role =>
  2. up --build
  3. docker-compose run rails-app rake db:migrate db:seed
  4. visit http://localhost:3000/tapp/summary and import AS COURSE db/seeds/make-fake-chass-applicant-import-CSC300.json
  5. visit http://localhost:3000/cp and import db/seeds/matz-fake-offer-for-csc300-tas.json
  6. visit http://localhost:3000/cp/ddahs
  7. now switch roles to instructor (this is what above fetch.js hack makes possible)
  8. create a ddah template. Call it t1. put a recognizable line in it
  9. SAVE t1
  10. create a second ddah template. Call it t2. apply t1.
  11. SAVE t2
  12. holy smokes.. t1 just became empty!

If you do not save t2 after applying t1, but instead cancel out then t1 survives. IT IS THE SAVE

jmzaleski commented 7 years ago

I repeated the above recipe (except templates z1,z2) using postman, so I could see what the server thought at each point. looks pretty clear that the save of template z2 ruins the allocations of template z1

make z1, save it

{
        "id": 5,
        "name": "z1",
        "optional": true,
        "instructor_id": 2,
        "tutorial_category": "Classroom TA",
        "department": "Computer Science",
        "created_at": "2017-09-29T11:42:28.854-04:00",
        "updated_at": "2017-09-29T11:42:28.854-04:00",
        "scaling_learning": false,
        "supervisor": "Mathew Zaleski",
        "allocations": [
            {
                "id": 3,
                "num_unit": 42,
                "unit_name": "created in z1",
                "minutes": 60,
                "duty_id": 5,
                "created_at": "2017-09-29T11:43:05.266-04:00",
                "updated_at": "2017-09-29T11:43:05.266-04:00"
            }
        ],
        "trainings": [],
        "categories": []
    }

apply z1 to z2

{
        "id": 5,
        "name": "z1",
        "optional": true,
        "instructor_id": 2,
        "tutorial_category": "Classroom TA",
        "department": "Computer Science",
        "created_at": "2017-09-29T11:42:28.854-04:00",
        "updated_at": "2017-09-29T11:42:28.854-04:00",
        "scaling_learning": false,
        "supervisor": "Mathew Zaleski",
        "allocations": [
            {
                "id": 3,
                "num_unit": 42,
                "unit_name": "created in z1",
                "minutes": 60,
                "duty_id": 5,
                "created_at": "2017-09-29T11:43:05.266-04:00",
                "updated_at": "2017-09-29T11:43:05.266-04:00"
            }
        ],
        "trainings": [],
        "categories": []
    },

create z2 (no allocations)

    {
        "id": 6,
        "name": "z2",
        "optional": true,
        "instructor_id": 2,
        "tutorial_category": "Classroom TA",
        "department": "Computer Science",
        "created_at": "2017-09-29T11:44:29.179-04:00",
        "updated_at": "2017-09-29T11:44:29.179-04:00",
        "scaling_learning": false,
        "supervisor": "Mathew Zaleski",
        "allocations": [],
        "trainings": [],
        "categories": []
    }

apply z1 to z2.. note server is now behind client

{
        "id": 5,
        "name": "z1",
        "optional": true,
        "instructor_id": 2,
        "tutorial_category": "Classroom TA",
        "department": "Computer Science",
        "created_at": "2017-09-29T11:42:28.854-04:00",
        "updated_at": "2017-09-29T11:42:28.854-04:00",
        "scaling_learning": false,
        "supervisor": "Mathew Zaleski",
        "allocations": [
            {
                "id": 3,
                "num_unit": 42,
                "unit_name": "created in z1",
                "minutes": 60,
                "duty_id": 5,
                "created_at": "2017-09-29T11:43:05.266-04:00",
                "updated_at": "2017-09-29T11:43:05.266-04:00"
            }
        ],
        "trainings": [],
        "categories": []
    },
    {
        "id": 6,
        "name": "z2",
        "optional": true,
        "instructor_id": 2,
        "tutorial_category": "Classroom TA",
        "department": "Computer Science",
        "created_at": "2017-09-29T11:44:29.179-04:00",
        "updated_at": "2017-09-29T11:44:29.179-04:00",
        "scaling_learning": false,
        "supervisor": "Mathew Zaleski",
        "allocations": [],
        "trainings": [],
        "categories": []
    }

save z2. BOOM saving z2 removes allocations from z1

   {
        "id": 5,
        "name": "z1",
        "optional": true,
        "instructor_id": 2,
        "tutorial_category": "Classroom TA",
        "department": "Computer Science",
        "created_at": "2017-09-29T11:42:28.854-04:00",
        "updated_at": "2017-09-29T11:42:28.854-04:00",
        "scaling_learning": false,
        "supervisor": "Mathew Zaleski",
        "allocations": [],
        "trainings": [],
        "categories": []
    },
    {
        "id": 6,
        "name": "z2",
        "optional": true,
        "instructor_id": 2,
        "tutorial_category": "Classroom TA",
        "department": "Computer Science",
        "created_at": "2017-09-29T11:44:29.179-04:00",
        "updated_at": "2017-09-29T11:44:29.179-04:00",
        "scaling_learning": false,
        "supervisor": "Mathew Zaleski",
        "allocations": [
            {
                "id": 3,
                "num_unit": 42,
                "unit_name": "created in z1",
                "minutes": 60,
                "duty_id": 5,
                "created_at": "2017-09-29T11:43:05.266-04:00",
                "updated_at": "2017-09-29T11:47:44.079-04:00"
            }
        ],
        "trainings": [],
        "categories": []
    }