From c2971d6d463e8ac89777db955c46e758fd21efa7 Mon Sep 17 00:00:00 2001 From: Pratyush Desai Date: Sat, 25 Dec 2021 04:03:45 +0530 Subject: [PATCH] initialize --- .gitignore | 2 + README.md | 0 requirements.txt | 6 + website/api/__init__.py | 0 website/api/admin.py | 3 + website/api/apps.py | 6 + website/api/migrations/__init__.py | 0 website/api/models.py | 3 + website/api/permissions.py | 0 website/api/serializers.py | 0 website/api/tests.py | 3 + website/api/views.py | 3 + website/blog/__init__.py | 0 website/blog/admin.py | 3 + website/blog/apps.py | 6 + website/blog/migrations/__init__.py | 0 website/blog/models.py | 18 +++ website/blog/permissions.py | 14 ++ website/blog/serializers.py | 10 ++ website/blog/tests.py | 3 + website/blog/urls.py | 6 + website/blog/views.py | 3 + website/manage.py | 22 ++++ website/website/__init__.py | 0 .../__pycache__/__init__.cpython-310.pyc | Bin 0 -> 148 bytes .../__pycache__/settings.cpython-310.pyc | Bin 0 -> 2272 bytes website/website/asgi.py | 16 +++ website/website/settings.py | 123 ++++++++++++++++++ website/website/urls.py | 21 +++ website/website/wsgi.py | 16 +++ 30 files changed, 287 insertions(+) create mode 100644 .gitignore create mode 100644 README.md create mode 100644 requirements.txt create mode 100644 website/api/__init__.py create mode 100644 website/api/admin.py create mode 100644 website/api/apps.py create mode 100644 website/api/migrations/__init__.py create mode 100644 website/api/models.py create mode 100644 website/api/permissions.py create mode 100644 website/api/serializers.py create mode 100644 website/api/tests.py create mode 100644 website/api/views.py create mode 100644 website/blog/__init__.py create mode 100644 website/blog/admin.py create mode 100644 website/blog/apps.py create mode 100644 website/blog/migrations/__init__.py create mode 100644 website/blog/models.py create mode 100644 website/blog/permissions.py create mode 100644 website/blog/serializers.py create mode 100644 website/blog/tests.py create mode 100644 website/blog/urls.py create mode 100644 website/blog/views.py create mode 100755 website/manage.py create mode 100644 website/website/__init__.py create mode 100644 website/website/__pycache__/__init__.cpython-310.pyc create mode 100644 website/website/__pycache__/settings.cpython-310.pyc create mode 100644 website/website/asgi.py create mode 100644 website/website/settings.py create mode 100644 website/website/urls.py create mode 100644 website/website/wsgi.py diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..04fc354 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +venv +.vscode \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..e69de29 diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..df3d464 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,6 @@ +asgiref==3.4.1 +Django==4.0 +djangorestframework==3.13.1 +psycopg2==2.9.2 +pytz==2021.3 +sqlparse==0.4.2 diff --git a/website/api/__init__.py b/website/api/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/website/api/admin.py b/website/api/admin.py new file mode 100644 index 0000000..8c38f3f --- /dev/null +++ b/website/api/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/website/api/apps.py b/website/api/apps.py new file mode 100644 index 0000000..66656fd --- /dev/null +++ b/website/api/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class ApiConfig(AppConfig): + default_auto_field = 'django.db.models.BigAutoField' + name = 'api' diff --git a/website/api/migrations/__init__.py b/website/api/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/website/api/models.py b/website/api/models.py new file mode 100644 index 0000000..71a8362 --- /dev/null +++ b/website/api/models.py @@ -0,0 +1,3 @@ +from django.db import models + +# Create your models here. diff --git a/website/api/permissions.py b/website/api/permissions.py new file mode 100644 index 0000000..e69de29 diff --git a/website/api/serializers.py b/website/api/serializers.py new file mode 100644 index 0000000..e69de29 diff --git a/website/api/tests.py b/website/api/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/website/api/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/website/api/views.py b/website/api/views.py new file mode 100644 index 0000000..91ea44a --- /dev/null +++ b/website/api/views.py @@ -0,0 +1,3 @@ +from django.shortcuts import render + +# Create your views here. diff --git a/website/blog/__init__.py b/website/blog/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/website/blog/admin.py b/website/blog/admin.py new file mode 100644 index 0000000..8c38f3f --- /dev/null +++ b/website/blog/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/website/blog/apps.py b/website/blog/apps.py new file mode 100644 index 0000000..94788a5 --- /dev/null +++ b/website/blog/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class BlogConfig(AppConfig): + default_auto_field = 'django.db.models.BigAutoField' + name = 'blog' diff --git a/website/blog/migrations/__init__.py b/website/blog/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/website/blog/models.py b/website/blog/models.py new file mode 100644 index 0000000..ff05537 --- /dev/null +++ b/website/blog/models.py @@ -0,0 +1,18 @@ +from django.db import models + + +# move to `const.py` + +STATUS = ( + (0,"Draft"), + (1,"Publish") +) +# Create your models here. + +class Post(models.Model): + title = models.CharField(max_length=200, unique=True) + author = models.ForeignKey('user.auth',on_delete=models.CASCADE) + updated_on =models.DateTimeField(auto_now= True) + created_on = models.DateTimeField(auto_now_add=True) + content = models.TextField() + # status = models.IntegerChoices() \ No newline at end of file diff --git a/website/blog/permissions.py b/website/blog/permissions.py new file mode 100644 index 0000000..f1ac3e4 --- /dev/null +++ b/website/blog/permissions.py @@ -0,0 +1,14 @@ +from rest_framework import permissions + +class IsOwnerOrReadOnly(permissions.BasePermission): + """ + Custom permission to only allow owners/authors of the object to edit it. + """ + def has_object_permission(self, request, view, obj): + # Read permissions are allowed to any request, + # so we'll always allow GET, HEAD or OPTIONS requests. + if request.method in permissions.SAFE_METHODS: + return True + + # Write permissions are only allowed to the owner of the snippet. + return obj.owner == request.user \ No newline at end of file diff --git a/website/blog/serializers.py b/website/blog/serializers.py new file mode 100644 index 0000000..e05ccc3 --- /dev/null +++ b/website/blog/serializers.py @@ -0,0 +1,10 @@ +from django.contrib.auth.models import User +from .models import * + +from rest_framework import serializers + +class PostSerializer(serializers.ModelSerializer): + class Meta: + model = Post + # better to explicitly mention the fields + fields = '__all__' \ No newline at end of file diff --git a/website/blog/tests.py b/website/blog/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/website/blog/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/website/blog/urls.py b/website/blog/urls.py new file mode 100644 index 0000000..306c8bc --- /dev/null +++ b/website/blog/urls.py @@ -0,0 +1,6 @@ +from django.urls import path +from . import views + +urlpatterns = [ + path('', views.index, name='index') +] \ No newline at end of file diff --git a/website/blog/views.py b/website/blog/views.py new file mode 100644 index 0000000..91ea44a --- /dev/null +++ b/website/blog/views.py @@ -0,0 +1,3 @@ +from django.shortcuts import render + +# Create your views here. diff --git a/website/manage.py b/website/manage.py new file mode 100755 index 0000000..ac2f90c --- /dev/null +++ b/website/manage.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python +"""Django's command-line utility for administrative tasks.""" +import os +import sys + + +def main(): + """Run administrative tasks.""" + os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'website.settings') + try: + from django.core.management import execute_from_command_line + except ImportError as exc: + raise ImportError( + "Couldn't import Django. Are you sure it's installed and " + "available on your PYTHONPATH environment variable? Did you " + "forget to activate a virtual environment?" + ) from exc + execute_from_command_line(sys.argv) + + +if __name__ == '__main__': + main() diff --git a/website/website/__init__.py b/website/website/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/website/website/__pycache__/__init__.cpython-310.pyc b/website/website/__pycache__/__init__.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..70489299b46bb2e807fffb121f421fa6a5f9a73b GIT binary patch literal 148 zcmd1j<>g`k0&&k{i6Hthh(HF6K#l_t7qb9~6oz01O-8?!3`HPe1o6vUKO;XkRX;aB zJu$@~Pd`1gL_a54zdSW5CAADh6=#;D!s+<<%)HE!_;|g7%3B;Zx%nxjIjMFa1B;n} H1PcQInSvnr literal 0 HcmV?d00001 diff --git a/website/website/__pycache__/settings.cpython-310.pyc b/website/website/__pycache__/settings.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..98981f77e30bbcd1c5fd6206b953de59fae5d080 GIT binary patch literal 2272 zcmb7FTXWk)6qXeE64!3iq-{z&Fk%=eE<|dZ^a4Xm6Q?Q# zY4pl};HeML2WI#q{0P1B#2?^+VJJtkop_wi5S(atbuQmI`|UZauvV*Z@LO&DX8%~_ zxZksv*YU_fdO$Qhj=7-yf2sn&tU;C{J{St{>&W|4hm)wEtn-Fnq`+W7hMh& z-tcAx<|54JP|2(!&>#_Iy2=}#@aWuY(dEq=s+#9f4V}kDbm2OOmR<{lH!q-zXc=rS zqLqBSl#iDQ?~3LUx?)~LtL8F9TY={ix@ulV@0nN7HJz(pw{P+sS7{#Dfg4H`Ge!cJ zO8a3f9pV8c3`Nl#j(GTUh>j~m#v=NqqM*>B@;JgYz7zTi4itb>SQrt9 zD${h8F+3Y$X@BH-l1C_$!u^x&*a3n-n8eac+Z$o}e`3XWeVPsN_ihRNoH z0}@c|jAFbt48MPP`-^)Iy^Z_9`rS|N#p`!{|D)i}UB``Xv*E`ZM|VDCuht&KR!oCEqV)+v9zL{VEa&?q>`2zL4Z~vRSeIpXH4(ULRF?;V@) zi1YlwcAi5k$lq?owvW3}R`qnouR3Wmc@%pzQ6?x1`;iBICJ(?J2WZ*}ax-r^W1^tgchJj`h;8R5amO>UmSGR7~UV_5Rp#P+yIGe+NmoH3oO&lw-H z_zs7ut}dpfO||h<>oiTV+1l09vfAre`Kr|I8Le(dPp(c0JESg=?I;44^CL`42=Ch? zj~&-E8l3P)UwCkpttS-_PS$lHEoz+!R-_#g5P#&iap1DyiT~GU^&huMZ<6B)z~i$5 zbVfdoiE|pEfP=LWH5d9uBPqcR5AC8P?@wTXNk2r`qw*$kp`F4lf<4r!ucjr-g6rF| z(ozJMq(=s^0Mw>s%gQd6OdewzdM|NWjNncQm|5ObbuByTw4!T`UCpqbYTu=WrncGN zPHSqr-QClg)|0Mo=;`@ZM>jwO0w@nXt?aa#&9=6u?rLdux7#(W{%*U`?QErshPKmd ztA?hhOMCiuE30(ng)GVx?URC?X6RW4{`d)XpX+2ZhEl_r$0Bdcvv)xy> zHLKBWY5>^U(JZqIB~$K0!mZm6I%zRm875?I0CFRXo-Q}FEw$e^EI{sBTP>~K{FRG8 z02cD$ulvd{^s(ZHu8nR5ic6T{ISQ0E!Y{Ka`|cjk)32Ny9i`>3fb)@uAHhePqu;;t4M4?