fix for timeseries metadata when copying or creating a new version
@@ -950,6 +950,28 @@ class TimeSeriesMetaData(CoreMetaData):
self.cv_mediums.all().delete()
self.cv_aggregation_statistics.all().delete()
+ def copy_all_elements_from(self, src_md, exclude_elements=None):
+ super(TimeSeriesMetaData, self).copy_all_elements_from(src_md, exclude_elements)
+ self.value_counts = src_md.value_counts
+ self.save()
+ # create CV terms
+ def copy_cv_terms(cv_class, cv_terms_to_copy):
+ for cv_term in cv_terms_to_copy:
+ cv_class.objects.create(metadata=self, name=cv_term.name,
+ term=cv_term.term,
+ is_dirty=cv_term.is_dirty)
+
+ copy_cv_terms(CVVariableType, src_md.cv_variable_types.all())
+ copy_cv_terms(CVVariableName, src_md.cv_variable_names.all())
+ copy_cv_terms(CVSpeciation, src_md.cv_speciations.all())
+ copy_cv_terms(CVElevationDatum, src_md.cv_elevation_datums.all())
+ copy_cv_terms(CVSiteType, src_md.cv_site_types.all())
+ copy_cv_terms(CVMethodType, src_md.cv_method_types.all())
+ copy_cv_terms(CVUnitsType, src_md.cv_units_types.all())
+ copy_cv_terms(CVStatus, src_md.cv_statuses.all())
+ copy_cv_terms(CVMedium, src_md.cv_mediums.all())
+ copy_cv_terms(CVAggregationStatistic, src_md.cv_aggregation_statistics.all())
+
def update_sqlite_file(self, user):
if not self.is_dirty:
return
