Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
scheduling-system
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
SMASCH
scheduling-system
Merge requests
!36
Resolve "configuration panel"
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Resolve "configuration panel"
87-configuration-panel
into
master
Overview
0
Commits
6
Pipelines
1
Changes
14
Merged
Piotr Gawron
requested to merge
87-configuration-panel
into
master
7 years ago
Overview
0
Commits
6
Pipelines
1
Changes
14
Expand
Closes
#87 (closed)
0
0
Merge request reports
Compare
master
master (base)
and
latest version
latest version
6a6347fc
6 commits,
7 years ago
14 files
+
308
−
3
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
14
Search (e.g. *.vue) (Ctrl+P)
smash/web/api_views/configuration.py
0 → 100644
+
58
−
0
Options
from
django.contrib.auth.decorators
import
login_required
from
django.http
import
JsonResponse
from
web.models
import
ConfigurationItem
@login_required
def
configuration_items
(
request
):
# id of the query from dataTable: https://datatables.net/manual/server-side
draw
=
int
(
request
.
GET
.
get
(
"
draw
"
,
"
-1
"
))
start
=
int
(
request
.
GET
.
get
(
"
start
"
,
"
0
"
))
length
=
int
(
request
.
GET
.
get
(
"
length
"
,
"
10
"
))
items
=
ConfigurationItem
.
objects
.
all
()
count
=
items
.
count
()
count_filtered
=
count
sliced_items
=
items
[
start
:(
start
+
length
)]
data
=
[]
for
configuration_item
in
sliced_items
:
data
.
append
({
"
id
"
:
configuration_item
.
id
,
"
name
"
:
configuration_item
.
name
,
"
value
"
:
configuration_item
.
value
})
return
JsonResponse
({
"
draw
"
:
draw
,
"
recordsTotal
"
:
count
,
"
recordsFiltered
"
:
count_filtered
,
"
data
"
:
data
})
@login_required
def
update_configuration_item
(
request
):
id
=
int
(
request
.
GET
.
get
(
"
id
"
,
"
-1
"
))
value
=
request
.
GET
.
get
(
"
value
"
,
None
)
if
(
id
is
None
)
or
(
value
is
None
):
return
JsonResponse
({
"
status
"
:
"
error
"
,
"
message
"
:
"
id and value are obligatory
"
})
items
=
ConfigurationItem
.
objects
.
filter
(
id
=
id
)
if
len
(
items
)
==
0
:
return
JsonResponse
({
"
status
"
:
"
error
"
,
"
message
"
:
"
item with given id doesn
'
t exist
"
})
item
=
items
[
0
]
item
.
value
=
value
item
.
save
()
return
JsonResponse
({
"
status
"
:
"
ok
"
,
})
Loading