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

13 implement post creation endpoints #27

Merged
merged 6 commits into from
Mar 15, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@ __pycache__
.idea

api/.env

api/neurona/.env
3 changes: 2 additions & 1 deletion api/neurona/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,11 @@
"django.contrib.auth.middleware.AuthenticationMiddleware",
"django.contrib.messages.middleware.MessageMiddleware",
"django.middleware.clickjacking.XFrameOptionsMiddleware",
]
]

ROOT_URLCONF = "neurona.urls"


TEMPLATES = [
{
"BACKEND": "django.template.backends.django.DjangoTemplates",
Expand Down
2 changes: 1 addition & 1 deletion api/neurona/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@

urlpatterns = [
path("admin/", admin.site.urls),
path("api/", include("neuronaApp.urls"))
path("api/", include("neuronaApp.urls")),
]
3 changes: 2 additions & 1 deletion api/neuronaApp/serializers/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Import serializers here
from .space_serializer import SpaceSerializer
from .authentication_serializer import *
from .authentication_serializer import *
from .posts_serializer import *
12 changes: 12 additions & 0 deletions api/neuronaApp/serializers/posts_serializer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from rest_framework import serializers
from neuronaApp.models import Posts, Comments, PostsImages, CommentsImages, Votes, CommentsVotes

class PostsSerializer(serializers.ModelSerializer):
class Meta:
model = Posts
fields = '__all__'

class CommentsSerializer(serializers.ModelSerializer):
class Meta:
model = Comments
fields = '__all__'
3 changes: 3 additions & 0 deletions api/neuronaApp/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@
from rest_framework.routers import DefaultRouter

from neuronaApp import views
from neuronaApp.views import PostsViewSet, CommentsViewSet

router = DefaultRouter()
router.register(r'validity', views.Validity, basename='validity')
router.register(r'passkey-options', views.PasskeyChallengeView, basename='passkey-options')
router.register(r'posts', PostsViewSet)
router.register(r'comments', CommentsViewSet)

urlpatterns = [
path("register/", views.RegisterView.as_view(), name="register"),
Expand Down
1 change: 1 addition & 0 deletions api/neuronaApp/views/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
from .space_view import *
from .authentication_view import PasskeyChallengeView, RegisterView, LoginView
from .user_profile_view import *
from .posts_view import *
12 changes: 12 additions & 0 deletions api/neuronaApp/views/posts_view.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from django.shortcuts import render
from rest_framework import viewsets
from neuronaApp.models import Posts, Comments
from neuronaApp.serializers import PostsSerializer, CommentsSerializer

class PostsViewSet(viewsets.ModelViewSet):
queryset = Posts.objects.all()
serializer_class = PostsSerializer

class CommentsViewSet(viewsets.ModelViewSet):
queryset = Comments.objects.all()
serializer_class = CommentsSerializer