-
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.
created crud apis for attendance, events, post and cmments
- Loading branch information
Showing
10 changed files
with
117 additions
and
8 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 |
---|---|---|
@@ -1,9 +1,13 @@ | ||
from rest_framework.routers import DefaultRouter | ||
from django.urls import path, include | ||
from .views import AttendanceListCreateAPIView, AttendanceRetrieveAPIView | ||
from .views import AttendanceListCreateAPIView, AttendanceRetrieveAPIView, AttendanceUpdateAPIView, AttendanceDestroyAPIView | ||
|
||
urlpatterns = [ | ||
path('<int:pk>/', AttendanceRetrieveAPIView.as_view(), | ||
path('<uuid:pk>/', AttendanceRetrieveAPIView.as_view(), | ||
name="attendance_detail"), | ||
path('<uuid:pk>/', AttendanceUpdateAPIView.as_view(), | ||
name="attendance_update"), | ||
path('<uuid:pk>/', AttendanceDestroyAPIView.as_view(), | ||
name="attendance_delete"), | ||
path('', AttendanceListCreateAPIView.as_view(), name="attendance_list") | ||
] |
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,20 @@ | ||
# django #selenium #webscraping | ||
from rest_framework import serializers | ||
from django.contrib.auth.models import User, Group | ||
from .models import Post, Comment | ||
|
||
|
||
class PostSerializer(serializers.ModelSerializer): | ||
class Meta: | ||
model = Post | ||
# fields = ('id', 'title', 'description', 'completed') | ||
# Shortcut for getting all fields | ||
fields = '__all__' | ||
|
||
|
||
class CommentSerializer(serializers.ModelSerializer): | ||
class Meta: | ||
model = Comment | ||
# fields = ('id', 'title', 'description', 'completed') | ||
# Shortcut for getting all fields | ||
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,17 @@ | ||
from django.urls import path, include | ||
from .views import PostListCreateAPIView, PostRetrieveAPIView, PostDestroyAPIView, PostUpdateAPIView, CommentListCreateAPIView, CommentRetrieveAPIView, CommentDestroyAPIView, CommentUpdateAPIView | ||
|
||
urlpatterns = [ | ||
path('posts/<uuid:pk>/', PostRetrieveAPIView.as_view(), | ||
name="Post_detail"), | ||
path('posts/', PostListCreateAPIView.as_view(), name="post_list"), | ||
path('posts/<uuid:pk>/', PostUpdateAPIView.as_view(), name="post_update"), | ||
path('posts/<uuid:pk>/', PostDestroyAPIView.as_view(), | ||
name="post_delete"), | ||
path('coments/<uuid:pk>/', CommentRetrieveAPIView.as_view(), | ||
name="comment_detail"), | ||
path('coments/', CommentListCreateAPIView.as_view(), name="comment_list"), | ||
path('coments/<uuid:pk>/', CommentUpdateAPIView.as_view(), name="comment_update"), | ||
path('coments/<uuid:pk>/', CommentDestroyAPIView.as_view(), | ||
name="event_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 |
---|---|---|
@@ -1,3 +1,46 @@ | ||
from django.shortcuts import render | ||
from .models import Post, Comment | ||
from .serializers import PostSerializer, CommentSerializer | ||
from rest_framework import generics | ||
|
||
# Create your views here. | ||
|
||
# Post serializer | ||
|
||
class PostListCreateAPIView(generics.ListCreateAPIView): | ||
queryset = Post.objects.all() | ||
serializer_class = PostSerializer | ||
|
||
|
||
class PostRetrieveAPIView(generics.RetrieveAPIView): | ||
queryset = Post.objects.all() | ||
serializer_class = PostSerializer | ||
|
||
|
||
class PostUpdateAPIView(generics.UpdateAPIView): | ||
queryset = Post.objects.all() | ||
serializer_class = PostSerializer | ||
|
||
|
||
class PostDestroyAPIView(generics.DestroyAPIView): | ||
queryset = Post.objects.all() | ||
serializer_class = PostSerializer | ||
|
||
|
||
# Commment serializer | ||
class CommentListCreateAPIView(generics.ListCreateAPIView): | ||
queryset = Comment.objects.all() | ||
serializer_class = CommentSerializer | ||
|
||
|
||
class CommentRetrieveAPIView(generics.RetrieveAPIView): | ||
queryset = Comment.objects.all() | ||
serializer_class = CommentSerializer | ||
|
||
|
||
class CommentUpdateAPIView(generics.UpdateAPIView): | ||
queryset = Comment.objects.all() | ||
serializer_class = CommentSerializer | ||
|
||
|
||
class CommentDestroyAPIView(generics.DestroyAPIView): | ||
queryset = Comment.objects.all() | ||
serializer_class = CommentSerializer |
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
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,8 +1,11 @@ | ||
from django.urls import path, include | ||
from .views import EventListCreateAPIView, EventRetrieveAPIView | ||
from .views import EventListCreateAPIView, EventRetrieveAPIView, EventDestroyAPIView, EventUpdateAPIView | ||
|
||
urlpatterns = [ | ||
path('<int:pk>/', EventRetrieveAPIView.as_view(), | ||
path('<uuid:pk>/', EventRetrieveAPIView.as_view(), | ||
name="event_detail"), | ||
path('', EventListCreateAPIView.as_view(), name="event_list") | ||
path('', EventListCreateAPIView.as_view(), name="event_list"), | ||
path('<uuid:pk>/', EventUpdateAPIView.as_view(), name="event_update"), | ||
path('<uuid:pk>/', EventDestroyAPIView.as_view(), | ||
name="event_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
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 |
---|---|---|
|
@@ -22,3 +22,4 @@ | |
- Email marketing | ||
- Live streeming | ||
- schedule meetings | ||
- Video and audio for sermons |