Exemplo n.º 1
0
    def to_dict_for_mongo(self):
        d = self.to_dict()
        data = {
            UUID: self.instance.uuid,
            ID: self.instance.id,
            BAMBOO_DATASET_ID: self.instance.xform.bamboo_dataset,
            self.USERFORM_ID: u'%s_%s' % (
                self.instance.xform.user.username,
                self.instance.xform.id_string),
            ATTACHMENTS: _get_attachments_from_instance(self.instance),
            self.STATUS: self.instance.status,
            GEOLOCATION: [self.lat, self.lng],
            SUBMISSION_TIME: self.instance.date_created.strftime(
                MONGO_STRFTIME),
            TAGS: list(self.instance.tags.names()),
            NOTES: self.get_notes(),
            SUBMITTED_BY: self.instance.user.username
            if self.instance.user else None,
            VERSION: self.instance.version,
            DURATION: self.instance.get_duration()
        }

        if isinstance(self.instance.deleted_at, datetime.datetime):
            data[DELETEDAT] = self.instance.deleted_at.strftime(MONGO_STRFTIME)

        data[EDITED] = (True if self.instance.submission_history.count() > 0
                        else False)

        d.update(data)

        return dict_for_mongo(d)
Exemplo n.º 2
0
    def to_dict_for_mongo(self):
        d = self.to_dict()
        data = {
            UUID: self.instance.uuid,
            ID: self.instance.id,
            BAMBOO_DATASET_ID: self.instance.xform.bamboo_dataset,
            self.USERFORM_ID: u'%s_%s' % (
                self.instance.xform.user.username,
                self.instance.xform.id_string),
            ATTACHMENTS: _get_attachments_from_instance(self.instance),
            self.STATUS: self.instance.status,
            GEOLOCATION: [self.lat, self.lng],
            SUBMISSION_TIME: self.instance.date_created.strftime(
                MONGO_STRFTIME),
            TAGS: list(self.instance.tags.names()),
            NOTES: self.get_notes(),
            SUBMITTED_BY: self.instance.user.username
            if self.instance.user else None,
            VERSION: self.instance.version,
            DURATION: self.instance.get_duration()
        }

        if isinstance(self.instance.deleted_at, datetime.datetime):
            data[DELETEDAT] = self.instance.deleted_at.strftime(MONGO_STRFTIME)

        d.update(data)

        return dict_for_mongo(d)
Exemplo n.º 3
0
    def to_dict_for_mongo(self):
        d = self.to_dict()
        data = {
            UUID:
            self.instance.uuid,
            ID:
            self.instance.id,
            BAMBOO_DATASET_ID:
            self.instance.xform.bamboo_dataset,
            self.USERFORM_ID:
            u'%s_%s' %
            (self.instance.xform.user.username, self.instance.xform.id_string),
            ATTACHMENTS:
            _get_attachments_from_instance(self.instance),
            self.STATUS:
            self.instance.status,
            GEOLOCATION: [self.lat, self.lng],
            SUBMISSION_TIME:
            self.instance.date_created.strftime(MONGO_STRFTIME),
            TAGS:
            list(self.instance.tags.names()),
            NOTES:
            self.get_notes(),
            SUBMITTED_BY:
            self.instance.user.username if self.instance.user else None,
            VERSION:
            self.instance.version,
            DURATION:
            self.instance.get_duration(),
            XFORM_ID:
            self.instance.xform.pk,
            TOTAL_MEDIA:
            self.instance.total_media,
            MEDIA_COUNT:
            self.instance.media_count,
            MEDIA_ALL_RECEIVED:
            self.instance.media_all_received
        }

        if isinstance(self.instance.deleted_at, datetime.datetime):
            data[DELETEDAT] = self.instance.deleted_at.strftime(MONGO_STRFTIME)

        if self.instance.has_a_review:
            status, comment = self.instance.get_review_status_and_comment()
            data[REVIEW_STATUS] = status
            if comment:
                data[REVIEW_COMMENT] = comment

        data[EDITED] = (True if self.instance.submission_history.count() > 0
                        else False)

        d.update(data)

        return dict_for_mongo(d)
Exemplo n.º 4
0
    def to_dict_for_mongo(self):
        d = self.to_dict()
        data = {
            UUID: self.instance.uuid,
            ID: self.instance.id,
            BAMBOO_DATASET_ID: self.instance.xform.bamboo_dataset,
            self.USERFORM_ID: u'%s_%s' % (
                self.instance.xform.user.username,
                self.instance.xform.id_string),
            ATTACHMENTS: _get_attachments_from_instance(self.instance),
            self.STATUS: self.instance.status,
            GEOLOCATION: [self.lat, self.lng],
            SUBMISSION_TIME: self.instance.date_created.strftime(
                MONGO_STRFTIME),
            TAGS: list(self.instance.tags.names()),
            NOTES: self.get_notes(),
            SUBMITTED_BY: self.instance.user.username
            if self.instance.user else None,
            VERSION: self.instance.version,
            DURATION: self.instance.get_duration(),
            XFORM_ID: self.instance.xform.pk,
            TOTAL_MEDIA: self.instance.total_media,
            MEDIA_COUNT: self.instance.media_count,
            MEDIA_ALL_RECEIVED: self.instance.media_all_received
        }

        if isinstance(self.instance.deleted_at, datetime.datetime):
            data[DELETEDAT] = self.instance.deleted_at.strftime(MONGO_STRFTIME)

        if self.instance.has_a_review:
            status, comment = self.instance.get_review_status_and_comment()
            data[REVIEW_STATUS] = status
            if comment:
                data[REVIEW_COMMENT] = comment

        data[EDITED] = (True if self.instance.submission_history.count() > 0
                        else False)

        d.update(data)

        return dict_for_mongo(d)