database/survey_models.py
def archive(self):
        """ Create an archive if there were any changes to the data since the last archive was
        created, or if no archive exists. """

        # get self as dictionary representation, remove fields that don't exist, extract last
        # updated and the survey id.
        new_data = self.as_dict()
        archive_start = new_data.pop("last_updated")
        survey_id = new_data.pop("id")
        new_data.pop("object_id")
        new_data.pop("created_on")
        new_data.pop("study")

        # Get the most recent archive for this Survey, to check whether the Survey has been edited
        try:
            prior_archive = self.most_recent_archive().as_dict()
        except SurveyArchive.DoesNotExist:
            prior_archive = None

        # if there was a prior archive identify if there were any changes, don't create an
        # archive if there were no changes.
        if prior_archive is not None:
            if not any(prior_archive[shared_field_name] != shared_field_value
                       for shared_field_name, shared_field_value in new_data.items()):
                return

        SurveyArchive(
            **new_data,
            survey_id=survey_id,
            archive_start=archive_start,
        ).save()
 Create an archive if there were any changes to the data since the last archive was
        created, or if no archive exists. 
Create an archive if there were any changes to the data since the last archive was
created, or if no archive exists.
Create an archive if there were any changes to the data since the last archive was created or if no archive exists .
def archive(self):
        new_data = self.as_dict()
        archive_start = new_data.pop("last_updated")
        survey_id = new_data.pop("id")
        new_data.pop("object_id")
        new_data.pop("created_on")
        new_data.pop("study")
        try:
            prior_archive = self.most_recent_archive().as_dict()
        except SurveyArchive.DoesNotExist:
            prior_archive = None
        if prior_archive is not None:
            if not any(prior_archive[shared_field_name] != shared_field_value
                       for shared_field_name, shared_field_value in new_data.items()):
                return
        SurveyArchive(
            **new_data,
            survey_id=survey_id,
            archive_start=archive_start,
        ).save()
def archive ( self ) : new_data = self . as_dict ( ) archive_start = new_data . pop ( "last_updated" ) survey_id = new_data . pop ( "id" ) new_data . pop ( "object_id" ) new_data . pop ( "created_on" ) new_data . pop ( "study" ) try : prior_archive = self . most_recent_archive ( ) . as_dict ( ) except SurveyArchive . DoesNotExist : prior_archive = None if prior_archive is not None : if not any ( prior_archive [ shared_field_name ] != shared_field_value for shared_field_name , shared_field_value in new_data . items ( ) ) : return SurveyArchive ( ** new_data , survey_id = survey_id , archive_start = archive_start , ) . save ( )
Create an archive if there were any changes to the data since the last archive was
created, or if no archive exists.
Create an archive if there were any changes to the data since the last archive was created or if no archive exists .
""" Create an archive if there were any changes to the data since the last archive was
        created, or if no archive exists. """ # get self as dictionary representation, remove fields that don't exist, extract last # updated and the survey id. # Get the most recent archive for this Survey, to check whether the Survey has been edited # if there was a prior archive identify if there were any changes, don't create an # archive if there were no changes.
self