-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: added serializers to watchlist and news
- Loading branch information
1 parent
1f7c64c
commit d235532
Showing
16 changed files
with
169 additions
and
24 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 |
---|---|---|
|
@@ -14,6 +14,7 @@ profilepictures/ | |
# For Rope Project settings | ||
.ropeproject | ||
|
||
.python-version | ||
|
||
env/ | ||
venv/ | ||
|
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,18 +1,26 @@ | ||
from django.urls import path | ||
|
||
from . import views | ||
from .ical import HSEventFeed, HSEventSingleFeed | ||
from .views import template_views | ||
|
||
app_name = "events" | ||
urlpatterns = [ | ||
path("", views.EventListView.as_view(), name="all"), | ||
path("<int:pk>/", views.EventView.as_view(), name="details"), | ||
path("<int:pk>/edit/", views.EventUpdateView.as_view(), name="edit"), | ||
path("<int:pk>/attended/", views.EventAttendeeEditView.as_view(), name="attended"), | ||
path("<int:pk>/skills/", views.EventAttendeeSkillsView.as_view(), name="skills"), | ||
path("new", views.EventCreateView.as_view(), name="new"), | ||
path("<int:pk>/delete/", views.EventDeleteView.as_view(), name="delete"), | ||
path("<int:event_id>/register/", views.register_on_event, name="register"), | ||
path("", template_views.EventListView.as_view(), name="all"), | ||
path("<int:pk>/", template_views.EventView.as_view(), name="details"), | ||
path("<int:pk>/edit/", template_views.EventUpdateView.as_view(), name="edit"), | ||
path( | ||
"<int:pk>/attended/", | ||
template_views.EventAttendeeEditView.as_view(), | ||
name="attended", | ||
), | ||
path( | ||
"<int:pk>/skills/", | ||
template_views.EventAttendeeSkillsView.as_view(), | ||
name="skills", | ||
), | ||
path("new", template_views.EventCreateView.as_view(), name="new"), | ||
path("<int:pk>/delete/", template_views.EventDeleteView.as_view(), name="delete"), | ||
path("<int:event_id>/register/", template_views.register_on_event, name="register"), | ||
path("feed.ics", HSEventFeed()), | ||
path("<int:pk>/feed.ics", HSEventSingleFeed()), | ||
] |
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,22 @@ | ||
from rest_framework import serializers | ||
|
||
from news.models import Article | ||
|
||
|
||
class ArticleListSerializer(serializers.ModelSerializer): | ||
class Meta: | ||
model = Article | ||
fields = ( | ||
"id", | ||
"title", | ||
"ingress_content", | ||
"internal", | ||
"pub_date", | ||
"thumbnail", | ||
) | ||
|
||
|
||
class ArticleRetrieveSerializer(ArticleListSerializer): | ||
class Meta: | ||
model = Article | ||
fields = "__all__" |
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,22 @@ | ||
from rest_framework import serializers | ||
|
||
from news.models import Event | ||
|
||
|
||
class EventListSerializer(serializers.ModelSerializer): | ||
class Meta: | ||
model = Event | ||
fields = fields = ( | ||
"id", | ||
"title", | ||
"ingress_content", | ||
"internal", | ||
"pub_date", | ||
"thumbnail", | ||
) | ||
|
||
|
||
class EventRetrieveSerializer(EventListSerializer): | ||
class Meta: | ||
model = Event | ||
fields = "__all__" |
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,9 @@ | ||
from rest_framework import serializers | ||
|
||
from news.models import EventRegistration | ||
|
||
|
||
class EventRegistrationSerializer(serializers.ModelSerializer): | ||
class Meta: | ||
model = EventRegistration | ||
fields = "__all__" |
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,9 @@ | ||
from rest_framework import serializers | ||
|
||
from news.models import Upload | ||
|
||
|
||
class UploadSerializer(serializers.ModelSerializer): | ||
class Meta: | ||
model = Upload | ||
fields = "__all__" |
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,12 +1,18 @@ | ||
from django.conf.urls import url | ||
|
||
from . import views | ||
from .views import template_views | ||
|
||
app_name = "news" | ||
urlpatterns = [ | ||
url(r"^$", views.ArticleListView.as_view(), name="all"), | ||
url(r"^(?P<pk>[0-9]+)/$", views.ArticleView.as_view(), name="details"), | ||
url(r"^(?P<pk>[0-9]+)/edit", views.ArticleUpdateView.as_view(), name="edit"), | ||
url(r"^new", views.ArticleCreateView.as_view(), name="new"), | ||
url(r"^(?P<pk>[0-9]+)/delete", views.ArticleDeleteView.as_view(), name="delete"), | ||
url(r"^$", template_views.ArticleListView.as_view(), name="all"), | ||
url(r"^(?P<pk>[0-9]+)/$", template_views.ArticleView.as_view(), name="details"), | ||
url( | ||
r"^(?P<pk>[0-9]+)/edit", template_views.ArticleUpdateView.as_view(), name="edit" | ||
), | ||
url(r"^new", template_views.ArticleCreateView.as_view(), name="new"), | ||
url( | ||
r"^(?P<pk>[0-9]+)/delete", | ||
template_views.ArticleDeleteView.as_view(), | ||
name="delete", | ||
), | ||
] |
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,14 @@ | ||
from rest_framework import viewsets | ||
|
||
from news.models import Article | ||
from news.serializers.article import ArticleListSerializer, ArticleRetrieveSerializer | ||
|
||
|
||
class ArticleViewSet(viewsets.ModelViewSet): | ||
queryset = Article.objects.all() | ||
serializer_class = ArticleListSerializer | ||
|
||
def get_serializer_class(self): | ||
if self.action == "list": | ||
return ArticleListSerializer | ||
return ArticleRetrieveSerializer |
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,14 @@ | ||
from rest_framework import viewsets | ||
|
||
from news.models import Event | ||
from news.serializers.event import EventListSerializer, EventRetrieveSerializer | ||
|
||
|
||
class EventViewSet(viewsets.ModelViewSet): | ||
queryset = Event.objects.all() | ||
serializer_class = EventListSerializer | ||
|
||
def get_serializer_class(self): | ||
if self.action == "list": | ||
return EventListSerializer | ||
return EventRetrieveSerializer |
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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
from rest_framework import viewsets | ||
|
||
from news.models import Upload | ||
from news.serializers.upload import UploadSerializer | ||
|
||
|
||
class UploadViewSet(viewsets.ModelViewSet): | ||
queryset = Upload.objects.all() | ||
serializer_class = UploadSerializer |
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,9 @@ | ||
from rest_framework import serializers | ||
|
||
from watchlist.models import ShiftSlot | ||
|
||
|
||
class ShiftSlotSerializer(serializers.ModelSerializer): | ||
class Meta: | ||
model = ShiftSlot | ||
fields = "__all__" |
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,16 +1,23 @@ | ||
from django.urls import path | ||
|
||
from . import views | ||
from website.urls import api_router | ||
|
||
from .views import shift_slot, template_views | ||
|
||
app_name = "watchlist" | ||
api_router.register("shiftslots", shift_slot.ShiftSlotViewSet) | ||
|
||
urlpatterns = [ | ||
path("", views.watchlistView.as_view(), name="vaktliste"), | ||
path("register/<int:pk>", views.WatchListRegisterView.as_view(), name="register"), | ||
path("", template_views.watchlistView.as_view(), name="vaktliste"), | ||
path( | ||
"register/<int:pk>", | ||
template_views.WatchListRegisterView.as_view(), | ||
name="register", | ||
), | ||
path( | ||
"unregister/<int:pk>", | ||
views.WatchListUnregisterView.as_view(), | ||
template_views.WatchListUnregisterView.as_view(), | ||
name="unregister", | ||
), | ||
path("reset", views.WatchListResetView.as_view(), name="reset"), | ||
path("reset", template_views.WatchListResetView.as_view(), name="reset"), | ||
] |
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,9 @@ | ||
from rest_framework import viewsets | ||
|
||
from watchlist.models import ShiftSlot | ||
from watchlist.serializers.shift_slot import ShiftSlotSerializer | ||
|
||
|
||
class ShiftSlotViewSet(viewsets.ModelViewSet): | ||
queryset = ShiftSlot.objects.all() | ||
serializer_class = ShiftSlotSerializer |
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