├── Pipfile ├── Pipfile.lock ├── README.md ├── backend ├── backend │ ├── __init__.py │ ├── __pycache__ │ │ ├── __init__.cpython-37.pyc │ │ ├── __init__.cpython-39.pyc │ │ ├── settings.cpython-37.pyc │ │ ├── settings.cpython-39.pyc │ │ ├── urls.cpython-37.pyc │ │ ├── urls.cpython-39.pyc │ │ ├── wsgi.cpython-37.pyc │ │ └── wsgi.cpython-39.pyc │ ├── asgi.py │ ├── settings.py │ ├── urls.py │ └── wsgi.py ├── db.sqlite3 ├── manage.py └── todo │ ├── __init__.py │ ├── __pycache__ │ ├── __init__.cpython-37.pyc │ ├── __init__.cpython-39.pyc │ ├── admin.cpython-37.pyc │ ├── admin.cpython-39.pyc │ ├── models.cpython-37.pyc │ ├── models.cpython-39.pyc │ ├── serializers.cpython-37.pyc │ ├── serializers.cpython-39.pyc │ ├── views.cpython-37.pyc │ └── views.cpython-39.pyc │ ├── admin.py │ ├── apps.py │ ├── migrations │ ├── 0001_initial.py │ ├── __init__.py │ └── __pycache__ │ │ ├── 0001_initial.cpython-37.pyc │ │ ├── 0001_initial.cpython-39.pyc │ │ ├── __init__.cpython-37.pyc │ │ └── __init__.cpython-39.pyc │ ├── models.py │ ├── serializers.py │ ├── tests.py │ └── views.py └── frontend ├── .eslintcache ├── .gitignore ├── README.md ├── package-lock.json ├── package.json ├── public ├── favicon.ico ├── index.html ├── logo192.png ├── logo512.png ├── manifest.json └── robots.txt └── src ├── App.css ├── App.js ├── components └── Modal.js ├── index.css ├── index.js └── reportWebVitals.js /Pipfile: -------------------------------------------------------------------------------- 1 | [[source]] 2 | url = "https://pypi.org/simple" 3 | verify_ssl = true 4 | name = "pypi" 5 | 6 | [packages] 7 | django = "*" 8 | djangorestframework = "*" 9 | django-cors-headers = "*" 10 | 11 | [dev-packages] 12 | 13 | [requires] 14 | python_version = "3.9" 15 | -------------------------------------------------------------------------------- /Pipfile.lock: -------------------------------------------------------------------------------- 1 | { 2 | "_meta": { 3 | "hash": { 4 | "sha256": "aa7f5fdf934909abd00a36f8171973a76fde8b5aedf710d894654e759183c202" 5 | }, 6 | "pipfile-spec": 6, 7 | "requires": { 8 | "python_version": "3.9" 9 | }, 10 | "sources": [ 11 | { 12 | "name": "pypi", 13 | "url": "https://pypi.org/simple", 14 | "verify_ssl": true 15 | } 16 | ] 17 | }, 18 | "default": { 19 | "asgiref": { 20 | "hashes": [ 21 | "sha256:5ee950735509d04eb673bd7f7120f8fa1c9e2df495394992c73234d526907e17", 22 | "sha256:7162a3cb30ab0609f1a4c95938fd73e8604f63bdba516a7f7d64b83ff09478f0" 23 | ], 24 | "markers": "python_version >= '3.5'", 25 | "version": "==3.3.1" 26 | }, 27 | "django": { 28 | "hashes": [ 29 | "sha256:2d78425ba74c7a1a74b196058b261b9733a8570782f4e2828974777ccca7edf7", 30 | "sha256:efa2ab96b33b20c2182db93147a0c3cd7769d418926f9e9f140a60dca7c64ca9" 31 | ], 32 | "index": "pypi", 33 | "version": "==3.1.5" 34 | }, 35 | "django-cors-headers": { 36 | "hashes": [ 37 | "sha256:5665fc1b1aabf1b678885cf6f8f8bd7da36ef0a978375e767d491b48d3055d8f", 38 | "sha256:ba898dd478cd4be3a38ebc3d8729fa4d044679f8c91b2684edee41129d7e968a" 39 | ], 40 | "index": "pypi", 41 | "version": "==3.6.0" 42 | }, 43 | "djangorestframework": { 44 | "hashes": [ 45 | "sha256:0209bafcb7b5010fdfec784034f059d512256424de2a0f084cb82b096d6dd6a7", 46 | "sha256:0898182b4737a7b584a2c73735d89816343369f259fea932d90dc78e35d8ac33" 47 | ], 48 | "index": "pypi", 49 | "version": "==3.12.2" 50 | }, 51 | "pytz": { 52 | "hashes": [ 53 | "sha256:16962c5fb8db4a8f63a26646d8886e9d769b6c511543557bc84e9569fb9a9cb4", 54 | "sha256:180befebb1927b16f6b57101720075a984c019ac16b1b7575673bea42c6c3da5" 55 | ], 56 | "version": "==2020.5" 57 | }, 58 | "sqlparse": { 59 | "hashes": [ 60 | "sha256:017cde379adbd6a1f15a61873f43e8274179378e95ef3fede90b5aa64d304ed0", 61 | "sha256:0f91fd2e829c44362cbcfab3e9ae12e22badaa8a29ad5ff599f9ec109f0454e8" 62 | ], 63 | "markers": "python_version >= '3.5'", 64 | "version": "==0.4.1" 65 | } 66 | }, 67 | "develop": {} 68 | } 69 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # React-Django-Task_Manager 2 | A Task Manager application created in React as the client-side and Django Rest Framework as the server-side 3 | 4 | React in a nutshell, is a JavaScript library that is great for developing single page applications (SPA) and it has solid documentation if you're interested tor read about React. 5 | 6 | And I have a react tutorial video where I explained how React works and how we can connect it to Django in order to send requests from the client to the server and return responses to the client. 7 | 8 | So React serves as the front-end , handling UI through the requests to Django's backend. 9 | 10 | The prerequistes for this project are 2 essential elements: 11 | 12 | 1- Python 3, obviously [ prefereably 3.5 and above] 13 | 14 | 2- Node.js - you can install node from nodejs.com and download it very easily, and you can check it if it was properly installed or not : node --version 15 | 16 | And we are going to start by our favorite side which is the backend , I'm saying our favorite side because this channel focuses on server-side programming and mainly Python. 17 | -------------------------------------------------------------------------------- /backend/backend/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BekBrace/django-react-app-Task_Manager/a7695294e2933fe3966905bbb8f74fe927945132/backend/backend/__init__.py -------------------------------------------------------------------------------- /backend/backend/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BekBrace/django-react-app-Task_Manager/a7695294e2933fe3966905bbb8f74fe927945132/backend/backend/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /backend/backend/__pycache__/__init__.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BekBrace/django-react-app-Task_Manager/a7695294e2933fe3966905bbb8f74fe927945132/backend/backend/__pycache__/__init__.cpython-39.pyc -------------------------------------------------------------------------------- /backend/backend/__pycache__/settings.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BekBrace/django-react-app-Task_Manager/a7695294e2933fe3966905bbb8f74fe927945132/backend/backend/__pycache__/settings.cpython-37.pyc -------------------------------------------------------------------------------- /backend/backend/__pycache__/settings.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BekBrace/django-react-app-Task_Manager/a7695294e2933fe3966905bbb8f74fe927945132/backend/backend/__pycache__/settings.cpython-39.pyc -------------------------------------------------------------------------------- /backend/backend/__pycache__/urls.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BekBrace/django-react-app-Task_Manager/a7695294e2933fe3966905bbb8f74fe927945132/backend/backend/__pycache__/urls.cpython-37.pyc -------------------------------------------------------------------------------- /backend/backend/__pycache__/urls.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BekBrace/django-react-app-Task_Manager/a7695294e2933fe3966905bbb8f74fe927945132/backend/backend/__pycache__/urls.cpython-39.pyc -------------------------------------------------------------------------------- /backend/backend/__pycache__/wsgi.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BekBrace/django-react-app-Task_Manager/a7695294e2933fe3966905bbb8f74fe927945132/backend/backend/__pycache__/wsgi.cpython-37.pyc -------------------------------------------------------------------------------- /backend/backend/__pycache__/wsgi.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BekBrace/django-react-app-Task_Manager/a7695294e2933fe3966905bbb8f74fe927945132/backend/backend/__pycache__/wsgi.cpython-39.pyc -------------------------------------------------------------------------------- /backend/backend/asgi.py: -------------------------------------------------------------------------------- 1 | """ 2 | ASGI config for backend project. 3 | 4 | It exposes the ASGI callable as a module-level variable named ``application``. 5 | 6 | For more information on this file, see 7 | https://docs.djangoproject.com/en/3.1/howto/deployment/asgi/ 8 | """ 9 | 10 | import os 11 | 12 | from django.core.asgi import get_asgi_application 13 | 14 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'backend.settings') 15 | 16 | application = get_asgi_application() 17 | -------------------------------------------------------------------------------- /backend/backend/settings.py: -------------------------------------------------------------------------------- 1 | """ 2 | Django settings for backend project. 3 | 4 | Generated by 'django-admin startproject' using Django 3.1.5. 5 | 6 | For more information on this file, see 7 | https://docs.djangoproject.com/en/3.1/topics/settings/ 8 | 9 | For the full list of settings and their values, see 10 | https://docs.djangoproject.com/en/3.1/ref/settings/ 11 | """ 12 | 13 | from pathlib import Path 14 | 15 | # Build paths inside the project like this: BASE_DIR / 'subdir'. 16 | BASE_DIR = Path(__file__).resolve().parent.parent 17 | 18 | 19 | # Quick-start development settings - unsuitable for production 20 | # See https://docs.djangoproject.com/en/3.1/howto/deployment/checklist/ 21 | 22 | # SECURITY WARNING: keep the secret key used in production secret! 23 | SECRET_KEY = 'YOUR SECRET KEY' 24 | 25 | # SECURITY WARNING: don't run with debug turned on in production! 26 | DEBUG = True 27 | 28 | ALLOWED_HOSTS = [] 29 | 30 | 31 | # Application definition 32 | 33 | INSTALLED_APPS = [ 34 | 'django.contrib.admin', 35 | 'django.contrib.auth', 36 | 'django.contrib.contenttypes', 37 | 'django.contrib.sessions', 38 | 'django.contrib.messages', 39 | 'django.contrib.staticfiles', 40 | 'todo', 41 | 'corsheaders', # add this 42 | 'rest_framework', # add this 43 | ] 44 | 45 | MIDDLEWARE = [ 46 | 'django.middleware.security.SecurityMiddleware', 47 | 'django.contrib.sessions.middleware.SessionMiddleware', 48 | 'django.middleware.common.CommonMiddleware', 49 | 'django.middleware.csrf.CsrfViewMiddleware', 50 | 'django.contrib.auth.middleware.AuthenticationMiddleware', 51 | 'django.contrib.messages.middleware.MessageMiddleware', 52 | 'django.middleware.clickjacking.XFrameOptionsMiddleware', 53 | 'corsheaders.middleware.CorsMiddleware', # add this 54 | ] 55 | 56 | ROOT_URLCONF = 'backend.urls' 57 | 58 | TEMPLATES = [ 59 | { 60 | 'BACKEND': 'django.template.backends.django.DjangoTemplates', 61 | 'DIRS': [], 62 | 'APP_DIRS': True, 63 | 'OPTIONS': { 64 | 'context_processors': [ 65 | 'django.template.context_processors.debug', 66 | 'django.template.context_processors.request', 67 | 'django.contrib.auth.context_processors.auth', 68 | 'django.contrib.messages.context_processors.messages', 69 | ], 70 | }, 71 | }, 72 | ] 73 | 74 | WSGI_APPLICATION = 'backend.wsgi.application' 75 | 76 | 77 | # Database 78 | # https://docs.djangoproject.com/en/3.1/ref/settings/#databases 79 | 80 | DATABASES = { 81 | 'default': { 82 | 'ENGINE': 'django.db.backends.sqlite3', 83 | 'NAME': BASE_DIR / 'db.sqlite3', 84 | } 85 | } 86 | 87 | 88 | # Password validation 89 | # https://docs.djangoproject.com/en/3.1/ref/settings/#auth-password-validators 90 | 91 | AUTH_PASSWORD_VALIDATORS = [ 92 | { 93 | 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', 94 | }, 95 | { 96 | 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', 97 | }, 98 | { 99 | 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', 100 | }, 101 | { 102 | 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', 103 | }, 104 | ] 105 | 106 | 107 | # Internationalization 108 | # https://docs.djangoproject.com/en/3.1/topics/i18n/ 109 | 110 | LANGUAGE_CODE = 'en-us' 111 | 112 | TIME_ZONE = 'UTC' 113 | 114 | USE_I18N = True 115 | 116 | USE_L10N = True 117 | 118 | USE_TZ = True 119 | 120 | 121 | # Static files (CSS, JavaScript, Images) 122 | # https://docs.djangoproject.com/en/3.1/howto/static-files/ 123 | 124 | STATIC_URL = '/static/' 125 | 126 | # Add this 127 | # we whitelist localhost:3000 because that's where frontend will be served 128 | CORS_ORIGIN_WHITELIST = ( 129 | 'http://localhost:3000', 130 | ) 131 | 132 | '''Django-cors-headers is a python library that will help in preventing the errors that we would normally get due to CORS. rules. In the CORS_ORIGIN_WHITELIST snippet, we whitelisted localhost:3000 because we want the frontend (which will be served on that port) of the application to interact with the API.''' 133 | -------------------------------------------------------------------------------- /backend/backend/urls.py: -------------------------------------------------------------------------------- 1 | """backend URL Configuration 2 | 3 | The `urlpatterns` list routes URLs to views. For more information please see: 4 | https://docs.djangoproject.com/en/3.1/topics/http/urls/ 5 | Examples: 6 | Function views 7 | 1. Add an import: from my_app import views 8 | 2. Add a URL to urlpatterns: path('', views.home, name='home') 9 | Class-based views 10 | 1. Add an import: from other_app.views import Home 11 | 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home') 12 | Including another URLconf 13 | 1. Import the include() function: from django.urls import include, path 14 | 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) 15 | """ 16 | from django.contrib import admin 17 | from todo import views # add this 18 | from rest_framework import routers # add this 19 | from django.urls import path, include # add this 20 | 21 | router = routers.DefaultRouter() # add this 22 | router.register(r'tasks', views.TodoView, 'task') # add this 23 | 24 | # from django.urls import path - DELETE THIS 25 | 26 | urlpatterns = [ 27 | path('admin/', admin.site.urls), 28 | path('api/', include(router.urls)) # add this 29 | ] 30 | 31 | ''' 32 | This is the final step that completes the building of the API, we can now perform CRUD operations on the todo model 33 | router allows us to do 2 things : 34 | /todo/ - this returns a list of all the Todo items (create and read operations can b done here) 35 | /todos/id - this returns a single todo item using id primary key (update and delete operations ) 36 | ''' 37 | -------------------------------------------------------------------------------- /backend/backend/wsgi.py: -------------------------------------------------------------------------------- 1 | """ 2 | WSGI config for backend project. 3 | 4 | It exposes the WSGI callable as a module-level variable named ``application``. 5 | 6 | For more information on this file, see 7 | https://docs.djangoproject.com/en/3.1/howto/deployment/wsgi/ 8 | """ 9 | 10 | import os 11 | 12 | from django.core.wsgi import get_wsgi_application 13 | 14 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'backend.settings') 15 | 16 | application = get_wsgi_application() 17 | -------------------------------------------------------------------------------- /backend/db.sqlite3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BekBrace/django-react-app-Task_Manager/a7695294e2933fe3966905bbb8f74fe927945132/backend/db.sqlite3 -------------------------------------------------------------------------------- /backend/manage.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | """Django's command-line utility for administrative tasks.""" 3 | import os 4 | import sys 5 | 6 | 7 | def main(): 8 | """Run administrative tasks.""" 9 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'backend.settings') 10 | try: 11 | from django.core.management import execute_from_command_line 12 | except ImportError as exc: 13 | raise ImportError( 14 | "Couldn't import Django. Are you sure it's installed and " 15 | "available on your PYTHONPATH environment variable? Did you " 16 | "forget to activate a virtual environment?" 17 | ) from exc 18 | execute_from_command_line(sys.argv) 19 | 20 | 21 | if __name__ == '__main__': 22 | main() 23 | -------------------------------------------------------------------------------- /backend/todo/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BekBrace/django-react-app-Task_Manager/a7695294e2933fe3966905bbb8f74fe927945132/backend/todo/__init__.py -------------------------------------------------------------------------------- /backend/todo/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BekBrace/django-react-app-Task_Manager/a7695294e2933fe3966905bbb8f74fe927945132/backend/todo/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /backend/todo/__pycache__/__init__.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BekBrace/django-react-app-Task_Manager/a7695294e2933fe3966905bbb8f74fe927945132/backend/todo/__pycache__/__init__.cpython-39.pyc -------------------------------------------------------------------------------- /backend/todo/__pycache__/admin.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BekBrace/django-react-app-Task_Manager/a7695294e2933fe3966905bbb8f74fe927945132/backend/todo/__pycache__/admin.cpython-37.pyc -------------------------------------------------------------------------------- /backend/todo/__pycache__/admin.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BekBrace/django-react-app-Task_Manager/a7695294e2933fe3966905bbb8f74fe927945132/backend/todo/__pycache__/admin.cpython-39.pyc -------------------------------------------------------------------------------- /backend/todo/__pycache__/models.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BekBrace/django-react-app-Task_Manager/a7695294e2933fe3966905bbb8f74fe927945132/backend/todo/__pycache__/models.cpython-37.pyc -------------------------------------------------------------------------------- /backend/todo/__pycache__/models.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BekBrace/django-react-app-Task_Manager/a7695294e2933fe3966905bbb8f74fe927945132/backend/todo/__pycache__/models.cpython-39.pyc -------------------------------------------------------------------------------- /backend/todo/__pycache__/serializers.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BekBrace/django-react-app-Task_Manager/a7695294e2933fe3966905bbb8f74fe927945132/backend/todo/__pycache__/serializers.cpython-37.pyc -------------------------------------------------------------------------------- /backend/todo/__pycache__/serializers.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BekBrace/django-react-app-Task_Manager/a7695294e2933fe3966905bbb8f74fe927945132/backend/todo/__pycache__/serializers.cpython-39.pyc -------------------------------------------------------------------------------- /backend/todo/__pycache__/views.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BekBrace/django-react-app-Task_Manager/a7695294e2933fe3966905bbb8f74fe927945132/backend/todo/__pycache__/views.cpython-37.pyc -------------------------------------------------------------------------------- /backend/todo/__pycache__/views.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BekBrace/django-react-app-Task_Manager/a7695294e2933fe3966905bbb8f74fe927945132/backend/todo/__pycache__/views.cpython-39.pyc -------------------------------------------------------------------------------- /backend/todo/admin.py: -------------------------------------------------------------------------------- 1 | from django.contrib import admin 2 | 3 | from .models import Todo # add this 4 | 5 | 6 | class TodoAdmin(admin.ModelAdmin): # add this 7 | list_display = ('title', 'description', 'completed') # add this 8 | 9 | 10 | # Register your models here. 11 | admin.site.register(Todo, TodoAdmin) # add this 12 | -------------------------------------------------------------------------------- /backend/todo/apps.py: -------------------------------------------------------------------------------- 1 | from django.apps import AppConfig 2 | 3 | 4 | class TodoConfig(AppConfig): 5 | name = 'todo' 6 | -------------------------------------------------------------------------------- /backend/todo/migrations/0001_initial.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 3.1.5 on 2021-01-24 16:37 2 | 3 | from django.db import migrations, models 4 | 5 | 6 | class Migration(migrations.Migration): 7 | 8 | initial = True 9 | 10 | dependencies = [ 11 | ] 12 | 13 | operations = [ 14 | migrations.CreateModel( 15 | name='Todo', 16 | fields=[ 17 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), 18 | ('title', models.CharField(max_length=120)), 19 | ('description', models.TextField()), 20 | ('completed', models.BooleanField(default=False)), 21 | ], 22 | ), 23 | ] 24 | -------------------------------------------------------------------------------- /backend/todo/migrations/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BekBrace/django-react-app-Task_Manager/a7695294e2933fe3966905bbb8f74fe927945132/backend/todo/migrations/__init__.py -------------------------------------------------------------------------------- /backend/todo/migrations/__pycache__/0001_initial.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BekBrace/django-react-app-Task_Manager/a7695294e2933fe3966905bbb8f74fe927945132/backend/todo/migrations/__pycache__/0001_initial.cpython-37.pyc -------------------------------------------------------------------------------- /backend/todo/migrations/__pycache__/0001_initial.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BekBrace/django-react-app-Task_Manager/a7695294e2933fe3966905bbb8f74fe927945132/backend/todo/migrations/__pycache__/0001_initial.cpython-39.pyc -------------------------------------------------------------------------------- /backend/todo/migrations/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BekBrace/django-react-app-Task_Manager/a7695294e2933fe3966905bbb8f74fe927945132/backend/todo/migrations/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /backend/todo/migrations/__pycache__/__init__.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BekBrace/django-react-app-Task_Manager/a7695294e2933fe3966905bbb8f74fe927945132/backend/todo/migrations/__pycache__/__init__.cpython-39.pyc -------------------------------------------------------------------------------- /backend/todo/models.py: -------------------------------------------------------------------------------- 1 | from django.db import models 2 | 3 | 4 | class Todo(models.Model): 5 | title = models.CharField(max_length=120) 6 | description = models.TextField() 7 | # completed property is the status of the task, and we will set the default to False. 8 | completed = models.BooleanField(default=False) 9 | 10 | def _str_(self): 11 | return self.title 12 | -------------------------------------------------------------------------------- /backend/todo/serializers.py: -------------------------------------------------------------------------------- 1 | '''Here we specify the model to work with and the fields we want to be converted to JSON.''' 2 | 3 | from rest_framework import serializers 4 | from .models import Todo 5 | 6 | 7 | class TodoSerializer(serializers.ModelSerializer): 8 | class Meta: 9 | model = Todo 10 | fields = ('id', 'title', 'description', 'completed') 11 | -------------------------------------------------------------------------------- /backend/todo/tests.py: -------------------------------------------------------------------------------- 1 | from django.test import TestCase 2 | 3 | # Create your tests here. 4 | -------------------------------------------------------------------------------- /backend/todo/views.py: -------------------------------------------------------------------------------- 1 | from django.shortcuts import render 2 | 3 | 4 | # viewsets class provides the implementation for CRUD operations by default, what we had to do was specify the serializer class and the query set. 5 | 6 | from rest_framework import viewsets # add this 7 | from .serializers import TodoSerializer # add this 8 | from .models import Todo # add this 9 | 10 | 11 | class TodoView(viewsets.ModelViewSet): # add this 12 | serializer_class = TodoSerializer # add this 13 | queryset = Todo.objects.all() # add this 14 | -------------------------------------------------------------------------------- /frontend/.eslintcache: -------------------------------------------------------------------------------- 1 | [{"C:\\Users\\amirb\\Desktop\\todo_app\\django_react_app\\frontend\\src\\index.js":"1","C:\\Users\\amirb\\Desktop\\todo_app\\django_react_app\\frontend\\src\\App.js":"2","C:\\Users\\amirb\\Desktop\\todo_app\\django_react_app\\frontend\\src\\reportWebVitals.js":"3","C:\\Users\\amirb\\Desktop\\todo_app\\django_react_app\\frontend\\src\\components\\Modal.js":"4"},{"size":636,"mtime":1612334980604,"results":"5","hashOfConfig":"6"},{"size":4971,"mtime":1612716024095,"results":"7","hashOfConfig":"6"},{"size":362,"mtime":1612198005934,"results":"8","hashOfConfig":"6"},{"size":2976,"mtime":1612420259043,"results":"9","hashOfConfig":"6"},{"filePath":"10","messages":"11","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"12"},"k1dvba",{"filePath":"13","messages":"14","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"15","messages":"16","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"12"},{"filePath":"17","messages":"18","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"12"},"C:\\Users\\amirb\\Desktop\\todo_app\\django_react_app\\frontend\\src\\index.js",[],["19","20"],"C:\\Users\\amirb\\Desktop\\todo_app\\django_react_app\\frontend\\src\\App.js",[],"C:\\Users\\amirb\\Desktop\\todo_app\\django_react_app\\frontend\\src\\reportWebVitals.js",[],"C:\\Users\\amirb\\Desktop\\todo_app\\django_react_app\\frontend\\src\\components\\Modal.js",[],{"ruleId":"21","replacedBy":"22"},{"ruleId":"23","replacedBy":"24"},"no-native-reassign",["25"],"no-negated-in-lhs",["26"],"no-global-assign","no-unsafe-negation"] -------------------------------------------------------------------------------- /frontend/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # production 12 | /build 13 | 14 | # misc 15 | .DS_Store 16 | .env.local 17 | .env.development.local 18 | .env.test.local 19 | .env.production.local 20 | 21 | npm-debug.log* 22 | yarn-debug.log* 23 | yarn-error.log* 24 | -------------------------------------------------------------------------------- /frontend/README.md: -------------------------------------------------------------------------------- 1 | # Getting Started with Create React App 2 | 3 | This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app). 4 | 5 | ## Available Scripts 6 | 7 | In the project directory, you can run: 8 | 9 | ### `npm start` 10 | 11 | Runs the app in the development mode.\ 12 | Open [http://localhost:3000](http://localhost:3000) to view it in the browser. 13 | 14 | The page will reload if you make edits.\ 15 | You will also see any lint errors in the console. 16 | 17 | ### `npm test` 18 | 19 | Launches the test runner in the interactive watch mode.\ 20 | See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information. 21 | 22 | ### `npm run build` 23 | 24 | Builds the app for production to the `build` folder.\ 25 | It correctly bundles React in production mode and optimizes the build for the best performance. 26 | 27 | The build is minified and the filenames include the hashes.\ 28 | Your app is ready to be deployed! 29 | 30 | See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information. 31 | 32 | ### `npm run eject` 33 | 34 | **Note: this is a one-way operation. Once you `eject`, you can’t go back!** 35 | 36 | 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. 37 | 38 | 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. 39 | 40 | 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. 41 | 42 | ## Learn More 43 | 44 | You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started). 45 | 46 | To learn React, check out the [React documentation](https://reactjs.org/). 47 | 48 | ### Code Splitting 49 | 50 | 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) 51 | 52 | ### Analyzing the Bundle Size 53 | 54 | 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) 55 | 56 | ### Making a Progressive Web App 57 | 58 | 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) 59 | 60 | ### Advanced Configuration 61 | 62 | 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) 63 | 64 | ### Deployment 65 | 66 | This section has moved here: [https://facebook.github.io/create-react-app/docs/deployment](https://facebook.github.io/create-react-app/docs/deployment) 67 | 68 | ### `npm run build` fails to minify 69 | 70 | 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) 71 | -------------------------------------------------------------------------------- /frontend/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "frontend", 3 | "version": "0.1.0", 4 | "private": true, 5 | "dependencies": { 6 | "@testing-library/jest-dom": "^5.11.9", 7 | "@testing-library/react": "^11.2.3", 8 | "@testing-library/user-event": "^12.6.2", 9 | "axios": "^0.21.1", 10 | "bootstrap": "^4.6.0", 11 | "react": "^17.0.1", 12 | "react-dom": "^17.0.1", 13 | "react-scripts": "4.0.1", 14 | "reactstrap": "^8.9.0", 15 | "web-vitals": "^0.2.4" 16 | }, 17 | "scripts": { 18 | "start": "react-scripts start", 19 | "build": "react-scripts build", 20 | "test": "react-scripts test", 21 | "eject": "react-scripts eject" 22 | }, 23 | "eslintConfig": { 24 | "extends": [ 25 | "react-app", 26 | "react-app/jest" 27 | ] 28 | }, 29 | "browserslist": { 30 | "production": [ 31 | ">0.2%", 32 | "not dead", 33 | "not op_mini all" 34 | ], 35 | "development": [ 36 | "last 1 chrome version", 37 | "last 1 firefox version", 38 | "last 1 safari version" 39 | ] 40 | } 41 | } -------------------------------------------------------------------------------- /frontend/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BekBrace/django-react-app-Task_Manager/a7695294e2933fe3966905bbb8f74fe927945132/frontend/public/favicon.ico -------------------------------------------------------------------------------- /frontend/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 12 | 13 | 17 | 18 | 27 | React App 28 | 29 | 30 | 31 |
32 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /frontend/public/logo192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BekBrace/django-react-app-Task_Manager/a7695294e2933fe3966905bbb8f74fe927945132/frontend/public/logo192.png -------------------------------------------------------------------------------- /frontend/public/logo512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BekBrace/django-react-app-Task_Manager/a7695294e2933fe3966905bbb8f74fe927945132/frontend/public/logo512.png -------------------------------------------------------------------------------- /frontend/public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "React App", 3 | "name": "Create React App Sample", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "64x64 32x32 24x24 16x16", 8 | "type": "image/x-icon" 9 | }, 10 | { 11 | "src": "logo192.png", 12 | "type": "image/png", 13 | "sizes": "192x192" 14 | }, 15 | { 16 | "src": "logo512.png", 17 | "type": "image/png", 18 | "sizes": "512x512" 19 | } 20 | ], 21 | "start_url": ".", 22 | "display": "standalone", 23 | "theme_color": "#000000", 24 | "background_color": "#ffffff" 25 | } 26 | -------------------------------------------------------------------------------- /frontend/public/robots.txt: -------------------------------------------------------------------------------- 1 | # https://www.robotstxt.org/robotstxt.html 2 | User-agent: * 3 | Disallow: 4 | -------------------------------------------------------------------------------- /frontend/src/App.css: -------------------------------------------------------------------------------- 1 | .App { 2 | text-align: center; 3 | } 4 | 5 | .App-logo { 6 | height: 40vmin; 7 | pointer-events: none; 8 | } 9 | 10 | @media (prefers-reduced-motion: no-preference) { 11 | .App-logo { 12 | animation: App-logo-spin infinite 20s linear; 13 | } 14 | } 15 | 16 | .App-header { 17 | background-color: #282c34; 18 | min-height: 100vh; 19 | display: flex; 20 | flex-direction: column; 21 | align-items: center; 22 | justify-content: center; 23 | font-size: calc(10px + 2vmin); 24 | color: white; 25 | } 26 | 27 | .App-link { 28 | color: #61dafb; 29 | } 30 | 31 | @keyframes App-logo-spin { 32 | from { 33 | transform: rotate(0deg); 34 | } 35 | to { 36 | transform: rotate(360deg); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /frontend/src/App.js: -------------------------------------------------------------------------------- 1 | import React, { Component } from "react"; 2 | import Modal from "./components/Modal"; 3 | import axios from 'axios'; 4 | 5 | class App extends Component { 6 | constructor(props) { 7 | super(props); 8 | this.state = { 9 | viewCompleted: false, 10 | activeItem: { 11 | title: "", 12 | description: "", 13 | completed: false 14 | }, 15 | taskList: [] 16 | }; 17 | } 18 | 19 | // Add componentDidMount() 20 | componentDidMount() { 21 | this.refreshList(); 22 | } 23 | 24 | 25 | refreshList = () => { 26 | axios //Axios to send and receive HTTP requests 27 | .get("http://localhost:8000/api/tasks/") 28 | .then(res => this.setState({ taskList: res.data })) 29 | .catch(err => console.log(err)); 30 | }; 31 | 32 | 33 | displayCompleted = status => { 34 | if (status) { 35 | return this.setState({ viewCompleted: true }); 36 | } 37 | return this.setState({ viewCompleted: false }); 38 | }; 39 | 40 | 41 | renderTabList = () => { 42 | return ( 43 |
44 | this.displayCompleted(true)} 46 | className={this.state.viewCompleted ? "active" : ""} 47 | > 48 | completed 49 | 50 | this.displayCompleted(false)} 52 | className={this.state.viewCompleted ? "" : "active"} 53 | > 54 | Incompleted 55 | 56 |
57 | ); 58 | }; 59 | 60 | // Main variable to render items on the screen 61 | renderItems = () => { 62 | const { viewCompleted } = this.state; 63 | const newItems = this.state.taskList.filter( 64 | item => item.completed === viewCompleted 65 | ); 66 | return newItems.map(item => ( 67 |
  • 71 | 76 | {item.title} 77 | 78 | 79 | 85 | 91 | 92 |
  • 93 | )); 94 | }; 95 | // /////////////////////////////////////////////////////////// 96 | 97 | ////add this after modal creation 98 | toggle = () => {//add this after modal creation 99 | this.setState({ modal: !this.state.modal });//add this after modal creation 100 | }; 101 | // handleSubmit = item => {//add this after modal creation 102 | // this.toggle();//add this after modal creation 103 | // alert("save" + JSON.stringify(item));//add this after modal creation 104 | // }; 105 | 106 | // Submit an item 107 | handleSubmit = item => { 108 | this.toggle(); 109 | if (item.id) { 110 | // if old post to edit and submit 111 | axios 112 | .put(`http://localhost:8000/api/tasks/${item.id}/`, item) 113 | .then(res => this.refreshList()); 114 | return; 115 | } 116 | // if new post to submit 117 | axios 118 | .post("http://localhost:8000/api/tasks/", item) 119 | .then(res => this.refreshList()); 120 | }; 121 | 122 | // Delete item 123 | handleDelete = item => { 124 | axios 125 | .delete(`http://localhost:8000/api/tasks/${item.id}/`) 126 | .then(res => this.refreshList()); 127 | }; 128 | // handleDelete = item => {//add this after modal creation 129 | // alert("delete" + JSON.stringify(item));//add this after modal creation 130 | // }; 131 | 132 | // Create item 133 | createItem = () => { 134 | const item = { title: "", description: "", completed: false }; 135 | this.setState({ activeItem: item, modal: !this.state.modal }); 136 | }; 137 | 138 | //Edit item 139 | editItem = item => { 140 | this.setState({ activeItem: item, modal: !this.state.modal }); 141 | }; 142 | 143 | 144 | // -I- Start by visual effects to viewer 145 | render() { 146 | return ( 147 |
    148 |

    Task Manager

    149 |
    150 |
    151 |
    152 |
    153 | 156 |
    157 | {this.renderTabList()} 158 |
      159 | {this.renderItems()} 160 |
    161 |
    162 |
    163 |
    164 | {this.state.modal ? ( 165 | 170 | ) : null} 171 |
    172 | ); 173 | } 174 | } 175 | export default App; 176 | -------------------------------------------------------------------------------- /frontend/src/components/Modal.js: -------------------------------------------------------------------------------- 1 | import React, { Component } from "react"; 2 | // importing all of these classes from reactstrap module 3 | import { 4 | Button, 5 | Modal, 6 | ModalHeader, 7 | ModalBody, 8 | ModalFooter, 9 | Form, 10 | FormGroup, 11 | Input, 12 | Label 13 | } from "reactstrap"; 14 | 15 | // build a class base component 16 | class CustomModal extends Component { 17 | constructor(props) { 18 | super(props); 19 | this.state = { 20 | activeItem: this.props.activeItem 21 | }; 22 | } 23 | // changes handler to check if a checkbox is checed or not 24 | handleChange = e => { 25 | let { name, value } = e.target; 26 | if (e.target.type === "checkbox") { 27 | value = e.target.checked; 28 | } 29 | const activeItem = { ...this.state.activeItem, [name]: value }; 30 | this.setState({ activeItem }); 31 | }; 32 | 33 | // rendering modal in the custommodal class received toggle and on save as props, 34 | render() { 35 | const { toggle, onSave } = this.props; 36 | return ( 37 | 38 | Task Item 39 | 40 | 41 |
    42 | 43 | {/* 3 formgroups 44 | 1 title label */} 45 | 46 | 47 | 54 | 55 | 56 | {/* 2 description label */} 57 | 58 | 59 | 66 | 67 | 68 | {/* 3 completed label */} 69 | 70 | 79 | 80 |
    81 |
    82 | {/* create a modal footer */} 83 | 84 | 87 | 88 |
    89 | ); 90 | } 91 | } 92 | export default CustomModal 93 | -------------------------------------------------------------------------------- /frontend/src/index.css: -------------------------------------------------------------------------------- 1 | body { 2 | margin: 0; 3 | padding:0; 4 | font-family: sans-serif; 5 | -webkit-font-smoothing: antialiased; 6 | background-color: rgb(5, 5, 128); 7 | } 8 | 9 | .todo-title{ 10 | cursor:pointer; 11 | } 12 | .completed-todo { 13 | text-decoration: line-through; 14 | } 15 | .tab-list > span { 16 | padding: 5px 8px; 17 | border : 1px solid rgb(5, 5, 128); 18 | border-radius:10px; 19 | margin-right:5px; 20 | cursor: pointer; 21 | } 22 | .tab-list>span.active { 23 | background-color: rgb(5, 5, 128); 24 | color:#fff; 25 | } -------------------------------------------------------------------------------- /frontend/src/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import './index.css'; 4 | import App from './App'; 5 | import reportWebVitals from './reportWebVitals'; 6 | // importing css stylesheet to use the bootstrap class 7 | import 'bootstrap/dist/css/bootstrap.min.css'; //add this line only in this file 8 | 9 | ReactDOM.render( 10 | 11 | 12 | , 13 | document.getElementById('root') 14 | ); 15 | 16 | // If you want to start measuring performance in your app, pass a function 17 | // to log results (for example: reportWebVitals(console.log)) 18 | // or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals 19 | reportWebVitals(); 20 | -------------------------------------------------------------------------------- /frontend/src/reportWebVitals.js: -------------------------------------------------------------------------------- 1 | const reportWebVitals = onPerfEntry => { 2 | if (onPerfEntry && onPerfEntry instanceof Function) { 3 | import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => { 4 | getCLS(onPerfEntry); 5 | getFID(onPerfEntry); 6 | getFCP(onPerfEntry); 7 | getLCP(onPerfEntry); 8 | getTTFB(onPerfEntry); 9 | }); 10 | } 11 | }; 12 | 13 | export default reportWebVitals; 14 | --------------------------------------------------------------------------------