/
models.py
664 lines (588 loc) · 25.5 KB
/
models.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
'''
This is the STOQS database model. The database schema derives from this module.
To evolve the schema you may make changes here then run syncdb and the unit tests.
To preserve data in existing databases you will need to make corresponding changes
in those databases, either by hand, or with a tool such as South. Otherwise, you
may simply drop your databases and reload the data.
Mike McCann
MBARI 17 March 2012
'''
from __future__ import unicode_literals
from django.contrib.gis.db import models
from django.contrib.postgres.fields import ArrayField
from django.utils.encoding import python_2_unicode_compatible
try:
import uuid
except ImportError:
from django.utils import uuid
class UUIDField(models.CharField) :
'''
Major classes in the model have been given a uuid field, which may prove helpful as web accessible resource identifiers.
'''
def __init__(self, *args, **kwargs):
kwargs['max_length'] = kwargs.get('max_length', 32 )
models.CharField.__init__(self, *args, **kwargs)
def pre_save(self, model_instance, add):
if add:
value=getattr(model_instance,self.attname)
if not value:
value = unicode(uuid.uuid4()).replace('-','')
setattr(model_instance, self.attname, value)
return value
else:
return super(UUIDField, self).pre_save(model_instance, add)
@python_2_unicode_compatible
class ResourceType(models.Model):
'''
Type of Resource. Example names: nc_global, quick-look-plot.
'''
uuid = UUIDField(editable=False)
name = models.CharField(max_length=128, db_index=True, unique=True)
description = models.CharField(max_length=256, blank=True, null=True)
objects = models.GeoManager()
class Meta(object):
app_label = 'stoqs'
def __str__(self):
return "%s" % (self.name,)
@python_2_unicode_compatible
class Resource(models.Model):
'''
A catchall class for saving any bit of information that may be associated with an Activity, or other STOQS model class.
This is useful for collecting web resources that may be shown in a popup window for an activity. Examples include: NC_GLOBAL data set
attributes or quick-look plots. The ResoureType class may be used to help categorize the display of resources.
'''
uuid = UUIDField(editable=False)
name = models.CharField(max_length=128, null=True)
value = models.TextField(null=True)
uristring = models.CharField(max_length=256, null=True)
resourcetype = models.ForeignKey(ResourceType, blank=True, null=True)
objects = models.GeoManager()
class Meta(object):
verbose_name = 'Resource'
verbose_name_plural = 'Resources'
app_label = 'stoqs'
def __str__(self):
return "(%s=%s)" % (self.name, self.value,)
@python_2_unicode_compatible
class Campaign(models.Model):
'''
A Campaign holds a collection of Activities and can have a name, description and start and end time.
An example name is "CANON October 2010".
'''
uuid = UUIDField(editable=False)
name = models.CharField(max_length=128, db_index=True, unique_for_date='startdate')
startdate = models.DateTimeField(null=True)
enddate = models.DateTimeField(null=True)
description = models.CharField(max_length=4096, blank=True, null=True)
objects = models.GeoManager()
class Meta(object):
app_label = 'stoqs'
verbose_name='Campaign'
verbose_name_plural='Campaigns'
def __str__(self):
return "%s" % (self.name,)
@python_2_unicode_compatible
class CampaignLog(models.Model):
'''
Placeholder for potential integration of various logging systems into STOQS. The
idea is that salient messages would be mined from other sources and loaded into the
stoqs database the same way measurements are loaded.
'''
uuid = UUIDField(editable=False)
campaign = models.ForeignKey(Campaign)
resource = models.ForeignKey(Resource)
timevalue = models.DateTimeField(db_index=True)
message = models.CharField(max_length=2048)
geom = models.PointField(srid=4326, spatial_index=True, dim=2, blank=True, null=True)
depth = models.FloatField(blank=True, null=True)
username = models.CharField(max_length=128, blank=True, null=True)
objects = models.GeoManager()
class Meta(object):
app_label = 'stoqs'
verbose_name='Campaign Log'
verbose_name_plural='Campaign Logs'
def __str__(self):
return "%s at %s" % (self.message, self.timevalue)
@python_2_unicode_compatible
class ActivityType(models.Model):
'''
Type of Activity. Example names: AUV Survey, Mooring Deployment, Ship Cruse, GLider Mission.
'''
uuid = UUIDField(editable=False)
name = models.CharField(max_length=128, db_index=True, unique=True)
objects = models.GeoManager()
class Meta(object):
verbose_name='Activity Type'
verbose_name_plural='Activity Types'
app_label = 'stoqs'
def __str__(self):
return "%s" % (self.name,)
@python_2_unicode_compatible
class PlatformType(models.Model):
'''
Type of platform. Example names: auv, mooring, drifter, ship. The color field is RGB(A) in hex.
'''
uuid = UUIDField(editable=False)
name = models.CharField(max_length=128, db_index=True, unique=True)
color = models.CharField(max_length=8, blank=True, null=True)
objects = models.GeoManager()
class Meta(object):
app_label = 'stoqs'
def __str__(self):
return "%s" % (self.name,)
@python_2_unicode_compatible
class Platform(models.Model):
'''
Platform. Example names (use lower case): dorado, tethys, martin. The color field is RGB(A) in hex.
'''
uuid = UUIDField(editable=False)
name = models.CharField(max_length=128)
platformtype = models.ForeignKey(PlatformType)
color = models.CharField(max_length=8, blank=True, null=True)
objects = models.GeoManager()
class Meta(object):
verbose_name = 'Platform'
verbose_name_plural = 'Platforms'
app_label = 'stoqs'
def __str__(self):
return "%s" % (self.name,)
@python_2_unicode_compatible
class Activity(models.Model):
'''
An Activity is anything that may produce data. Example Activity names include:
Dorado389_2011_117_01_117_01_decim.nc (stride=10),
20110415_20110418/20110418T192351/slate.nc (stride=10), 27710_jhmudas_v1.nc (stride=1).
'''
uuid = UUIDField(editable=False)
campaign = models.ForeignKey(Campaign, blank=True, null=True)
platform = models.ForeignKey(Platform)
name = models.CharField(max_length=256)
comment = models.TextField(max_length=2048)
startdate = models.DateTimeField()
plannedstartdate = models.DateTimeField(null=True)
enddate = models.DateTimeField(null=True)
plannedenddate = models.DateTimeField(null=True)
num_measuredparameters = models.IntegerField(null=True)
loaded_date = models.DateTimeField(null=True)
maptrack = models.LineStringField(null=True)
plannedtrack = models.LineStringField(null=True)
mappoint = models.PointField(srid=4326, spatial_index=True, dim=2, blank=True, null=True)
mindepth = models.FloatField(null=True)
maxdepth = models.FloatField(null=True)
activitytype = models.ForeignKey(ActivityType, blank=True, null=True, default=None)
objects = models.GeoManager()
class Meta(object):
verbose_name='Activity'
verbose_name_plural='Activities'
app_label = 'stoqs'
def __str__(self):
return "%s" % (self.name,)
@python_2_unicode_compatible
class InstantPoint(models.Model):
'''
An instance in time for an Activity. This InstantPoint may have a measurement or sample associated with it.
An InstantPoint may be used to record the start time for an integrative measurement or sample. An example
is a plankton net tow which integrates over space and time. As implemented in the STOQS UI, NetTow data have
exactly one InstantPoint per Activity, with the ActivityType name containing 'NetTow'. The start and end
times and depths can then be retrieved from fields of the Activity record. If the integrative measurement
or sample is from a non-linear longitude/latitude path then that can be stored in the maptrack field.
'''
activity = models.ForeignKey(Activity)
timevalue = models.DateTimeField(db_index=True)
objects = models.GeoManager()
class Meta(object):
app_label = 'stoqs'
def __str__(self):
return "%s" % (self.timevalue,)
@python_2_unicode_compatible
class NominalLocation(models.Model):
'''
A NominalLocation has depth and geom fields for storing a Nominal horizontal position and depth of a
measurement. This is useful for representing CF discrete geometry data of featureType timeSeriesProfile;
for example, a mooring time series with nominal latitude, longitude and nominal depths of subsurface
instruments. It has a many to one relationship with Activity.
'''
activity = models.ForeignKey(Activity)
depth= models.FloatField(db_index=True)
geom = models.PointField(srid=4326, spatial_index=True, dim=2)
objects = models.GeoManager()
class Meta(object):
verbose_name = 'NominalLocation'
verbose_name_plural = 'NominalLocations'
app_label = 'stoqs'
def __str__(self):
return "Nominal Location at %s %s %s" % (self.geom.x, self.geom.y, self.depth)
class SimpleDepthTime(models.Model):
'''
A simplified time series of depth values for an Activity useful for plotting in the UI
'''
activity = models.ForeignKey(Activity)
nominallocation = models.ForeignKey(NominalLocation, null=True)
instantpoint = models.ForeignKey(InstantPoint)
epochmilliseconds = models.FloatField()
depth= models.FloatField()
objects = models.GeoManager()
class Meta(object):
verbose_name='Simple depth time series'
verbose_name_plural='Simple depth time series'
app_label = 'stoqs'
class SimpleBottomDepthTime(models.Model):
'''
A simplified time series of bottom depth values for an Activity useful for plotting in the UI
'''
activity = models.ForeignKey(Activity)
nominallocation = models.ForeignKey(NominalLocation, null=True)
instantpoint = models.ForeignKey(InstantPoint)
epochmilliseconds = models.FloatField()
bottomdepth= models.FloatField()
objects = models.GeoManager()
class Meta(object):
verbose_name='Simple bottom depth time series'
verbose_name_plural='Simple bottom depth time series'
app_label = 'stoqs'
class PlannedDepthTime(models.Model):
'''
A simplified time series of depth values for an Activity useful for plotting in the UI
'''
activity = models.ForeignKey(Activity)
epochmilliseconds = models.FloatField()
depth= models.FloatField()
objects = models.GeoManager()
class Meta(object):
verbose_name='Planned depth time series'
verbose_name_plural='Planned depth time series'
app_label = 'stoqs'
@python_2_unicode_compatible
class Parameter(models.Model):
'''
A Parameter is something that can be measured producing a numeric value or
a array of numeric values. If a parameter is related to an array of values
then the domain field contains the domain values corresponding to the
dataarray values in MeasuredParameter. Example names include temperature,
salinity, fluoresence, plankton counts by size class.
'''
uuid = UUIDField(editable=False)
name = models.CharField(max_length=128, unique=True)
type = models.CharField(max_length=128, blank=True, null=True)
description= models.CharField(max_length=512, blank=True, null=True)
standard_name = models.CharField(max_length=128, null=True)
long_name = models.CharField(max_length=128, blank=True, null=True)
units = models.CharField(max_length=128, blank=True, null=True)
origin = models.CharField(max_length=256, blank=True, null=True)
domain = ArrayField(models.FloatField(), null=True)
objects = models.GeoManager()
class Meta(object):
verbose_name = 'Parameter'
verbose_name_plural = 'Parameters'
app_label = 'stoqs'
def __str__(self):
return "%s" % (self.name,)
@python_2_unicode_compatible
class ParameterGroup(models.Model):
'''
A grouping of parameters with a many-to-many relationship to the Paramter table. Useful for showing checkboxes
in the User Interface for which kinds of Parameters to show, e.g.: Electronic measured, bottle samples, bio-optical,
physical. Mapping to other ontologies to a ParamterGroup (e.g. GCMD) is also possible.
'''
uuid = UUIDField(editable=False)
name = models.CharField(max_length=128, unique=True)
description= models.CharField(max_length=128, blank=True, null=True)
objects = models.GeoManager()
class Meta(object):
verbose_name = 'ParameterGroup'
verbose_name_plural = 'ParameterGroups'
app_label = 'stoqs'
def __str__(self):
return "%s" % (self.name,)
class ParameterGroupParameter(models.Model):
'''
Association table pairing ParamterGroup and Parameter
'''
uuid = UUIDField(editable=False)
parametergroup = models.ForeignKey(ParameterGroup)
parameter = models.ForeignKey(Parameter)
class Meta(object):
verbose_name = 'ParameterGroup Parameter'
verbose_name_plural = 'ParameterGroup Parameter'
app_label = 'stoqs'
unique_together = ['parametergroup', 'parameter']
class CampaignResource(models.Model):
'''
Association class pairing Campaigns and Resources. Must use explicit many-to-many and GeoManager does not support .add().
'''
uuid = UUIDField(editable=False)
campaign = models.ForeignKey(Campaign)
resource = models.ForeignKey(Resource)
class Meta(object):
verbose_name = 'Campaign Resource'
verbose_name_plural = 'Campaign Resource'
app_label = 'stoqs'
unique_together = ['campaign', 'resource']
def __repr__(self):
return "CampaignResource(%s=%s)" % (self.resource.name, self.resource.value)
class ActivityResource(models.Model):
'''
Association class pairing Activities and Resources. Must use explicit many-to-many and GeoManager does not support .add().
'''
uuid = UUIDField(editable=False)
activity = models.ForeignKey(Activity)
resource = models.ForeignKey(Resource)
class Meta(object):
verbose_name = 'Activity Resource'
verbose_name_plural = 'Activity Resource'
app_label = 'stoqs'
unique_together = ['activity', 'resource']
class ParameterResource(models.Model):
'''
Association class pairing Parameters and Resources. Must use explicit many-to-many and GeoManager does not support .add().
'''
uuid = UUIDField(editable=False)
parameter = models.ForeignKey(Parameter)
resource = models.ForeignKey(Resource)
class Meta(object):
verbose_name = 'Parameter Resource'
verbose_name_plural = 'Parameter Resource'
app_label = 'stoqs'
unique_together = ['parameter', 'resource']
@python_2_unicode_compatible
class Measurement(models.Model):
'''
A Measurement may have a @depth value (this is an Oceanographic Query System) and a horizontal location
(represented by the @geom field), it may also have a nominal location with is represented in a related table.
It is associated with an InstantPoint and and a MeasuredParameter (where the measured datavalue is stored).
'''
instantpoint = models.ForeignKey(InstantPoint)
nominallocation = models.ForeignKey(NominalLocation, null=True)
depth= models.FloatField(db_index=True)
bottomdepth= models.FloatField(db_index=True, null=True)
geom = models.PointField(srid=4326, spatial_index=True, dim=2)
objects = models.GeoManager()
class Meta(object):
verbose_name = 'Measurement'
verbose_name_plural = 'Measurements'
app_label = 'stoqs'
def __str__(self):
return "Measurement at %s" % (self.geom,)
@python_2_unicode_compatible
class SampleType(models.Model):
'''
Type of Sample. Example names: Gulper, Niskin, Bucket
'''
uuid = UUIDField(editable=False)
name = models.CharField(max_length=128, db_index=True, unique=True)
objects = models.GeoManager()
class Meta(object):
verbose_name='Sample Type'
verbose_name_plural='Sample Types'
app_label = 'stoqs'
def __str__(self):
return "%s" % (self.name,)
@python_2_unicode_compatible
class SamplePurpose(models.Model):
'''
Purpose of Sample. Example names: random, control, peak
'''
uuid = UUIDField(editable=False)
name = models.CharField(max_length=128, unique=True)
description = models.CharField(max_length=1024)
objects = models.GeoManager()
class Meta(object):
verbose_name='Sample Purpose'
verbose_name_plural='Sample Purposes'
app_label = 'stoqs'
def __str__(self):
return "%s" % (self.name,)
@python_2_unicode_compatible
class AnalysisMethod(models.Model):
'''
The method used for producing a ParamaterSample.datavlue from a Sample
'''
uuid = UUIDField(editable=False)
name = models.CharField(max_length=256, db_index=True, unique=True)
uristring = models.CharField(max_length=256, null=True)
objects = models.GeoManager()
class Meta(object):
verbose_name='Analysis Method'
verbose_name_plural='Analysis Methods'
app_label = 'stoqs'
def __str__(self):
return "%s" % (self.name,)
@python_2_unicode_compatible
class Sample(models.Model):
'''
A Sample may have a depth value (this is an Oceanographic Query System) and a location (represented by the geom field),
be associated with an InstantPoint and and a SampledParameter (where the measured datavalue is stored). A Sample
differs from a Measurement in that it represents an actual physical sample from which analyses may be made producing
digital values which may be stored in the SampleParameter table. Some of the fields have units. The canonical unit
values are:
volume: ml
filterdiameter: mm
filterporesize: microns
'''
uuid = UUIDField(editable=False)
instantpoint = models.ForeignKey(InstantPoint)
depth= models.DecimalField(max_digits=100, db_index=True, decimal_places=30)
geom = models.PointField(srid=4326, spatial_index=True, dim=2)
name = models.CharField(max_length=128, db_index=True)
sampletype = models.ForeignKey(SampleType, blank=True, null=True, default=None)
samplepurpose = models.ForeignKey(SamplePurpose, blank=True, null=True, default=None)
volume = models.FloatField(blank=True, null=True)
filterdiameter = models.FloatField(blank=True, null=True)
filterporesize = models.FloatField(blank=True, null=True)
laboratory = models.CharField(max_length=128, blank=True, null=True)
researcher = models.CharField(max_length=128, blank=True, null=True)
objects = models.GeoManager()
class Meta(object):
verbose_name = 'Sample'
verbose_name_plural = 'Samples'
app_label = 'stoqs'
def __str__(self):
return "%s" % (self.name,)
class SampleRelationship(models.Model):
'''
Association class pairing Samples and Samples for many-to-many parent/child relationships.
'''
uuid = UUIDField(editable=False)
parent = models.ForeignKey(Sample, related_name='child')
child = models.ForeignKey(Sample, related_name='parent')
class Meta(object):
verbose_name = 'Sample Relationship'
verbose_name_plural = 'Sample Relationships'
app_label = 'stoqs'
unique_together = ['parent', 'child']
class SampleResource(models.Model):
'''
Association class pairing Samples and Resources. Must use explicit many-to-many and GeoManager does not support .add().
'''
uuid = UUIDField(editable=False)
sample = models.ForeignKey(Sample)
resource = models.ForeignKey(Resource)
class Meta(object):
verbose_name = 'Sample Resource'
verbose_name_plural = 'Sample Resource'
app_label = 'stoqs'
unique_together = ['sample', 'resource']
class PlatformResource(models.Model):
'''
Association class pairing Platforms and Resources. Must use explicit many-to-many and GeoManager does not support .add().
'''
uuid = UUIDField(editable=False)
platform = models.ForeignKey(Platform)
resource = models.ForeignKey(Resource)
class Meta(object):
verbose_name = 'Platform Resource'
verbose_name_plural = 'Platform Resource'
app_label = 'stoqs'
unique_together = ['platform', 'resource']
class ResourceResource(models.Model):
'''
Association class pairing Resources and Resources for many-to-many from/to relationships.
'''
uuid = UUIDField(editable=False)
fromresource = models.ForeignKey(Resource, related_name='toresource')
toresource = models.ForeignKey(Resource, related_name='fromresource')
class Meta(object):
verbose_name = 'Resource Resource'
verbose_name_plural = 'Resource Resource'
app_label = 'stoqs'
unique_together = ['fromresource', 'toresource']
class ActivityParameter(models.Model):
'''
Association class pairing Parameters that have been loaded for an Activity
'''
uuid = UUIDField(editable=False)
activity = models.ForeignKey(Activity)
parameter = models.ForeignKey(Parameter)
# Parameter statistics for the Activity
number = models.IntegerField(null=True)
min = models.FloatField(null=True)
max = models.FloatField(null=True)
mean = models.FloatField(null=True)
median = models.FloatField(null=True)
mode = models.FloatField(null=True)
# Useful for visualiztion, ignoring min & max outliers - 2.5% & 97.5% percentiles of the parameter
p025 = models.FloatField(null=True)
p975 = models.FloatField(null=True)
# Useful for visualiztion, ignoring fewer min & max outliers - 1% & 99% percentiles of the parameter
p010 = models.FloatField(null=True)
p990 = models.FloatField(null=True)
class Meta(object):
verbose_name = 'Activity Parameter'
verbose_name_plural = 'Activity Parameter'
app_label = 'stoqs'
unique_together = ['activity', 'parameter']
class ActivityParameterHistogram(models.Model):
'''
Association class pairing Parameters that have been loaded for an Activity
'''
uuid = UUIDField(editable=False)
activityparameter = models.ForeignKey(ActivityParameter)
binlo = models.FloatField()
binhi = models.FloatField()
bincount = models.IntegerField()
class MeasuredParameter(models.Model):
'''
Association class pairing Measurements with Parameters. This is where the measured values are stored -- in the datavalue field.
'''
measurement = models.ForeignKey(Measurement)
parameter = models.ForeignKey(Parameter)
datavalue = models.FloatField(db_index=True, null=True)
dataarray = ArrayField(models.FloatField(), null=True)
objects = models.GeoManager()
class Meta(object):
verbose_name = 'Measured Parameter'
verbose_name_plural = 'Measured Parameter'
app_label = 'stoqs'
unique_together = ['measurement','parameter']
class SampledParameter(models.Model):
'''
Association class pairing Samples with Parameters. This is where any digital sampled data values are stored -- in the datavalue field.
'''
uuid = UUIDField(editable=False)
sample = models.ForeignKey(Sample)
parameter = models.ForeignKey(Parameter)
datavalue = models.DecimalField(max_digits=100, db_index=True, decimal_places=30)
analysismethod = models.ForeignKey(AnalysisMethod, null=True)
objects = models.GeoManager()
class Meta(object):
verbose_name = 'Sampled Parameter'
verbose_name_plural = 'Sampled Parameter'
app_label = 'stoqs'
unique_together = ['sample','parameter']
class MeasuredParameterResource(models.Model):
'''
Association class pairing MeasuredParameters and Resources. Must use explicit many-to-many and GeoManager does not support .add().
Class contains activity field for ease of association in the filter set of the UI.
'''
uuid = UUIDField(editable=False)
measuredparameter = models.ForeignKey(MeasuredParameter)
resource = models.ForeignKey(Resource)
activity = models.ForeignKey(Activity)
class Meta(object):
verbose_name = 'MeasuredParameter Resource'
verbose_name_plural = 'MeasuredParameter Resource'
app_label = 'stoqs'
unique_together = ['measuredparameter', 'resource']
class SampledParameterResource(models.Model):
'''
Association class pairing SampledParameters and Resources. Must use explicit many-to-many and GeoManager does not support .add().
Class contains activity field for ease of association in the filter set of the UI.
'''
uuid = UUIDField(editable=False)
sampledparameter = models.ForeignKey(SampledParameter)
resource = models.ForeignKey(Resource)
activity = models.ForeignKey(Activity)
class Meta(object):
verbose_name = 'SampledParameter Resource'
verbose_name_plural = 'SampledParameter Resource'
app_label = 'stoqs'
unique_together = ['sampledparameter', 'resource']
class PermaLink(models.Model):
'''
A simple model for storing permalinks created by users.
'''
uuid=UUIDField(editable=False, primary_key=True)
parameters=models.TextField(null=False, blank=False)
create_date=models.DateTimeField(auto_now_add=True)
usage_count=models.IntegerField(default=0)
last_usage=models.DateTimeField(auto_now=True)