Example #1
0
 def data_fields(self, only_data=True):
     fields = self._meta.get_all_field_names()
     if only_data:
         # ie. the ones starting by the age prefix
         fields = [x for x in fields if x[0:3] \
                  in ([('%s_' % k)[0:3] for k in POPULATIONS.keys()])]
     return fields
Example #2
0
    def dirty_fields(self, only_data=True):
        """ List of fields which have changed since previous revision """
        # no dirty fields if validated
        if self.nut_report._status >= self.nut_report.STATUS_VALIDATED:
            return []

        versions = reversion.get_for_object(self)

        # no dirty fields if only one rev.
        if len(versions) <= 1:
            return []

        last, previous = versions[0:2]

        diff = []

        fields = self._meta.get_all_field_names()
        if only_data:
            # only data fields
            # ie. the ones starting by the age prefix
            fields = [x for x in fields if x[0:3] \
                     in ([('%s_' % k)[0:3] for k in POPULATIONS.keys()])]
        for field in fields:
            if last.field_dict[field] != previous.field_dict[field]:
                diff.append(field)
        return diff