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
Commits
08cc68ec
Commit
08cc68ec
authored
7 years ago
by
Piotr Gawron
Browse files
Options
Downloads
Patches
Plain Diff
api for obtaining flying teams
parent
da855430
No related branches found
No related tags found
1 merge request
!106
Resolve "Subjects without visit list"
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
smash/web/api_urls.py
+4
-1
4 additions, 1 deletion
smash/web/api_urls.py
smash/web/api_views/flying_team.py
+15
-0
15 additions, 0 deletions
smash/web/api_views/flying_team.py
smash/web/tests/api_views/test_flying_team.py
+38
-0
38 additions, 0 deletions
smash/web/tests/api_views/test_flying_team.py
with
57 additions
and
1 deletion
smash/web/api_urls.py
+
4
−
1
View file @
08cc68ec
...
...
@@ -16,7 +16,7 @@ Including another URLconf
from
django.conf.urls
import
url
from
web.api_views
import
worker
,
location
,
subject
,
appointment_type
,
appointment
,
configuration
,
daily_planning
,
\
redcap
redcap
,
flying_team
urlpatterns
=
[
# appointments
...
...
@@ -41,6 +41,9 @@ urlpatterns = [
# locations
url
(
r
'
^locations$
'
,
location
.
locations
,
name
=
'
web.api.locations
'
),
# flying_teams
url
(
r
'
^flying_teams$
'
,
flying_team
.
flying_teams
,
name
=
'
web.api.flying_teams
'
),
# worker data
url
(
r
'
^specializations$
'
,
worker
.
specializations
,
name
=
'
web.api.specializations
'
),
url
(
r
'
^units$
'
,
worker
.
units
,
name
=
'
web.api.units
'
),
...
...
This diff is collapsed.
Click to expand it.
smash/web/api_views/flying_team.py
0 → 100644
+
15
−
0
View file @
08cc68ec
from
django.contrib.auth.decorators
import
login_required
from
django.http
import
JsonResponse
from
web.models
import
FlyingTeam
@login_required
def
flying_teams
(
request
):
all_flying_teams
=
FlyingTeam
.
objects
.
all
()
data
=
[]
for
flying_team
in
all_flying_teams
:
data
.
append
({
"
id
"
:
flying_team
.
id
,
"
name
"
:
flying_team
.
place
})
return
JsonResponse
({
"
flying_teams
"
:
data
})
This diff is collapsed.
Click to expand it.
smash/web/tests/api_views/test_flying_team.py
0 → 100644
+
38
−
0
View file @
08cc68ec
# coding=utf-8
import
json
from
django.contrib.auth.models
import
User
from
django.test
import
Client
from
django.test
import
TestCase
from
django.urls
import
reverse
from
web.tests.functions
import
create_worker
,
create_flying_team
class
TestFlyingTeamApi
(
TestCase
):
def
setUp
(
self
):
self
.
client
=
Client
()
username
=
'
piotr
'
password
=
'
top_secret
'
self
.
user
=
User
.
objects
.
create_user
(
username
=
username
,
email
=
'
jacob@bla
'
,
password
=
password
)
self
.
worker
=
create_worker
(
self
.
user
)
self
.
client
.
login
(
username
=
username
,
password
=
password
)
def
test_flying_teams
(
self
):
flying_team_name
=
"
some flying_team
"
response
=
self
.
client
.
get
(
reverse
(
'
web.api.flying_teams
'
))
self
.
assertEqual
(
response
.
status_code
,
200
)
create_flying_team
(
flying_team_name
)
response
=
self
.
client
.
get
(
reverse
(
'
web.api.flying_teams
'
))
flying_teams
=
json
.
loads
(
response
.
content
)[
'
flying_teams
'
]
found
=
False
for
flying_team
in
flying_teams
:
if
flying_team
[
'
name
'
]
==
flying_team_name
:
found
=
True
self
.
assertTrue
(
found
)
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