Skip to content

Commit

Permalink
hotfixes #7 (#1012)
Browse files Browse the repository at this point in the history
* truly restrict forms to those available to the participant.

* fixed an issue where you would have a blank field and validation will fail.

* added the name field to the participant schema so it can be rendered in the selector.

* fixed bug where master checklists weren't also including section timestamp labels
  • Loading branch information
takinbo authored Oct 25, 2024
1 parent 9281642 commit c7e7d9a
Show file tree
Hide file tree
Showing 5 changed files with 140 additions and 169 deletions.
7 changes: 4 additions & 3 deletions apollo/participants/api/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@


class ParticipantSchema(BaseModelSchema):
role = ma.fields.Method('get_role')
role = ma.fields.Method("get_role")

class Meta:
"""ParticipantSchema Meta."""

model = Participant
fields = ('id', 'full_name', 'first_name', 'other_names', 'last_name',
'participant_id', 'role')
fields = ("id", "name", "full_name", "first_name", "other_names", "last_name", "participant_id", "role")

def get_role(self, obj):
return obj.role.name
12 changes: 8 additions & 4 deletions apollo/participants/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,10 +235,14 @@ def _get_form_data(participant: Participant):
)

# get participant submissions
participant_submissions = Submission.query.join(
EventAlias,
and_(EventAlias.participant_set_id == participant.participant_set_id, Submission.event_id == EventAlias.id),
).join(FormAlias, Submission.form_id == FormAlias.id)
participant_submissions = (
Submission.query.filter(Submission.participant_id == participant.id)
.join(
EventAlias,
and_(EventAlias.participant_set_id == participant.participant_set_id, Submission.event_id == EventAlias.id),
)
.join(FormAlias, Submission.form_id == FormAlias.id)
)

# get checklist and survey forms based on the available submissions
non_incident_forms = participant_submissions.with_entities(FormAlias).distinct(FormAlias.id)
Expand Down
2 changes: 1 addition & 1 deletion apollo/pwa/static/js/serviceworker.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const CACHE_NAME = 'apollo-cache-static-v11';
const CACHE_NAME = 'apollo-cache-static-v12';

const CACHED_URLS = [
'/pwa/',
Expand Down
26 changes: 13 additions & 13 deletions apollo/pwa/templates/pwa/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ <h6 class="card-header" :class="getCompletionClass(index)"><a class="text-white"
};
if (a.form_type !== b.form_type)
return FORM_TYPE_MAP[a.form_type] - FORM_TYPE_MAP[b.form_type];

if (a.name > b.name)
return 1;
else if (a.name < b.name)
Expand Down Expand Up @@ -381,7 +381,7 @@ <h6 class="card-header" :class="getCompletionClass(index)"><a class="text-white"
acc += ((data[field.tag] !== undefined && data[field.tag] !== '') ? 1 : 0);
return acc;
}, 0);

return completion;
};

Expand All @@ -394,7 +394,7 @@ <h6 class="card-header" :class="getCompletionClass(index)"><a class="text-white"

if ((completion.total === completion.filled) && submission.passedQA)
return true;

return false;
};

Expand Down Expand Up @@ -479,7 +479,7 @@ <h6 class="card-header" :class="getCompletionClass(index)"><a class="text-white"
status = '{{ _("Partial") }}';
else
status = '{{ _("Complete") }}';

return status;
}
},
Expand Down Expand Up @@ -531,7 +531,7 @@ <h6 class="card-header" :class="getCompletionClass(index)"><a class="text-white"
return true;
else if (this.submission.updated.getTime() > this.submission.posted.getTime())
return true;

return false;
},
showQAStatus() {
Expand Down Expand Up @@ -745,7 +745,7 @@ <h6 class="card-header" :class="getCompletionClass(index)"><a class="text-white"
});
});
}

return sub;
},
newSubmission(form) {
Expand Down Expand Up @@ -847,7 +847,7 @@ <h6 class="card-header" :class="getCompletionClass(index)"><a class="text-white"
if (instance.data[field.tag] !== undefined || instance.data[field.tag] !== null) {
if ((fieldData < field.min) || (fieldData > field.max))
errorFields.push(field.tag);
else if (Number.parseInt(fieldData.toString()) !== fieldData)
else if (fieldData !== undefined && Number.parseInt(fieldData.toString()) !== fieldData)
errorFields.push(field.tag);
}
});
Expand Down Expand Up @@ -1048,18 +1048,18 @@ <h6 class="card-header" :class="getCompletionClass(index)"><a class="text-white"
return instance.submissions.filter(submission => {
if (submission.posted === null)
return true;

if (submission.updated.getTime() > submission.posted.getTime())
return true;

return false;
}).length;
},
groupedSubmissions() {
let instance = this;
if (instance.forms === null || instance.forms === [] || instance.submissions === null || instance.submissions === [])
return {};

return instance.forms.reduce((acc, form) => {
acc[form.id] = instance.submissionsSubset(form);
return acc;
Expand Down Expand Up @@ -1172,7 +1172,7 @@ <h6 class="card-header" :class="getCompletionClass(index)"><a class="text-white"
let formIds = new Set(forms.map(form => form.id));
instance._loadCollectionFromDatabase(db.forms, dbForms => {
unusedFormIds = dbForms.filter(form => !formIds.has(form.id)).map(form => form.id);

db.forms.bulkPut(forms);
db.forms.bulkDelete(unusedFormIds);

Expand Down Expand Up @@ -1410,7 +1410,7 @@ <h6 class="card-header" :class="getCompletionClass(index)"><a class="text-white"

if (instance.currentSubmission === submission)
return false;

return !submission.passedQA;
})
.forEach(submission => {
Expand Down Expand Up @@ -1449,7 +1449,7 @@ <h6 class="card-header" :class="getCompletionClass(index)"><a class="text-white"
globalStatus() {
if (this.submissions.length === 0)
return 0;

let unchangedSubmissions = this.submissions.filter(sub => sub.updated === null);
if (unchangedSubmissions.length === this.submissions.length)
return 0;
Expand Down
Loading

0 comments on commit c7e7d9a

Please sign in to comment.