def update_aquifer(request): id_input = TextInput(display_text='Aquifer ID', name='id-input', placeholder='', attributes={ 'id': 'id-input', 'readonly': 'true' }) aquifer_text_input = TextInput( display_text='Aquifer Name', name='aquifer-text-input', placeholder='e.g.: Abod', attributes={'id': 'aquifer-text-input'}, ) aquifer_id_input = TextInput( display_text='Aquifer ID', name='aquifer-id-input', placeholder='e.g.: 23', attributes={'id': 'aquifer-id-input'}, ) geoserver_text_input = geoserver_text_gizmo() context = { 'id_input': id_input, 'geoserver_text_input': geoserver_text_input, 'aquifer_text_input': aquifer_text_input, 'aquifer_id_input': aquifer_id_input } return render(request, 'gwdm/update_aquifer.html', context)
def home(request): """ Controller for the app home page. """ drawing_options = MVDraw( controls=['Modify', 'Delete', 'Move', 'Point', 'LineString', 'Polygon', 'Box'], initial='Point', output_format='WKT' ) view_options = MVView( projection='EPSG:4326', center=[-100, 40], zoom=3.5, maxZoom=18, minZoom=2 ) landchange_map = MapView( height='100%', width='100%', layers=[], basemap='OpenStreetMap', view=view_options, draw=drawing_options ) save_button = Button( display_text='', name='save_button', icon='glyphicon glyphicon-floppy-disk', style='success', attributes={ 'data-toggle':'tooltip', 'data-placement':'top', 'title':'Save' } ) latitude = TextInput( display_text='Latitude', name='Latitude', placeholder='Enter Coordinates' ) longitude = TextInput( display_text='Longitude', name='Longitude', placeholder='Enter Coordinates' ) context = { 'save_button': save_button, 'landchange_map': landchange_map, 'latitude': latitude, 'longitude': longitude, } return render(request, 'landchange_learner/home.html', context)
def add_endpoint(request): name_input = TextInput(display_text='Layer Name', name='name-input', placeholder='', attributes={'id': 'name-input'}) endpoint_input = TextInput( display_text='REST Endpoint', name='endpoint-input', placeholder='e.g.: REST Endpoint', attributes={'id': 'endpoint-input'}, ) endpoint_type = SelectInput(display_text='Endpoint Type', name='endpoint-type', attributes={'id': 'endpoint-type'}, multiple=False, options=[('wfs', 'wfs'), ('wms', 'wms')]) wms_layers_input = TextInput(display_text='WMS Layer Name', name='wms-layers-input', placeholder='e.g.: cite:qpf24hr_day1_latest', attributes={'id': 'wms-layers-input'}, classes='wms_layer hidden') fill_opacity = TextInput( display_text='Fill Opacity', name='fill-opacity', placeholder='e.g.: 0.7. Goes from 0 to 1.', attributes={'id': 'fill-opacity'}, ) stroke_width = TextInput( display_text='Stroke Width', name='stroke-width', placeholder='e.g.: 2. The thickness of the fill stroke.', attributes={'id': 'stroke-width'}, ) add_button = Button(display_text='Add Endpoint', icon='glyphicon glyphicon-plus', style='primary', name='submit-add-endpoint', attributes={'id': 'submit-add-endpoint'}, classes="add") context = { "name_input": name_input, "endpoint_input": endpoint_input, "endpoint_type": endpoint_type, "wms_layers_input": wms_layers_input, "fill_opacity": fill_opacity, "stroke_width": stroke_width, "add_button": add_button } return render(request, 'glo_dda/add_endpoint.html', context)
def add_data_store(request): """ Controller for the app add_data_store page. """ # initialize session session_maker = app.get_persistent_store_database('main_db', as_sessionmaker=True) session = session_maker() data_store_name_input = TextInput(display_text='Data Store Server Name', name='data-store-name-input', placeholder='e.g.: My CKAN Server', icon_append='glyphicon glyphicon-tag') # Query DB for data store types data_store_types = session.query(DataStoreType).filter( DataStoreType.id > 1).all() data_store_type_list = [] for data_store_type in data_store_types: data_store_type_list.append( (data_store_type.human_readable_name, data_store_type.id)) session.close() data_store_type_select_input = \ SelectInput(display_text='Data Store Type', name='data-store-type-select', options=data_store_type_list, initial=data_store_type_list[0][0]) data_store_endpoint_input = TextInput( display_text='Data Store API Endpoint', name='data-store-endpoint-input', placeholder='e.g.: http://ciwweb.chpc.utah.edu/api/3/action', icon_append='glyphicon glyphicon-cloud-download') data_store_owner_org_input = TextInput( display_text='Data Store Owner Organization', name='data-store-owner_org-input', placeholder='e.g.: byu', icon_append='glyphicon glyphicon-home') add_button = Button(display_text='Add Data Store', icon='glyphicon glyphicon-plus', style='success', name='submit-add-data-store', attributes={'id': 'submit-add-data-store'}) context = { 'data_store_name_input': data_store_name_input, 'data_store_type_select_input': data_store_type_select_input, 'data_store_endpoint_input': data_store_endpoint_input, 'data_store_owner_org_input': data_store_owner_org_input, 'add_button': add_button, } return render(request, 'streamflow_prediction_tool/add_data_store.html', context)
def graph(request): latitude_error = '' longitude_error = '' lat_input = TextInput(display_text='Latitude', name='latitude', error=latitude_error) long_input = TextInput(display_text='Longtiude', name='longitude', error=longitude_error) submit_button = Button( display_text='Submit', name='submit-button', icon='glyphicon glyphicon-ok', style='success', attributes={'form': 'view-graphs-form'}, submit=True, ) cancel_buton = Button(display_text='Cancel', name='cancel-button', icon='glyphicon glyphicon-remove', href=reverse('precip_by_location:home')) context = { 'lat_input': lat_input, 'long_input': long_input, 'submit_button': submit_button, 'cancel_button': cancel_buton } if request.POST and 'submit-button' in request.POST: import time start_time = time.time() has_errors = False latitude = request.POST.get('latitude', None) longitude = request.POST.get('longitude', None) if not latitude: has_errors = True latitude_error = 'Latitude is required' if not longitude: has_errors = True longitude_error = 'Longtiude is required' if not has_errors: #create the graphs here and return the render and stuff latitude, longitude = getClosestLatLong(latitude, longitude) temperature_plot, precipitation_plot = create_graph( getLocID(latitude, longitude)) context['temperature_plot'] = temperature_plot context['precipitation_plot'] = precipitation_plot print("--- %s seconds to generate---" % (time.time() - start_time)) return render(request, 'precip_by_location/graph.html', context) messages.error(request, "Please fix errors.") return render(request, 'precip_by_location/graph.html', context)
def home(request): """ Controller for map page. """ # Define Gizmo Options select_model = SelectInput( display_text='Model Type:', name='select_model', multiple=False, options=(('SPT (Standard Penetration Test)', 'spt'), ('CPT (Cone Penetration Test)', 'cpt')), initial=('SPT (Standard Penetration Test)', 'spt'), ) select_year = SelectInput(display_text='Model/Data Year:', name='select_year', multiple=False, options=[(2014, 2014), (2008, 2008)], initial=[(2014, 2014)]) select_return_period = SelectInput(display_text='Return Period (years):', name='select_return_period', multiple=False, options=[('475', 475), ('1033', 1033), ('2475', 2475)], initial=['475', 475]) select_state = SelectInput(display_text='State:', name='select_state', multiple=False, options=[ ('Alaska', 'Alaska'), ('Arizona', 'Arizona'), ('California', 'California'), ('Connecticut', 'Connecticut'), ('Idaho', 'Idaho'), ('Montana', 'Montana'), ('Nevada', 'Nevada'), ('Oregon', 'Oregon'), ('South Carolina', 'South_Carolina'), ('Utah', 'Utah'), ('Washington', 'Washington'), ], initial=['Utah', 'Utah']) text_input_lat = TextInput(display_text='Latitude', name='lat-input') text_input_lon = TextInput(display_text='Longitude', name='lon-input') context = { 'select_model': select_model, 'select_year': select_year, 'select_return_period': select_return_period, 'select_state': select_state, 'text_input_lat': text_input_lat, 'text_input_lon': text_input_lon, } return render(request, 'lfhazard/home.html', context)
def add_polygon(request): polygon_input = TextInput( display_text='Polygon input', name='polygon-input', placeholder='e.g.: Polygon', attributes={ 'id': 'polygon-input', 'readonly': 'true' }, ) select_layer_input = SelectInput(display_text='Select Layer', name='select-layer', multiple=False, original=True, options=[('S_FIRM_PAN', 'S_FIRM_PAN'), ('S_FLD_HAZ_AR', 'S_FLD_HAZ_AR') ], initial=['S_FLD_HAZ_AR']) year_input = TextInput(display_text='Year', name='year-input', placeholder='e.g.: 2019', attributes={'id': 'year-input'}) source_input = TextInput(display_text='Source', name='source-input', placeholder='e.g.: FIS', attributes={'id': 'source-input'}) add_button = Button( display_text='Add Polygon', icon='glyphicon glyphicon-plus', style='success', name='submit-add-point', attributes={'id': 'submit-add-polygon'}, ) context = { 'polygon_input': polygon_input, 'select_layer_input': select_layer_input, 'year_input': year_input, 'source_input': source_input, 'add_button': add_button } return render(request, 'glo_vli/add_polygon.html', context)
def add_dam(request): """ Controller for the Add Dam page. """ # Define form gizmos name_input = TextInput(display_text='Name', name='name') owner_input = SelectInput(display_text='Owner', name='owner', multiple=False, options=[('Reclamation', 'Reclamation'), ('Army Corp', 'Army Corp'), ('Other', 'Other')], initial=['Reclamation']) river_input = TextInput(display_text='River', name='river', placeholder='e.g.: Mississippi River') date_built = DatePicker(name='date-built', display_text='Date Built', autoclose=True, format='MM d, yyyy', start_view='decade', today_button=True, initial='February 15, 2017') add_button = Button(display_text='Add', name='add-button', icon='glyphicon glyphicon-plus', style='success', attributes={'form': 'add-dam-form'}, submit=True) cancel_button = Button(display_text='Cancel', name='cancel-button', href=reverse('dam_inventory:home')) context = { 'name_input': name_input, 'owner_input': owner_input, 'river_input': river_input, 'date_built_input': date_built, 'add_button': add_button, 'cancel_button': cancel_button, } return render(request, 'dam_inventory/add_dam.html', context)
def map(request): slider1 = RangeSlider(display_text='Time of Day', name='slider1', min='6AM', max='9PM', initial='6AM', step=1) text_input = TextInput(display_text='Location Search', name='input', placeholder='e.g.: BYU Clyde Building', prepend='') map_button = Button(display_text='Calculate', name='map-button', icon='glyphicon glyphicon-globe', style='info', attributes={ 'data-toggle': 'tooltip', 'data-placement': 'top', 'onclick': 'app.bufferPoint()', 'title': 'Calculate' }) context = { 'slider1': slider1, 'map_button': map_button, 'text_input': text_input } return render(request, 'geoids_traveltimepolygons/map.html', context)
def add_measurements(request): region_select = get_region_select() variable_select = get_variable_select() aquifer_select = get_aquifer_select(None) attributes_button = Button( display_text='Get Attributes', icon='glyphicon glyphicon-plus', style='primary', name='submit-get-attributes', attributes={'id': 'submit-get-attributes'}, ) format_text_input = TextInput( display_text='Date Format', name='format-text-input', placeholder='e.g.: mm-dd-yyyy', attributes={'id': 'format-text-input'}, ) context = { 'region_select': region_select, 'aquifer_select': aquifer_select, 'variable_select': variable_select, 'attributes_button': attributes_button, 'format_text_input': format_text_input } return render(request, 'gwdm/add_measurements.html', context)
def add_aquifer(request): """ Controller for add aquifer """ region_select = get_region_select() aquifer_text_input = TextInput( display_text='Aquifer Name', name='aquifer-text-input', placeholder='e.g.: Niger', attributes={'id': 'aquifer-text-input'}, ) add_button = Button(display_text='Add Aquifer', icon='glyphicon glyphicon-plus', style='primary', name='submit-add-aquifer', attributes={'id': 'submit-add-aquifer'}, classes="add hidden") attributes_button = Button( display_text='Get Attributes', icon='glyphicon glyphicon-plus', style='primary', name='submit-get-attributes', attributes={'id': 'submit-get-attributes'}, ) context = { 'aquifer_text_input': aquifer_text_input, 'region_select': region_select, 'attributes_button': attributes_button, 'add_button': add_button } return render(request, 'gwdm/add_aquifer.html', context)
def add_region(request): """ Controller for add region """ region_text_input = TextInput( display_text='Region Name', name='region-text-input', placeholder='e.g.: West Africa', attributes={'id': 'region-text-input'}, ) add_button = Button(display_text='Add Region', icon='glyphicon glyphicon-plus', style='primary', name='submit-add-region', attributes={'id': 'submit-add-region'}, classes="add") context = { 'region_text_input': region_text_input, 'add_button': add_button } return render(request, 'gwdm/add_region.html', context)
def home(request): """ Controller for the app home page. """ btnCalc = Button(display_text="Calculate Storage Capacity", name="btnCalc", attributes="onclick=run_rc()", submit=False) btnDrawPolygon = Button(display_text="Draw Reservoir Maximum Boundary", name="btnDraw", attributes="onclick=draw_polygon()", submit=False) btnClickPoint = Button(display_text="Select pour point", name="btnClickPoint", attributes="onclick=addClickPoint()", submit=False) waterLevel = TextInput(display_text='Water Level (m):', name="waterLevel", initial="50", disabled=False, attributes="") context = { 'btnCalc': btnCalc, 'btnDrawPolygon': btnDrawPolygon, 'btnClickPoint':btnClickPoint, 'waterLevel':waterLevel } return render(request, 'reservoir_calculation/home.html', context)
def gizmos(request): """ Controller for the app home page. """ date_picker = DatePicker(name='date', display_text='Date', autoclose=True, format='MM d, yyyy', start_date='2/15/2014', start_view='decade', today_button=True, initial='February 15, 2017') text_input = TextInput(display_text='Text', name='inputAmount', placeholder='e.g.: 10.00', prepend='$') slider1 = RangeSlider(display_text='Slider 1', name='slider1', min=0, max=100, initial=50, step=1) context = { 'date_picker': date_picker, 'text_input': text_input, 'slider1': slider1, } return render(request, 'map_app_lippold/gizmos.html', context)
def add_new_layer(request): """ Controller for the upload layer page. """ add_new_select = SelectInput(display_text='Add New Layer', name='add-new-select', attributes={'id': 'add-new-select'}, multiple=False, options=[('True', 'True'), ('False', 'False')]) layer_text_input = TextInput( display_text='Layer Name', name='layer-text-input', placeholder='e.g.: Hospitals', attributes={'id': 'layer-text-input'}, ) layer_options = get_layer_options() layer_list = [(layer, layer) for key, val in layer_options.items() for layer in val] layer_select_input = SelectInput( display_text='Select Layer', name='layer-select-input', multiple=False, original=True, options=layer_list, ) attributes_button = Button( display_text='Get Attributes', icon='glyphicon glyphicon-plus', style='primary', name='submit-get-attributes', attributes={'id': 'submit-get-attributes'}, ) add_button = Button(display_text='Add Layer', icon='glyphicon glyphicon-plus', style='primary', name='submit-add-layer', attributes={'id': 'submit-add-layer'}, classes="hidden add") context = { 'add_new_select': add_new_select, 'layer_text_input': layer_text_input, 'layer_select_input': layer_select_input, 'attributes_button': attributes_button, 'add_button': add_button } return render(request, 'glo_dda/add_new_layer.html', context)
def home(request): """ Controller for the app home page. """ damHeight = TextInput(display_text='Dam Height (m):', name="damHeight", initial="100", disabled=False, attributes="") interval = TextInput(display_text='Interval :', name="interval", initial="10", disabled=False, attributes="") btnDelin = Button(display_text="Delinate Watershed", name="btnDelin", attributes="onclick=run_wd_calc()", submit=False) btnCalc = Button(display_text="Calculate Storage Capacity Curve", name="btnCalc", attributes="onclick=run_sc_calc()", submit=False) context = { 'damHeight': damHeight, 'interval':interval, 'btnDelin':btnDelin, 'btnCalc': btnCalc } # this part just for multiprocessing test # info("Main Line") # print "Pre: Process------------------------" # p = Process(target=myfunc) # # p.daemon = True # p.start() # # print "POST: Process-----------------------" return render(request, 'hydroprospector_app/home.html', context)
def gizmo(request): """ Controller for the app home page. """ if request.POST: runoff = float(request.POST['runoff']) intensity = float(request.POST['intensity']) area = float(request.POST['area']) flow = runoff * intensity * area text_input1 = TextInput( display_text='Runoff Coeficient, c', name='runoff', initial='0.8', ) text_input2 = TextInput( display_text='Rainfall Intensity, i [in/hr]', name='intensity', initial='6', ) text_input3 = TextInput( display_text='Drainage Area, A [acre]', name='area', initial='160', ) single_button = Button(display_text='Calculate Flow', name='flow', attributes='form=flow-form', submit=True) context = { 'single_button': single_button, 'text_input1': text_input1, 'text_input2': text_input2, 'text_input3': text_input3 } return render(request, 'sprint/gizmo.html', context)
def update_variable(request): id_input = TextInput(display_text='Variable ID', name='id-input', placeholder='', attributes={ 'id': 'id-input', 'readonly': 'true' }) name_text_input = TextInput( display_text='Variable Name', name='variable-text-input', placeholder='e.g.: Ground Water Depth', attributes={'id': 'variable-text-input'}, ) units_text_input = TextInput( display_text='Variable Units', name='units-text-input', placeholder='e.g.: m', attributes={'id': 'units-text-input'}, ) desc_text_input = TextInput( display_text='Variable Description', name='desc-text-input', placeholder='e.g.: m', attributes={'id': 'desc-text-input'}, ) context = { 'id_input': id_input, 'name_text_input': name_text_input, 'units_text_input': units_text_input, 'desc_text_input': desc_text_input } return render(request, 'gwdm/update_variable.html', context)
def add_geoserver(request): """ Controller for the app add_geoserver page. """ geoserver_name_input = TextInput(display_text='GeoServer Name', name='geoserver-name-input', placeholder='e.g.: My GeoServer', icon_append='glyphicon glyphicon-tag') geoserver_url_input = \ TextInput(display_text='GeoServer Url', name='geoserver-url-input', placeholder='e.g.: http://localhost:8181/geoserver', icon_append='glyphicon glyphicon-cloud-download') geoserver_username_input = \ TextInput(display_text='GeoServer Username', name='geoserver-username-input', placeholder='e.g.: admin', icon_append='glyphicon glyphicon-user') add_button = Button(display_text='Add GeoServer', icon='glyphicon glyphicon-plus', style='success', name='submit-add-geoserver', attributes={'id': 'submit-add-geoserver'}) context = { 'geoserver_name_input': geoserver_name_input, 'geoserver_url_input': geoserver_url_input, 'geoserver_username_input': geoserver_username_input, 'add_button': add_button, } return render(request, 'streamflow_prediction_tool/add_geoserver.html', context)
def update_region(request): id_input = TextInput(display_text='Region ID', name='id-input', placeholder='', attributes={ 'id': 'id-input', 'readonly': 'true' }) region_text_input = TextInput( display_text='Region Name', name='region-text-input', placeholder='e.g.: West Africa', attributes={'id': 'region-text-input'}, ) geoserver_text_input = geoserver_text_gizmo() context = { 'id_input': id_input, 'region_text_input': region_text_input, 'geoserver_text_input': geoserver_text_input } return render(request, 'gwdm/update_region.html', context)
def add_watershed_group(request): """ Controller for the app add_watershed_group page. """ watershed_group_name_input = \ TextInput(display_text='Watershed Group Name', name='watershed-group-name-input', placeholder='e.g.: My Watershed Group', icon_append='glyphicon glyphicon-tag') # initialize session session_maker = app.get_persistent_store_database('main_db', as_sessionmaker=True) session = session_maker() # Query DB for settings watersheds = session.query(Watershed) \ .order_by(Watershed.watershed_name, Watershed.subbasin_name) \ .all() watershed_list = [] for watershed in watersheds: watershed_list.append( ("%s (%s)" % (watershed.watershed_name, watershed.subbasin_name), watershed.id)) session.close() watershed_select = SelectInput( display_text='Select Watershed(s) to Add to Group', name='watershed_select', options=watershed_list, multiple=True, ) add_button = Button(display_text='Add Watershed Group', icon='glyphicon glyphicon-plus', style='success', name='submit-add-watershed-group', attributes={'id': 'submit-add-watershed-group'}) context = { 'watershed_group_name_input': watershed_group_name_input, 'watershed_select': watershed_select, 'add_button': add_button, } return render(request, 'streamflow_prediction_tool/add_watershed_group.html', context)
def thredds_text_gizmo() -> Any: """ Thredds Gizmo Input to Store Thredds WMS Endpoint Returns: A Hidden Tethys Gizmo Input with Thredds WMS Endpoint """ thredds_endpoint = app.get_spatial_dataset_service('primary_thredds', as_endpoint=True) thredds_text_input = TextInput(display_text='Thredds', name='thredds-text-input', placeholder=thredds_endpoint, attributes={'value': thredds_endpoint}, classes="hidden") return thredds_text_input
def home(request): """ Controller for the app home page. """ # Pre-populate lat-picker and lon_picker from model select_input = SelectInput( display_text='Basemap', name='select_input', multiple=False, options=[('Bing', 'bing_layer'), ('MapQuest', 'mapQuest_layer'), ('OpenStreet', 'openstreet_layer'), ('Stamen', 'stamen_layer')], original=['Bing'], attributes="id=selectInput onchange=run_select_basemap()") txtLocation = TextInput(display_text='Location Search:', name="txtLocation", initial="", disabled=False, attributes="onkeypress=handle_search_key(event);") btnSearch = Button(display_text="Search", name="btnSearch", attributes="onclick=run_geocoder();", submit=False) select_navigation = SelectInput( display_text="", name='select_navigation', multiple=False, options=[('Select EPA WATERS Service', 'select'), ('Delineate watershed', 'DeWa'), ('Upstream mainstem', 'UM'), ('Upstream with tributaries', 'UT'), ('Downstream mainstem', 'DM'), ('Downstream with divergences', 'DD')], original=['Select EPA WATERS Service'], attributes="id=select_navigation onchange=select_function();") # Pass variables to the template via the context dictionary context = { 'select_input': select_input, 'txtLocation': txtLocation, 'btnSearch': btnSearch, 'select_navigation': select_navigation } return render(request, 'watershed_delin/home.html', context)
def geoserver_text_gizmo() -> Any: """ Geoserver Gizmo Input to Store Geoserver WFS Endpoint Returns: A Hidden Tethys Gizmo Input with Geoserver WFS Endpoint """ geoserver_wfs_endpoint = app.get_spatial_dataset_service( 'primary_geoserver', as_wfs=True) geoserver_text_input = TextInput( display_text='Geoserver', name='geoserver-text-input', placeholder=geoserver_wfs_endpoint, attributes={'value': geoserver_wfs_endpoint}, classes="hidden") return geoserver_text_input
def mapview(request): """ Controller for the app map page. """ time_slider = RangeSlider(display_text='Time of Day', name='time_slider', min=0, max=24, initial=12, step=1 ) adjust_slider = RangeSlider(display_text='Air Quality Adjustment', name='slider2', min=-5, max=5, initial=0, step=0.5, ) search_input = TextInput(display_text='Location Search', name = 'search_input', icon_append = 'glyphicon glyphicon-search', ) date_picker = DatePicker(name='date_picker', display_text='Date', autoclose=True, format='MM d, yyyy', start_date='03/05/18', start_view='decade', today_button=True, initial='March 5, 2018' ) context = { 'time_slider': time_slider, 'adjust_slider': adjust_slider, 'search_input': search_input, 'date_picker': date_picker, } return render(request, 'mapapp_gibbons/mapview.html', context)
def add_region(request): region_name_input = TextInput( display_text="Region Display Name", name="region-name-input", placeholder="e.g.: Utah", icon_append="glyphicon glyphicon-home", ) # Input for the Region Display Name add_button = Button( display_text="Add Region", icon="glyphicon glyphicon-plus", style="success", name="submit-add-region", attributes={"id": "submit-add-region"}, ) # Add region button context = {"region_name_input": region_name_input, "add_button": add_button} return render(request, "ggst/add_region.html", context)
def region_map(request): """ Controller for the Region Map home page. """ info = request.GET region_id = info.get('region-select') region_name = get_region_name(int(region_id)) aquifer_select = get_aquifer_select(region_id, aquifer_id=True) geoserver_text_input = geoserver_text_gizmo() thredds_text_input = thredds_text_gizmo() variable_select = get_region_variable_select(region_id=region_id) # variable_select = get_variable_select() select_interpolation = SelectInput(display_text='Interpolation Layer', name='select-interpolation', options=[], multiple=False) region_text_input = TextInput(display_text='Region', name='region-text-input', placeholder=region_id, attributes={ 'value': region_id, 'region-name': region_name }, classes="hidden") context = { 'aquifer_select': aquifer_select, 'variable_select': variable_select, 'geoserver_text_input': geoserver_text_input, 'thredds_text_input': thredds_text_input, 'select_interpolation': select_interpolation, 'region_text_input': region_text_input, 'region_name': region_name } return render(request, 'gwdm/region_map.html', context)
def addregions(request): text_input = TextInput(display_text='Add a Region', name='inputAmount', placeholder='e.g.: Sanpete County', prepend='$') add_button = Button(display_text='Add', name='add-button', icon='glyphicon glyphicon-plus', style='info', attributes={ 'data-toggle': 'tooltip', 'data-placement': 'top', 'title': 'Add' }) context = { 'text_input': text_input, 'add_button': add_button, } return render(request, 'mysnowpackapp/addregions.html', context)
def gistable(request): yaque_parcels_list = get_all_parcels() parcels_in_table = [] for item in yaque_parcels_list: table_entry = (item.fid, item.object_id, item.dueno, item.AREA, item.Area_Planted, item.Crop_1, item.Area_Crop_1, item.Crop_2, item.Area_Crop_2, item.Crop_3, item.Area_Crop_3) parcels_in_table.append(table_entry) datatable_results = DataTableView( column_names=('FID', 'Object ID', 'Dueno', 'Area', 'Area Planted', 'Crop 1', 'Area Crop 1', 'Crop 2', 'Area Crop 2', 'Crop 3', 'Area Crop 3'), rows=parcels_in_table, searching=False, orderClasses=False, ) select_district = SelectInput( display_text='Select an Irrigation District:', name='select_district', multiple=False, original=True, options=[ ('Yaque Del Sur', '1'), ('Valle de San Juan', '2'), ('Lago Enriquillo', '3'), ('Azua', '4'), ('Laguna de Cabral', '5'), ], initial=['']) specify_lot = TextInput( display_text='Type the Object ID of the lot you wish to update', name='lot', initial=1) update_button = Button(display_text='Update Parcel', name='update_parcels', style='success', icon='glyphicon glyphicon-plus', href='', submit=False, disabled=False, attributes={"onclick": "updatemodal()"}, classes='') submit_changes_button = Button( display_text='Update Parcel', name='update_parcels', style='success', icon='glyphicon', href='', submit=False, disabled=False, attributes={"onclick": "update_persistent_store_parcel()"}, classes='') specify_dueno = TextInput(display_text='Dueno', name='specify-dueno') specify_area = TextInput(display_text='Area of Lot', name='specify-area') specify_area_planted = TextInput(display_text='Area Planted in Lot', name='specify-area-planted') specify_crop_1 = TextInput(display_text='Crop 1 Name', name='specify-crop-1') specify_area_crop_1 = TextInput(display_text='Area planted with Crop 1', name='specify-area-crop-1') specify_crop_2 = TextInput(display_text='Crop 2 Name', name='specify-crop-2') specify_area_crop_2 = TextInput(display_text='Area planted with Crop 2', name='specify-area-crop-2') specify_crop_3 = TextInput(display_text='Crop 3 Name', name='specify-crop-3') specify_area_crop_3 = TextInput(display_text='Area planted with Crop 3', name='specify-area-crop-3') context = { 'datatable_results': datatable_results, 'select_district': select_district, 'specify_lot': specify_lot, 'update_button': update_button, 'submit_changes_button': submit_changes_button, 'specify_dueno': specify_dueno, 'specify_area': specify_area, 'specify_area_planted': specify_area_planted, 'specify_crop_1': specify_crop_1, 'specify_area_crop_1': specify_area_crop_1, 'specify_crop_2': specify_crop_2, 'specify_area_crop_2': specify_area_crop_2, 'specify_crop_3': specify_crop_3, 'specify_area_crop_3': specify_area_crop_3 } return render(request, 'cultivar/gistable.html', context)
def demand_calculator(request): months = [ 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec' ] k_value_options = [('Maiz(Iniciales)', 0.4), ('Maiz(Desarollo)', 0.8), ('Maiz(Mediados)', 1.125), ('Maiz(Finales)', 1.075), ('Maiz(Recoleccion)', 0.875), ('Platano(Iniciales)', 0.45), ('Platano(Desarollo)', 0.775), ('Platano(Mediados)', 1.05), ('Platano(Finales)', 0.95), ('Platano(Recoleccion)', 0.8), ('Cana(Iniciales)', 0.6), ('Cana(Desarollo)', 0.8), ('Cana(Mediados)', 1), ('Cana(Finales)', 0.85), ('Cana(Recoleccion)', 0.75), ('Arroz(Iniciales)', 1.125), ('Arroz(Desarollo)', 1.3), ('Arroz(Mediados)', 1.2), ('Arroz(Finales)', 1), ('Arroz(Recoleccion)', 1), ('Other...(Specify)', 999)] select_district = SelectInput( display_text='Select an Irrigation District:', name='select1', multiple=False, original=True, options=[ ('Yaque Del Sur', '219114'), ('Valle de San Juan', '609024'), ('Lago Enriquillo', '413236'), ('Azua', '871546'), ('Laguna de Cabral', '700'), ], initial=['']) select_crop_number = SelectInput( display_text='Number of Crop Types Planted:', name='select_crop_number', multiple=False, original=True, options=[('1', 1), ('2', 2), ('3', 3), ('4', 4)], initial=['1'], attributes={'onchange': "cropnumber()"}) select_crop_type = SelectInput( display_text='Crop Type(Growth Stage):', name='kValue1', multiple=False, original=True, options=k_value_options, attributes={ 'onchange': "$('.user-k-value').toggleClass('hidden', this.value != 999)" }) input_k_value = TextInput(display_text='Crop K Value', name='kValue2') input_crop_name = TextInput(display_text='Crop Type', name='cropName') select_crop_2_type = SelectInput( display_text='Crop Type(Growth Stage):', name='k2Value1', multiple=False, original=True, options=k_value_options, attributes={ 'onchange': "$('.user-k-value').toggleClass('hidden', this.value != 999)" }) input_k_2_value = TextInput(display_text='Crop K Value', name='k2Value2') input_crop_2_name = TextInput(display_text='Crop Type', name='crop2Name') select_crop_3_type = SelectInput( display_text='Crop Type(Growth Stage):', name='k3Value1', multiple=False, original=True, options=k_value_options, attributes={ 'onchange': "$('.user-k-value').toggleClass('hidden', this.value != 999)" }) input_k_3_value = TextInput(display_text='Crop K Value', name='k3Value2') input_crop_3_name = TextInput(display_text='Crop Type', name='crop3Name') select_crop_4_type = SelectInput( display_text='Crop Type(Growth Stage):', name='k4Value1', multiple=False, original=True, options=k_value_options, attributes={ 'onchange': "$('.user-k-value').toggleClass('hidden', this.value != 999)" }) input_k_4_value = TextInput(display_text='Crop K Value', name='k4Value2') input_crop_4_name = TextInput(display_text='Crop Type', name='crop4Name') input_parameters_button = Button(display_text='Input Parameters', name='input-parameters-button', icon='', style='', submit=False, disabled=False, attributes={"onclick": "watermodal()"}, classes='') calculate_button = Button(display_text='Calculate Demand', name='calculate_demand', style='success', icon='glyphicon', href='', submit=False, disabled=False, attributes={"onclick": "calculate_demand()"}, classes='') area_seeded_1 = TextInput(display_text='Area Seeded(tareas)', name='area_seeded_1', placeholder='e.g.: 10.00', prepend='*') area_seeded_2 = TextInput(display_text='Area Seeded(tareas)', name='area_seeded_2', placeholder='e.g.: 10.00', prepend='*') area_seeded_3 = TextInput(display_text='Area Seeded(tareas)', name='area_seeded_3', placeholder='e.g.: 10.00', prepend='*') area_seeded_4 = TextInput(display_text='Area Seeded(tareas)', name='area_seeded_4', placeholder='e.g.: 10.00', prepend='*') close_button = Button(display_text='Close', name='close_button', style='', icon='', href='', submit=False, disabled=False, attributes={"onclick": "hideresultmodal()"}, classes='') water_results = TableView( column_names=('Crop Type', 'Area of Planted Crop (ac)', 'Total Demand for specified time period (ac-ft)'), rows=[ ('Corn', 150, 47), ('Cocoa', 200, 58), ('Rice', 75, 35), ('Total', 425, 140), ], hover=True, striped=True, bordered=True, condensed=True, editable_columns=(False, False), row_ids=[21, 25, 31]) context = { 'input_crop_name': input_crop_name, 'input_k_value': input_k_value, 'input_crop_2_name': input_crop_2_name, 'input_k_2_value': input_k_2_value, 'input_crop_3_name': input_crop_3_name, 'input_k_3_value': input_k_3_value, 'input_crop_4_name': input_crop_4_name, 'input_k_4_value': input_k_4_value, 'k_value_options': k_value_options, 'area_seeded_1': area_seeded_1, 'area_seeded_2': area_seeded_2, 'area_seeded_3': area_seeded_3, 'area_seeded_4': area_seeded_4, 'months': months, 'water_results': water_results, 'close_button': close_button, 'calculate_button': calculate_button, 'select_crop_type': select_crop_type, 'select_crop_2_type': select_crop_2_type, 'select_crop_3_type': select_crop_3_type, 'select_crop_4_type': select_crop_4_type, 'select_crop_number': select_crop_number, 'input_parameters_button': input_parameters_button, 'select_district': select_district, } return render(request, 'cultivar/demand_calculator.html', context)