Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
V
VIPSWeb
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
VIPS
VIPSWeb
Commits
719364f7
Commit
719364f7
authored
7 years ago
by
Tor-Einar Skog
Browse files
Options
Downloads
Patches
Plain Diff
Supporting season select for forecasts list
parent
70ae022e
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
forecasts/models.py
+5
-3
5 additions, 3 deletions
forecasts/models.py
forecasts/templates/forecasts/index.html
+8
-0
8 additions, 0 deletions
forecasts/templates/forecasts/index.html
forecasts/views.py
+10
-3
10 additions, 3 deletions
forecasts/views.py
with
23 additions
and
6 deletions
forecasts/models.py
+
5
−
3
View file @
719364f7
...
...
@@ -223,16 +223,18 @@ class ForecastConfiguration:
# Returns a result object
@staticmethod
def
get_forecast_configurations_from_vipslogic
(
crop_organism_ids
):
def
get_forecast_configurations_from_vipslogic
(
crop_organism_ids
,
season
):
crop_organism_id_paramstring
=
""
if
crop_organism_ids
!=
None
:
for
crop_organism_id
in
crop_organism_ids
:
crop_organism_id_paramstring
+=
"
&cropOrganismId=%s
"
%
crop_organism_id
request_result
=
requests
.
get
(
"
%s://%s/rest/organizationforecastconfigurations/%s?%s
"
%
(
request_result
=
requests
.
get
(
"
%s://%s/rest/organizationforecastconfigurations/%s?
from=%s-01-01&to=%s-12-31
%s
"
%
(
settings
.
VIPSLOGIC_PROTOCOL
,
settings
.
VIPSLOGIC_SERVER_NAME
,
settings
.
VIPS_ORGANIZATION_ID
,
season
,
season
,
crop_organism_id_paramstring
)
)
...
...
This diff is collapsed.
Click to expand it.
forecasts/templates/forecasts/index.html
+
8
−
0
View file @
719364f7
...
...
@@ -44,6 +44,14 @@
<th>
<input
id=
"weatherStationName"
class=
"form-control"
type=
"text"
placeholder=
"{% trans "
Search
"
%}"
oninput=
"filterForecastConfigurations();"
/>
</th>
<th></th>
<th
colspan=
"2"
>
<select
id=
"season"
class=
"form-control"
onchange=
"window.location.href='/forecasts?season=' + this.options[this.options.selectedIndex].value;"
>
{% for season_option_value in season_range %}
<option
value=
"{{season_option_value}}"
{%
if
season_option_value =
=
season
%}
selected=
"selected"
{%
endif
%}
>
{{season_option_value}}
</option>
{% endfor %}
</select>
</th>
</tr>
</thead>
<thead>
...
...
This diff is collapsed.
Click to expand it.
forecasts/views.py
+
10
−
3
View file @
719364f7
#
# Copyright (c) 201
4
NIBIO <http://www.nibio.no/>.
# Copyright (c) 201
7
NIBIO <http://www.nibio.no/>.
#
# This file is part of VIPSWeb.
# VIPSWeb is free software: you can redistribute it and/or modify
...
...
@@ -17,6 +17,8 @@
#
# @author: Tor-Einar Skog <tor-einar.skog@nibio.no>
from
datetime
import
datetime
from
dateutil.relativedelta
import
relativedelta
from
django.http
import
HttpResponse
from
django.shortcuts
import
render
...
...
@@ -26,7 +28,10 @@ from django.utils import translation
from
forecasts.models
import
ForecastConfiguration
,
ForecastResult
,
ResultParameter
,
ResultParameterLocal
,
Model
,
MeasurementUnit
,
ModelGraphParameter
def
index
(
request
):
forecast_configurations
=
ForecastConfiguration
.
get_forecast_configurations_from_vipslogic
(
None
).
text
season_range
=
range
(
2016
,
datetime
.
now
().
year
+
1
)
season
=
int
(
request
.
GET
.
get
(
"
season
"
,
(
datetime
.
now
()
+
relativedelta
(
months
=
settings
.
SYSTEM_TIME_OFFSET_MONTHS
)).
year
))
forecast_configurations
=
ForecastConfiguration
.
get_forecast_configurations_from_vipslogic
(
None
,
season
).
text
private_forecast_configurations
=
None
if
request
.
session
.
get
(
"
user_uuid
"
,
None
)
!=
None
:
private_forecast_configurations
=
ForecastConfiguration
.
get_private_forecast_configurations
(
request
.
session
[
"
user_uuid
"
])
...
...
@@ -34,7 +39,9 @@ def index(request):
context
=
{
'
forecast_configurations
'
:
forecast_configurations
,
'
private_forecast_configurations
'
:
private_forecast_configurations
,
'
models_local_names
'
:
Model
.
get_models_local_names
().
text
'
models_local_names
'
:
Model
.
get_models_local_names
().
text
,
'
season
'
:
season
,
'
season_range
'
:
season_range
}
return
render
(
request
,
'
forecasts/index.html
'
,
context
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment