-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #239 from praptisharma28/todo-react-django
Added ToDo app made on react and django
- Loading branch information
Showing
60 changed files
with
17,849 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
__pycache__/ | ||
node_modules/ | ||
db.sqlite3 | ||
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
__pycache__/ | ||
node_modules/ | ||
db.sqlite3 | ||
.env | ||
venv | ||
env |
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,8 @@ | ||
FROM python:3.9-slim | ||
|
||
WORKDIR /app | ||
COPY . . | ||
|
||
RUN pip install -r requirements.txt | ||
|
||
CMD ["python","manage.py","runserver","0.0.0.0:8000"] |
Empty file.
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,8 @@ | ||
from django.contrib import admin | ||
|
||
# Register your models here. | ||
|
||
from .models import Note | ||
|
||
|
||
admin.site.register(Note) |
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,6 @@ | ||
from django.apps import AppConfig | ||
|
||
|
||
class ApiConfig(AppConfig): | ||
default_auto_field = 'django.db.models.BigAutoField' | ||
name = 'api' |
23 changes: 23 additions & 0 deletions
23
TODO_DjangoReact/Django-React-NotesApp/api/migrations/0001_initial.py
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,23 @@ | ||
# Generated by Django 3.2.7 on 2021-09-09 14:26 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
initial = True | ||
|
||
dependencies = [ | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='Note', | ||
fields=[ | ||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('body', models.TextField(blank=True, null=True)), | ||
('updated', models.DateTimeField(auto_now=True)), | ||
('created', models.DateTimeField(auto_now_add=True)), | ||
], | ||
), | ||
] |
Empty file.
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,12 @@ | ||
from django.db import models | ||
|
||
# Create your models here. | ||
|
||
|
||
class Note(models.Model): | ||
body = models.TextField(null=True, blank=True) | ||
updated = models.DateTimeField(auto_now=True) | ||
created = models.DateTimeField(auto_now_add=True) | ||
|
||
def __str__(self): | ||
return self.body[0:50] |
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,8 @@ | ||
from rest_framework.serializers import ModelSerializer | ||
from .models import Note | ||
|
||
|
||
class NoteSerializer(ModelSerializer): | ||
class Meta: | ||
model = Note | ||
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,3 @@ | ||
from django.test import TestCase | ||
|
||
# Create your tests here. |
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,12 @@ | ||
from django.urls import path | ||
from . import views | ||
|
||
urlpatterns = [ | ||
path('', views.getRoutes, name="routes"), | ||
path('notes/', views.getNotes, name="notes"), | ||
# path('notes/create/', views.createNote, name="create-note"), | ||
#path('notes/<str:pk>/update/', views.updateNote, name="update-note"), | ||
#path('notes/<str:pk>/delete/', views.deleteNote, name="delete-note"), | ||
|
||
path('notes/<str:pk>/', views.getNote, name="note"), | ||
] |
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,40 @@ | ||
from rest_framework.response import Response | ||
from .models import Note | ||
from .serializers import NoteSerializer | ||
|
||
|
||
def getNotesList(request): | ||
notes = Note.objects.all().order_by('-updated') | ||
serializer = NoteSerializer(notes, many=True) | ||
return Response(serializer.data) | ||
|
||
|
||
def getNoteDetail(request, pk): | ||
notes = Note.objects.get(id=pk) | ||
serializer = NoteSerializer(notes, many=False) | ||
return Response(serializer.data) | ||
|
||
|
||
def createNote(request): | ||
data = request.data | ||
note = Note.objects.create( | ||
body=data['body'] | ||
) | ||
serializer = NoteSerializer(note, many=False) | ||
return Response(serializer.data) | ||
|
||
def updateNote(request, pk): | ||
data = request.data | ||
note = Note.objects.get(id=pk) | ||
serializer = NoteSerializer(instance=note, data=data) | ||
|
||
if serializer.is_valid(): | ||
serializer.save() | ||
|
||
return serializer.data | ||
|
||
|
||
def deleteNote(request, pk): | ||
note = Note.objects.get(id=pk) | ||
note.delete() | ||
return Response('Note was deleted!') |
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,106 @@ | ||
from django.http import response | ||
from django.shortcuts import render | ||
from rest_framework.response import Response | ||
from rest_framework.decorators import api_view | ||
from rest_framework.serializers import Serializer | ||
from .models import Note | ||
from .serializers import NoteSerializer | ||
from api import serializers | ||
from .utils import updateNote, getNoteDetail, deleteNote, getNotesList, createNote | ||
# Create your views here. | ||
|
||
|
||
@api_view(['GET']) | ||
def getRoutes(request): | ||
|
||
routes = [ | ||
{ | ||
'Endpoint': '/notes/', | ||
'method': 'GET', | ||
'body': None, | ||
'description': 'Returns an array of notes' | ||
}, | ||
{ | ||
'Endpoint': '/notes/id', | ||
'method': 'GET', | ||
'body': None, | ||
'description': 'Returns a single note object' | ||
}, | ||
{ | ||
'Endpoint': '/notes/create/', | ||
'method': 'POST', | ||
'body': {'body': ""}, | ||
'description': 'Creates new note with data sent in post request' | ||
}, | ||
{ | ||
'Endpoint': '/notes/id/update/', | ||
'method': 'PUT', | ||
'body': {'body': ""}, | ||
'description': 'Creates an existing note with data sent in post request' | ||
}, | ||
{ | ||
'Endpoint': '/notes/id/delete/', | ||
'method': 'DELETE', | ||
'body': None, | ||
'description': 'Deletes and exiting note' | ||
}, | ||
] | ||
return Response(routes) | ||
|
||
|
||
# /notes GET | ||
# /notes POST | ||
# /notes/<id> GET | ||
# /notes/<id> PUT | ||
# /notes/<id> DELETE | ||
|
||
@api_view(['GET', 'POST']) | ||
def getNotes(request): | ||
|
||
if request.method == 'GET': | ||
return getNotesList(request) | ||
|
||
if request.method == 'POST': | ||
return createNote(request) | ||
|
||
|
||
@api_view(['GET', 'PUT', 'DELETE']) | ||
def getNote(request, pk): | ||
|
||
if request.method == 'GET': | ||
return getNoteDetail(request, pk) | ||
|
||
if request.method == 'PUT': | ||
return updateNote(request, pk) | ||
|
||
if request.method == 'DELETE': | ||
return deleteNote(request, pk) | ||
|
||
|
||
# @api_view(['POST']) | ||
# def createNote(request): | ||
# data = request.data | ||
# note = Note.objects.create( | ||
# body=data['body'] | ||
# ) | ||
# serializer = NoteSerializer(note, many=False) | ||
# return Response(serializer.data) | ||
|
||
|
||
# @api_view(['PUT']) | ||
# def updateNote(request, pk): | ||
# data = request.data | ||
# note = Note.objects.get(id=pk) | ||
# serializer = NoteSerializer(instance=note, data=data) | ||
|
||
# if serializer.is_valid(): | ||
# serializer.save() | ||
|
||
# return Response(serializer.data) | ||
|
||
|
||
# @api_view(['DELETE']) | ||
# def deleteNote(request, pk): | ||
# note = Note.objects.get(id=pk) | ||
# note.delete() | ||
# return Response('Note was deleted!') |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,70 @@ | ||
# Getting Started with Create React App | ||
|
||
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app). | ||
|
||
## Available Scripts | ||
|
||
In the project directory, you can run: | ||
|
||
### `npm start` | ||
|
||
Runs the app in the development mode.\ | ||
Open [http://localhost:3000](http://localhost:3000) to view it in the browser. | ||
|
||
The page will reload if you make edits.\ | ||
You will also see any lint errors in the console. | ||
|
||
### `npm test` | ||
|
||
Launches the test runner in the interactive watch mode.\ | ||
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information. | ||
|
||
### `npm run build` | ||
|
||
Builds the app for production to the `build` folder.\ | ||
It correctly bundles React in production mode and optimizes the build for the best performance. | ||
|
||
The build is minified and the filenames include the hashes.\ | ||
Your app is ready to be deployed! | ||
|
||
See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information. | ||
|
||
### `npm run eject` | ||
|
||
**Note: this is a one-way operation. Once you `eject`, you can’t go back!** | ||
|
||
If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project. | ||
|
||
Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own. | ||
|
||
You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it. | ||
|
||
## Learn More | ||
|
||
You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started). | ||
|
||
To learn React, check out the [React documentation](https://reactjs.org/). | ||
|
||
### Code Splitting | ||
|
||
This section has moved here: [https://facebook.github.io/create-react-app/docs/code-splitting](https://facebook.github.io/create-react-app/docs/code-splitting) | ||
|
||
### Analyzing the Bundle Size | ||
|
||
This section has moved here: [https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size](https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size) | ||
|
||
### Making a Progressive Web App | ||
|
||
This section has moved here: [https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app](https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app) | ||
|
||
### Advanced Configuration | ||
|
||
This section has moved here: [https://facebook.github.io/create-react-app/docs/advanced-configuration](https://facebook.github.io/create-react-app/docs/advanced-configuration) | ||
|
||
### Deployment | ||
|
||
This section has moved here: [https://facebook.github.io/create-react-app/docs/deployment](https://facebook.github.io/create-react-app/docs/deployment) | ||
|
||
### `npm run build` fails to minify | ||
|
||
This section has moved here: [https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify](https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify) |
22 changes: 22 additions & 0 deletions
22
TODO_DjangoReact/Django-React-NotesApp/frontend/build/asset-manifest.json
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 @@ | ||
{ | ||
"files": { | ||
"main.css": "/static/css/main.138a22f4.chunk.css", | ||
"main.js": "/static/js/main.5b159992.chunk.js", | ||
"main.js.map": "/static/js/main.5b159992.chunk.js.map", | ||
"runtime-main.js": "/static/js/runtime-main.4eab1d6a.js", | ||
"runtime-main.js.map": "/static/js/runtime-main.4eab1d6a.js.map", | ||
"static/js/2.bbb5d1f5.chunk.js": "/static/js/2.bbb5d1f5.chunk.js", | ||
"static/js/2.bbb5d1f5.chunk.js.map": "/static/js/2.bbb5d1f5.chunk.js.map", | ||
"index.html": "/index.html", | ||
"static/css/main.138a22f4.chunk.css.map": "/static/css/main.138a22f4.chunk.css.map", | ||
"static/js/2.bbb5d1f5.chunk.js.LICENSE.txt": "/static/js/2.bbb5d1f5.chunk.js.LICENSE.txt", | ||
"static/media/add.3ceadee7.svg": "/static/media/add.3ceadee7.svg", | ||
"static/media/arrow-left.a94dd897.svg": "/static/media/arrow-left.a94dd897.svg" | ||
}, | ||
"entrypoints": [ | ||
"static/js/runtime-main.4eab1d6a.js", | ||
"static/js/2.bbb5d1f5.chunk.js", | ||
"static/css/main.138a22f4.chunk.css", | ||
"static/js/main.5b159992.chunk.js" | ||
] | ||
} |
Binary file not shown.
1 change: 1 addition & 0 deletions
1
TODO_DjangoReact/Django-React-NotesApp/frontend/build/index.html
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 @@ | ||
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="Web site created using create-react-app"/><link rel="apple-touch-icon" href="/logo192.png"/><link rel="manifest" href="/manifest.json"/><title>React App</title><link href="/static/css/main.138a22f4.chunk.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div><script>!function(e){function r(r){for(var n,f,l=r[0],i=r[1],a=r[2],c=0,s=[];c<l.length;c++)f=l[c],Object.prototype.hasOwnProperty.call(o,f)&&o[f]&&s.push(o[f][0]),o[f]=0;for(n in i)Object.prototype.hasOwnProperty.call(i,n)&&(e[n]=i[n]);for(p&&p(r);s.length;)s.shift()();return u.push.apply(u,a||[]),t()}function t(){for(var e,r=0;r<u.length;r++){for(var t=u[r],n=!0,l=1;l<t.length;l++){var i=t[l];0!==o[i]&&(n=!1)}n&&(u.splice(r--,1),e=f(f.s=t[0]))}return e}var n={},o={1:0},u=[];function f(r){if(n[r])return n[r].exports;var t=n[r]={i:r,l:!1,exports:{}};return e[r].call(t.exports,t,t.exports,f),t.l=!0,t.exports}f.m=e,f.c=n,f.d=function(e,r,t){f.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:t})},f.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},f.t=function(e,r){if(1&r&&(e=f(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var t=Object.create(null);if(f.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var n in e)f.d(t,n,function(r){return e[r]}.bind(null,n));return t},f.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return f.d(r,"a",r),r},f.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},f.p="/";var l=this.webpackJsonpfrontend=this.webpackJsonpfrontend||[],i=l.push.bind(l);l.push=r,l=l.slice();for(var a=0;a<l.length;a++)r(l[a]);var p=i;t()}([])</script><script src="/static/js/2.bbb5d1f5.chunk.js"></script><script src="/static/js/main.5b159992.chunk.js"></script></body></html> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 25 additions & 0 deletions
25
TODO_DjangoReact/Django-React-NotesApp/frontend/build/manifest.json
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,25 @@ | ||
{ | ||
"short_name": "React App", | ||
"name": "Create React App Sample", | ||
"icons": [ | ||
{ | ||
"src": "favicon.ico", | ||
"sizes": "64x64 32x32 24x24 16x16", | ||
"type": "image/x-icon" | ||
}, | ||
{ | ||
"src": "logo192.png", | ||
"type": "image/png", | ||
"sizes": "192x192" | ||
}, | ||
{ | ||
"src": "logo512.png", | ||
"type": "image/png", | ||
"sizes": "512x512" | ||
} | ||
], | ||
"start_url": ".", | ||
"display": "standalone", | ||
"theme_color": "#000000", | ||
"background_color": "#ffffff" | ||
} |
3 changes: 3 additions & 0 deletions
3
TODO_DjangoReact/Django-React-NotesApp/frontend/build/robots.txt
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,3 @@ | ||
# https://www.robotstxt.org/robotstxt.html | ||
User-agent: * | ||
Disallow: |
2 changes: 2 additions & 0 deletions
2
TODO_DjangoReact/Django-React-NotesApp/frontend/build/static/css/main.138a22f4.chunk.css
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.