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
98522569
Commit
98522569
authored
Jan 17, 2016
by
adam
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
https://gitlab.telemabk.pl/vallher/JoinTheCity
parents
63a11fb7
0567d761
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
29 additions
and
3 deletions
+29
-3
models.py
JoinTheCityREST/app/Discussion/models.py
+8
-1
views.py
JoinTheCityREST/app/Discussion/views.py
+12
-1
mapaUtrudnien.py
JoinTheCityREST/lib/api/mapaUtrudnien.py
+1
-1
restauracje.py
JoinTheCityREST/lib/api/restauracje.py
+8
-0
No files found.
JoinTheCityREST/app/Discussion/models.py
View file @
98522569
...
...
@@ -22,3 +22,10 @@ class Discussion(models.Model):
def
__str__
(
self
):
return
self
.
question
def
add_message
(
self
,
user
,
text
):
message
=
TextMessage
.
objects
.
create
()
message
.
user
=
user
message
.
text
=
text
self
.
messages
.
add
(
message
)
self
.
save
()
\ No newline at end of file
JoinTheCityREST/app/Discussion/views.py
View file @
98522569
# Create your views here.
from
django.shortcuts
import
get_object_or_404
from
rest_framework
import
viewsets
,
permissions
from
rest_framework.decorators
import
detail_route
from
app.API.serializers
import
APISerializer
from
app.Discussion.models
import
Discussion
,
TextMessage
from
app.Discussion.serializers
import
TextMessageSerializer
,
DiscussionSerializer
from
rest_framework.response
import
Response
import
rest_framework
class
DiscussionViewSet
(
viewsets
.
ModelViewSet
):
"""
...
...
@@ -13,6 +16,14 @@ class DiscussionViewSet(viewsets.ModelViewSet):
serializer_class
=
DiscussionSerializer
permission_classes
=
(
permissions
.
IsAuthenticatedOrReadOnly
,)
@
detail_route
()
def
add
(
self
,
request
,
pk
=
None
):
discussion
=
get_object_or_404
(
self
.
queryset
,
pk
=
pk
)
text
=
request
.
data
.
get
(
'text'
)
user
=
request
.
user
discussion
.
add_message
(
text
=
text
,
user
=
user
)
return
Response
(
status
=
rest_framework
.
status
.
HTTP_200_OK
)
class
TextMessageViewSet
(
viewsets
.
ModelViewSet
):
"""
API for articles
...
...
JoinTheCityREST/lib/api/mapaUtrudnien.py
View file @
98522569
...
...
@@ -29,6 +29,6 @@ class API(BaseAPI):
result
[
'name'
]
=
property
[
'value'
]
elif
property
[
'key'
]
==
'lat'
:
result
[
'latitude'
]
=
property
[
'value'
]
elif
property
[
'key'
]
==
'l
on
'
:
elif
property
[
'key'
]
==
'l
ng
'
:
result
[
'longitude'
]
=
property
[
'value'
]
return
result
\ No newline at end of file
JoinTheCityREST/lib/api/restauracje.py
View file @
98522569
...
...
@@ -31,4 +31,12 @@ class API(BaseAPI):
result
[
'latitude'
]
=
property
[
'value'
]
elif
property
[
'key'
]
==
'OADR_GPS_D'
:
result
[
'longitude'
]
=
property
[
'value'
]
elif
property
[
'key'
]
==
'OADR_MIASTO'
:
result
[
'city'
]
=
property
[
'value'
]
elif
property
[
'key'
]
==
'OADR_ULICA'
:
result
[
'street'
]
=
property
[
'value'
]
elif
property
[
'key'
]
==
'OADR_NR'
:
result
[
'nr'
]
=
property
[
'value'
]
result
[
'address'
]
=
"{0} {1}, {2}"
.
format
(
result
[
'street'
]
.
encode
(
"utf-8"
),
result
[
'nr'
]
.
encode
(
"utf-8"
),
result
[
'city'
]
.
encode
(
"utf-8"
))
return
result
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