Skip to content

Commit

Permalink
Merge pull request #286 from ODM2/release/0.9.0
Browse files Browse the repository at this point in the history
Release/0.9.0
  • Loading branch information
jcaraballo17 authored Aug 15, 2018
2 parents 2e63141 + f7dc6e8 commit c2b1f96
Show file tree
Hide file tree
Showing 51 changed files with 1,248 additions and 1,091 deletions.
4 changes: 2 additions & 2 deletions src/WebSDL/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
# Application definition

INSTALLED_APPS = [
'debug_toolbar',
# 'debug_toolbar',
'rest_framework',
'accounts.apps.AccountsConfig',
'dataloader.apps.DataloaderConfig',
Expand Down Expand Up @@ -72,7 +72,7 @@
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'hydroshare_util.middleware.AuthMiddleware',
'debug_toolbar.middleware.DebugToolbarMiddleware',
# 'debug_toolbar.middleware.DebugToolbarMiddleware',
]

REST_FRAMEWORK = {
Expand Down
10 changes: 5 additions & 5 deletions src/WebSDL/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@
url(BASE_URL, include('dataloaderservices.urls'))
]

if settings.DEBUG:
import debug_toolbar
urlpatterns = [
url(r'^__debug__/', include(debug_toolbar.urls)),
] + urlpatterns
# if settings.DEBUG:
# import debug_toolbar
# urlpatterns = [
# url(r'^__debug__/', include(debug_toolbar.urls)),
# ] + urlpatterns
6 changes: 3 additions & 3 deletions src/dataloader/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,23 +198,23 @@ class Meta:


class YIntendedComponent(models.Model):
intended_y_spacing = models.FloatField(db_column='intendedyspacing')
intended_y_spacing = models.FloatField(db_column='intendedyspacing', blank=True, null=True)
intended_y_spacing_unit = models.ForeignKey('Unit', related_name='+', db_column='intendedyspacingunitsid', blank=True, null=True)

class Meta:
abstract = True


class ZIntendedComponent(models.Model):
intended_z_spacing = models.FloatField(db_column='intendedzspacing')
intended_z_spacing = models.FloatField(db_column='intendedzspacing', blank=True, null=True)
intended_z_spacing_unit = models.ForeignKey('Unit', related_name='+', db_column='intendedzspacingunitsid', blank=True, null=True)

class Meta:
abstract = True


class TimeIntendedComponent(models.Model):
intended_time_spacing = models.FloatField(db_column='intendedtimespacing')
intended_time_spacing = models.FloatField(db_column='intendedtimespacing', blank=True, null=True)
intended_time_spacing_unit = models.ForeignKey('Unit', related_name='+', db_column='intendedtimespacingunitsid', blank=True, null=True)

class Meta:
Expand Down
112 changes: 9 additions & 103 deletions src/dataloaderinterface/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,10 @@
from django.forms import NumberInput
from django.forms.widgets import HiddenInput

from dataloader.models import SamplingFeature, Organization, Affiliation, Result, Site, EquipmentModel, Medium, \
OrganizationType, ActionBy, SiteType, Variable, Unit
from dataloader.models import Organization, Affiliation, EquipmentModel, Medium, OrganizationType, SiteType, Variable, Unit
from django import forms
from django.forms.formsets import formset_factory
import re

from dataloaderinterface.models import SiteRegistration, SiteAlert, SiteSensor, SensorOutput
from hydroshare.models import HydroShareResource

allowed_site_types = [
'Borehole', 'Ditch', 'Atmosphere', 'Estuary', 'House', 'Land', 'Pavement', 'Stream', 'Spring',
Expand Down Expand Up @@ -45,8 +41,6 @@ def label_from_instance(self, obj):
return SampledMediumField.get_custom_label(obj.name)


# ODM2

class SiteRegistrationForm(forms.ModelForm):
affiliation_id = forms.ModelChoiceField(
queryset=Affiliation.objects.for_display(),
Expand All @@ -70,12 +64,13 @@ class Meta:
model = SiteRegistration
fields = [
'affiliation_id', 'sampling_feature_code', 'sampling_feature_name', 'latitude', 'longitude', 'elevation_m',
'elevation_datum', 'site_type', 'stream_name', 'major_watershed', 'sub_basin', 'closest_town'
'elevation_datum', 'site_type', 'stream_name', 'major_watershed', 'sub_basin', 'closest_town', 'site_notes'
]
labels = {
'sampling_feature_code': 'Site Code',
'sampling_feature_name': 'Site Name',
'elevation_m': 'Elevation',
'site_notes': 'Notes'
}
help_texts = {
'sampling_feature_code': 'Enter a brief and unique text string to identify your site (e.g., "Del_Phil")',
Expand All @@ -87,15 +82,6 @@ class Meta:
}


class ActionByForm(forms.ModelForm):
use_required_attribute = False
affiliation = forms.ModelChoiceField(queryset=Affiliation.objects.all(), required=False, help_text='Select the user that deployed or manages the site', label='Deployed By')

class Meta:
model = ActionBy
fields = ['affiliation']


class OrganizationForm(forms.ModelForm):
use_required_attribute = False
organization_type = forms.ModelChoiceField(queryset=OrganizationType.objects.all().exclude(name__in=['Vendor', 'Manufacturer']), required=False, help_text='Choose the type of organization')
Expand All @@ -115,57 +101,6 @@ class Meta:
]


class SamplingFeatureForm(forms.ModelForm):
use_required_attribute = False
sampling_feature_name = forms.CharField(required=True, label='Site Name', help_text='Enter a brief but descriptive name for your site (e.g., "Delaware River near Phillipsburg")')

class Meta:
model = SamplingFeature
help_texts = {
'sampling_feature_code': 'Enter a brief and unique text string to identify your site (e.g., "Del_Phil")',
'elevation_m': 'Enter the elevation of your site in meters',
'elevation_datum': 'Choose the elevation datum for your site\'s elevation. If you don\'t know it, choose "MSL"'
}
fields = [
'sampling_feature_code',
'sampling_feature_name',
'elevation_m',
'elevation_datum',
]
labels = {
'sampling_feature_code': 'Site Code',
'elevation_m': 'Elevation',
}


class SiteForm(forms.ModelForm):
allowed_site_types = [
'Borehole', 'Ditch', 'Atmosphere', 'Estuary', 'House', 'Land', 'Pavement', 'Stream', 'Spring',
'Lake, Reservoir, Impoundment', 'Laboratory or sample-preparation area', 'Observation well', 'Soil hole',
'Storm sewer', 'Stream gage', 'Tidal stream', 'Water quality station', 'Weather station', 'Wetland', 'Other'
]

site_type = forms.ModelChoiceField(
queryset=SiteType.objects.filter(name__in=allowed_site_types),
help_text='Select the type of site you are deploying (e.g., "Stream")',
widget=SiteTypeSelect
)
use_required_attribute = False

class Meta:
model = Site
help_texts = {
'site_type': '',
'latitude': 'Enter the latitude of your site in decimal degrees (e.g., 40.6893)',
'longitude': 'Enter the longitude of your site in decimal degrees (e.g., -75.2033)',
}
fields = [
'site_type',
'latitude',
'longitude',
]


class SiteSensorForm(forms.ModelForm):
allowed_sampled_medium = ['Air', 'Soil', 'Sediment', 'Liquid aqueous', 'Equipment', 'Not applicable', 'Other']

Expand Down Expand Up @@ -204,46 +139,14 @@ def clean_output_variable(self):
class Meta:
model = SiteSensor
fields = [
'output_variable', 'sensor_manufacturer', 'sensor_model', 'variable', 'unit', 'sampled_medium'
]


class ResultForm(forms.ModelForm):
def __init__(self, *args, **kwargs):
super(ResultForm, self).__init__(*args, **kwargs)
self.empty_permitted = False

equipment_model = forms.ModelChoiceField(queryset=EquipmentModel.objects.for_display(), help_text='Choose the model of your sensor')
sampled_medium = SampledMediumField(queryset=Medium.objects.filter(pk__in=[
'Air', 'Soil', 'Sediment', 'Liquid aqueous',
'Equipment', 'Not applicable', 'Other'
]), help_text='Choose the sampled medium')

class Meta:
model = Result
help_texts = {
'equipment_model': 'Choose the model of your sensor',
'variable': 'Choose the measured variable',
'unit': 'Choose the measured units',
'sampled_medium': 'Choose the sampled medium'
}
fields = [
'result_id',
'equipment_model',
'variable',
'unit',
'sampled_medium',
'output_variable', 'sensor_manufacturer', 'sensor_model', 'variable', 'unit', 'sampled_medium', 'height', 'sensor_notes'
]
labels = {
'equipment_model': 'Sensor Model',
'variable': 'Measured Variable',
'sampled_medium': 'Sampled Medium',
'height': 'Height above(+) or below(-) surface, in meters',
'sensor_notes': 'Notes'
}


ResultFormSet = formset_factory(ResultForm, extra=0, can_order=False, min_num=1, can_delete=True)


class SiteAlertForm(forms.ModelForm):
notify = forms.BooleanField(required=False, initial=False, label='Notify me if site stops receiving sensor data.')
hours_threshold = forms.DurationField(required=False, label='Notify after', widget=NumberInput(attrs={'min': 1}))
Expand All @@ -256,3 +159,6 @@ class Meta:
'notify': 'Receive email notifications for this site',
}


class SensorDataForm(forms.Form):
data_file = forms.FileField()

This file was deleted.

This file was deleted.

Loading

0 comments on commit c2b1f96

Please sign in to comment.