Пример #1
0
 def clean(self):
     # unlike for submissions, this always gets called, because
     # participants are 'mobile' - they can be moved from one location
     # to another. we want this to reflect that.
     self.location_name_path = compute_location_path(self.location)
     if self.gender not in map(lambda op: op[0], self.GENDER):
         self.gender = ''
Пример #2
0
    def clean(self):
        # update location name path if it does not exist.
        # unlike for participants, submissions aren't 'mobile', that is,
        # there doesn't seem to be a use case for transferring submissions.
        # at least, not at the time of writing
        if not self.location_name_path:
            self.location_name_path = compute_location_path(self.location)

        # cleanup data fields
        self._update_data_fields()

        # save the submission without cleaning to prevent an infinite loop
        self.save(clean=False)

        # update the master submission
        self._update_master()

        if self.master == self:
            # update completion status
            self._update_completion_status()

        # and compute the verification
        self._compute_data_quality()

        # update the confidence
        self._update_confidence()

        # update the `updated` timestamp
        self.updated = datetime.utcnow()
Пример #3
0
    def clean(self):
        # update location name path if it does not exist.
        # unlike for participants, submissions aren't 'mobile', that is,
        # there doesn't seem to be a use case for transferring submissions.
        # at least, not at the time of writing
        if not self.location_name_path:
            self.location_name_path = compute_location_path(self.location)

        # cleanup data fields
        self._update_data_fields()

        # save the submission without cleaning to prevent an infinite loop
        self.save(clean=False)

        # update the master submission
        self._update_master()

        if self.master == self:
            # update completion status
            self._update_completion_status()

        # and compute the verification
        self._compute_data_quality()

        # update the confidence
        self._update_confidence()

        # update the `updated` timestamp
        self.updated = datetime.utcnow()
Пример #4
0
 def clean(self):
     # unlike for submissions, this always gets called, because
     # participants are 'mobile' - they can be moved from one location
     # to another. we want this to reflect that.
     self.location_name_path = compute_location_path(self.location)
     if self.gender not in map(lambda op: op[0], self.GENDER):
         self.gender = ''
Пример #5
0
def import_locations(upload_id, mappings):
    upload = services.user_uploads.get(pk=upload_id)
    dataframe = helpers.load_source_file(upload.data)

    update_locations(dataframe, mappings, upload.event)

    # fetch and update all submissions
    deployment = upload.event.deployment
    submissions = services.submissions.all().filter(deployment=deployment)
    for submission in submissions:
        if submission.location:
            submission.location_name_path = helpers.compute_location_path(submission.location)
            submission.save(clean=False)

    # delete uploaded file
    upload.data.delete()
    upload.delete()

    msg_body = render_template_string(email_template)

    send_email(_("Locations Import Report"), msg_body, [upload.user.email])
Пример #6
0
def import_locations(upload_id, mappings):
    upload = services.user_uploads.get(pk=upload_id)
    dataframe = helpers.load_source_file(upload.data)

    update_locations(dataframe, mappings, upload.event)

    # fetch and update all submissions
    deployment = upload.event.deployment
    submissions = services.submissions.all().filter(deployment=deployment)
    for submission in submissions:
        if submission.location:
            submission.location_name_path = helpers.compute_location_path(
                submission.location)
            submission.save(clean=False)

    # delete uploaded file
    upload.data.delete()
    upload.delete()

    msg_body = render_template_string(email_template)

    send_email(_('Locations Import Report'), msg_body, [upload.user.email])