-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
kiezradar: add radius based model, serializer, api, view, template
- Loading branch information
Showing
28 changed files
with
918 additions
and
408 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
### Added | ||
|
||
- KiezRadar model, serializer, view and api for radius based filter in kiezradar app | ||
|
||
### Changed | ||
- kiezradar one-to-one field in SearchProfile model |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,56 @@ | ||
from rest_framework import viewsets | ||
from rest_framework.permissions import IsAuthenticated | ||
|
||
from adhocracy4.api.permissions import ViewSetRulesPermission | ||
|
||
from .models import KiezRadar | ||
from .models import SearchProfile | ||
from .serializers import KiezRadarSerializer | ||
from .serializers import SearchProfileSerializer | ||
|
||
|
||
class KiezRadarViewSet(viewsets.ModelViewSet): | ||
""" | ||
ViewSet for managing KiezRadar objects. | ||
""" | ||
|
||
queryset = KiezRadar.objects.all() | ||
serializer_class = KiezRadarSerializer | ||
permission_classes = [ViewSetRulesPermission] | ||
|
||
def perform_create(self, serializer): | ||
""" | ||
Override to save the user from the request. | ||
""" | ||
serializer.save(creator=self.request.user) | ||
|
||
def get_permission_object(self): | ||
return None | ||
|
||
def get_queryset(self): | ||
if self.request.user.is_authenticated: | ||
return KiezRadar.objects.filter(creator=self.request.user) | ||
return KiezRadar.objects.none() | ||
|
||
|
||
class SearchProfileViewSet(viewsets.ModelViewSet): | ||
""" | ||
ViewSet for managing SearchProfile objects. | ||
""" | ||
|
||
queryset = SearchProfile.objects.select_related("query").all() | ||
serializer_class = SearchProfileSerializer | ||
permission_classes = [IsAuthenticated] | ||
permission_classes = [ViewSetRulesPermission] | ||
|
||
def perform_create(self, serializer): | ||
""" | ||
Override to save the user from the request. | ||
""" | ||
serializer.save(user=self.request.user) | ||
serializer.save(creator=self.request.user) | ||
|
||
def get_permission_object(self): | ||
return None | ||
|
||
def get_queryset(self): | ||
if self.request.user.is_authenticated: | ||
return SearchProfile.objects.filter(creator=self.request.user) | ||
return SearchProfile.objects.none() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 0 additions & 18 deletions
18
meinberlin/apps/kiezradar/migrations/0003_searchprofile_notification.py
This file was deleted.
Oops, something went wrong.
47 changes: 0 additions & 47 deletions
47
meinberlin/apps/kiezradar/migrations/0004_add_project_status.py
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.