Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
J
JoinTheCity
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Rafal
JoinTheCity
Commits
4c95de8a
Commit
4c95de8a
authored
Jan 11, 2016
by
Rafal
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make apitype
Add all apis to database
parent
ce180e5d
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
47 additions
and
8 deletions
+47
-8
init_apis.py
JoinTheCityREST/app/API/management/commands/init_apis.py
+11
-5
init_apitypes.py
JoinTheCityREST/app/API/management/commands/init_apitypes.py
+19
-0
models.py
JoinTheCityREST/app/API/models.py
+14
-1
init.py
JoinTheCityREST/app/User/management/commands/init.py
+1
-0
init_userapi.py
JoinTheCityREST/app/User/management/commands/init_userapi.py
+2
-2
No files found.
JoinTheCityREST/app/API/management/commands/init_apis.py
View file @
4c95de8a
from
app.API.models
import
API
from
app.API.models
import
API
,
APIType
from
app.Tag.models
import
Tag
__author__
=
'Rafal'
...
...
@@ -10,14 +10,20 @@ class Command(BaseCommand):
def
handle
(
self
,
*
args
,
**
options
):
apis
=
[
[
'Hotele w Krakowie'
,
'Krakow'
],
[
'Wypadki w Krakowie'
,
'Krakow'
],
[
'Cmenatarze w Krakowie'
,
'Krakow'
],
[
'Apteki w Krakowie'
,
'Krakow'
,
'map'
,
'apteki'
],
[
'Baseny w Krakowie'
,
'Krakow'
,
'map'
,
'baseny'
],
[
'Hotele w Krakowie'
,
'Krakow'
,
'map'
,
' hotele'
],
[
'HotSpoty w Krakowie'
,
'Krakow'
,
'map'
,
' mapaHotSpotow'
],
[
'Utrudnienia w Krakowie'
,
'Krakow'
,
'map'
,
' mapaUtrudnien'
],
[
'Restauracje w Krakowie'
,
'Krakow'
,
'map'
,
' restauracje'
],
[
'Szpitale w Krakowie'
,
'Krakow'
,
'map'
,
' szpitale'
],
[
'Zdarzenia drogowe w Krakowie'
,
'Krakow'
,
'map'
,
' zdarzeniaDrogowe'
],
]
print
"Creating APIs"
for
api
in
apis
:
print
"Create {0}"
.
format
(
api
[
0
])
tag
=
Tag
.
objects
.
filter
(
name
=
api
[
1
])[
0
]
new_api
=
API
.
objects
.
create
(
name
=
api
[
0
])
api_type
=
APIType
.
objects
.
filter
(
name
=
api
[
2
])[
0
]
new_api
=
API
.
objects
.
create
(
name
=
api
[
0
],
type
=
api_type
,
source
=
api
[
3
])
new_api
.
tag
=
[
tag
,
]
new_api
.
save
()
\ No newline at end of file
JoinTheCityREST/app/API/management/commands/init_apitypes.py
0 → 100644
View file @
4c95de8a
from
app.API.models
import
API
,
APIType
from
app.Tag.models
import
Tag
__author__
=
'Rafal'
from
django.core.management.base
import
BaseCommand
class
Command
(
BaseCommand
):
help
=
'Closes the specified poll for voting'
def
handle
(
self
,
*
args
,
**
options
):
apis_type
=
[
[
'map'
,
],
]
print
"Creating APIs type"
for
api_type
in
apis_type
:
print
"Create {0}"
.
format
(
api_type
[
0
])
new_api
=
APIType
.
objects
.
create
(
name
=
api_type
[
0
])
new_api
.
save
()
\ No newline at end of file
JoinTheCityREST/app/API/models.py
View file @
4c95de8a
...
...
@@ -5,9 +5,22 @@ from django.db import models
from
app.Tag.models
import
Tag
class
APIType
(
models
.
Model
):
name
=
models
.
CharField
(
max_length
=
100
)
def
__str__
(
self
):
return
self
.
name
class
API
(
models
.
Model
):
name
=
models
.
CharField
(
max_length
=
100
)
tag
=
models
.
ManyToManyField
(
Tag
,
related_name
=
'API_tags'
,
blank
=
False
,
default
=
None
)
type
=
models
.
ForeignKey
(
APIType
,
related_name
=
'API_type'
,
blank
=
False
,
null
=
False
,
default
=
None
)
source
=
models
.
CharField
(
max_length
=
100
)
def
__str__
(
self
):
return
self
.
name
JoinTheCityREST/app/User/management/commands/init.py
View file @
4c95de8a
...
...
@@ -10,6 +10,7 @@ class Command(BaseCommand):
call_command
(
'init_users'
)
call_command
(
'init_localizations'
)
call_command
(
'init_tags'
)
call_command
(
'init_apitypes'
)
call_command
(
'init_apis'
)
call_command
(
'init_textmessages'
)
call_command
(
'init_discussions'
)
...
...
JoinTheCityREST/app/User/management/commands/init_userapi.py
View file @
4c95de8a
...
...
@@ -14,8 +14,8 @@ class Command(BaseCommand):
def
handle
(
self
,
*
args
,
**
options
):
apis
=
[
[
'admin'
,
'Hotele w Krakowie'
],
[
'admin'
,
'
Wypadki
w Krakowie'
],
[
'admin'
,
'
Cmenatarz
e w Krakowie'
],
[
'admin'
,
'
Zdarzenia drogowe
w Krakowie'
],
[
'admin'
,
'
Restauracj
e w Krakowie'
],
]
print
"Creating UserApi"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment