Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API:s for the new front-end #792

Open
wants to merge 22 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file added src/__init__.py
Empty file.
31 changes: 31 additions & 0 deletions src/events/serializers/serializers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
from events.models.costs import Costs
from events.models.event import Event
from events.models.participant import Participant
from events.models.application import EventApplication
from events.models.ticket import Ticket
from rest_framework import serializers

class CostsSerializer(serializers.ModelSerializer):
class Meta:
model = Costs
fields = '__all__'

class EventSerializer(serializers.ModelSerializer):
class Meta:
model = Event
fields = '__all__'

class ParticipantSerializer(serializers.ModelSerializer):
class Meta:
model = Participant
fields = '__all__'

class EventApplicationSerializer(serializers.ModelSerializer):
class Meta:
model = EventApplication
fields = '__all__'

class TicketSerializer(serializers.ModelSerializer):
class Meta:
model = Ticket
fields = '__all__'
11 changes: 11 additions & 0 deletions src/events/urls.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
from django.urls import path, re_path
from rest_framework import routers
from events import views

router = routers.SimpleRouter()
router.register(r'^api/costs', views.api.CostsViewSet, basename="CostsView")
router.register(r'^api/event', views.api.EventViewSet, basename="EventView")
router.register(r'^api/eventapplication', views.api.EventApplicationViewSet, basename="EventApplicationView")
router.register(r'^api/ticket', views.api.TicketViewSet, basename="TicketView")
router.register(r'^api/participant', views.api.ParticipantViewSet, basename="ParticipantView")


urlpatterns = [
path('event/<int:pk>',
views.EventView.as_view(),
Expand Down Expand Up @@ -31,3 +40,5 @@
name='events_event_modeladmin_export_participants'
),
]

urlpatterns += router.urls
1 change: 1 addition & 0 deletions src/events/views/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
from .admin_unassign_unpaid import *
from .admin_remove_applications import *
from .admin_export_participants import *
from .api import *
34 changes: 34 additions & 0 deletions src/events/views/api.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
from rest_framework import viewsets
from events.serializers.serializers import *
from rest_framework.permissions import AllowAny
from events.models.costs import Costs
from events.models.event import Event
from events.models.participant import Participant
from events.models.application import EventApplication
from events.models.ticket import Ticket

class CostsViewSet(viewsets.ModelViewSet):
serializer_class = CostsSerializer
permission_classes = [AllowAny]
queryset = Costs.objects.all()

class EventViewSet(viewsets.ModelViewSet):
serializer_class = EventSerializer
permission_classes = [AllowAny]
queryset = Event.objects.all()

class ParticipantViewSet(viewsets.ModelViewSet):
serializer_class = ParticipantSerializer
permission_classes = [AllowAny]
queryset = Participant.objects.all()

class EventApplicationViewSet(viewsets.ModelViewSet):
serializer_class = EventApplicationSerializer
permission_classes = [AllowAny]
queryset = EventApplication.objects.all()

class TicketViewSet(viewsets.ModelViewSet):
serializer_class = TicketSerializer
permission_classes = [AllowAny]
queryset = Ticket.objects.all()

13 changes: 13 additions & 0 deletions src/involvement/serializers/position_serializer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from involvement.models.position import Position
from rest_framework import serializers

class PositionSerializer(serializers.ModelSerializer):
class Meta:
model = Position
fields = '__all__'

class PositionDepthSerializer(serializers.ModelSerializer):
class Meta:
model = Position
fields = '__all__'
depth = 1
8 changes: 7 additions & 1 deletion src/involvement/urls.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
from django.conf.urls import re_path

from rest_framework import routers
from involvement import views

router = routers.SimpleRouter()
router.register(r'^position', views.position_api.PositionViewSet, basename="PositionView")
router.register(r'^position2', views.position_api.Position2ViewSet, basename="Position2View")

urlpatterns = [
re_path(
r'^admin/involvement/position/elect/(\d+)/$',
Expand All @@ -19,3 +23,5 @@
name='involvement_position_extend'
),
]

urlpatterns += router.urls
1 change: 1 addition & 0 deletions src/involvement/views/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from .position_create_view import PositionCreateView
from .position_edit_view import PositionEditView
from .position_inspect_view import PositionInspectView
from .position_api import PositionViewSet
from .role_create_view import RoleCreateView
from .role_edit_view import RoleEditView
from .application_create_view import ApplicationCreateView
Expand Down
14 changes: 14 additions & 0 deletions src/involvement/views/position_api.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from rest_framework import viewsets
from involvement.serializers.position_serializer import PositionSerializer, PositionDepthSerializer
from rest_framework.permissions import AllowAny
from involvement.models.position import Position

class PositionViewSet(viewsets.ModelViewSet):
serializer_class = PositionSerializer
permission_classes = [AllowAny]
queryset = Position.objects.all()

class Position2ViewSet(viewsets.ModelViewSet):
serializer_class = PositionDepthSerializer
permission_classes = [AllowAny]
queryset = Position.objects.all()
40 changes: 20 additions & 20 deletions src/moore/settings/dev.py
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reasons for these changes? Committed by mistake?

Original file line number Diff line number Diff line change
Expand Up @@ -21,31 +21,31 @@
# https://docs.djangoproject.com/en/1.10/ref/settings/#databases


if IS_RUNNING_TEST:
DATABASES = {
# if IS_RUNNING_TEST:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}
# Override search backend to not use postgres
WAGTAILSEARCH_BACKENDS = {
'default': {
'BACKEND': 'wagtail.search.backends.database',
}
}

elif 'DOCKER' in os.environ:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'moore',
'USER': 'moore',
'HOST': 'moore-db',
'PASSWORD': 'moore',
'PORT': 5432,
}
}
# # Override search backend to not use postgres
# WAGTAILSEARCH_BACKENDS = {
# 'default': {
# 'BACKEND': 'wagtail.search.backends.database',
# }
# }

# elif 'DOCKER' in os.environ:
# DATABASES = {
# 'default': {
# 'ENGINE': 'django.db.backends.postgresql',
# 'NAME': 'moore',
# 'USER': 'moore',
# 'HOST': 'moore-db',
# 'PASSWORD': 'moore',
# 'PORT': 5432,
# }
# }

# Base URL to use when referring to full URLs within the Wagtail admin
# backend - e.g. in notification emails. Don't include '/admin' or a
Expand Down
Loading