From 3ec547e65d104b9ad00f9cf9aba251468394f650 Mon Sep 17 00:00:00 2001 From: HARSH Date: Fri, 10 May 2024 14:03:36 +0530 Subject: [PATCH] Adding new To Do app 1. Authentication - uses django auth User for new user registration and login. 2. Items - uses sqllite3 to perform CRUD operation on users tasks/notes. 3. Temaplates - contaions html files --- To-Do_app/Pipfile | 12 ++ To-Do_app/Pipfile.lock | 62 +++++++ To-Do_app/ToDo_app/Authentication/__init__.py | 0 To-Do_app/ToDo_app/Authentication/admin.py | 3 + To-Do_app/ToDo_app/Authentication/apps.py | 6 + .../Authentication/migrations/__init__.py | 0 To-Do_app/ToDo_app/Authentication/models.py | 3 + To-Do_app/ToDo_app/Authentication/tests.py | 3 + To-Do_app/ToDo_app/Authentication/urls.py | 13 ++ To-Do_app/ToDo_app/Authentication/views.py | 85 +++++++++ To-Do_app/ToDo_app/Items/__init__.py | 0 To-Do_app/ToDo_app/Items/admin.py | 3 + To-Do_app/ToDo_app/Items/apps.py | 6 + .../ToDo_app/Items/migrations/0001_initial.py | 38 ++++ .../Items/migrations/0002_alter_items_date.py | 19 ++ .../Items/migrations/0003_alter_items_date.py | 18 ++ .../Items/migrations/0004_items_status.py | 18 ++ .../ToDo_app/Items/migrations/__init__.py | 0 To-Do_app/ToDo_app/Items/models.py | 28 +++ To-Do_app/ToDo_app/Items/tests.py | 3 + To-Do_app/ToDo_app/Items/urls.py | 10 ++ To-Do_app/ToDo_app/Items/views.py | 120 +++++++++++++ To-Do_app/ToDo_app/ToDo_app/__init__.py | 0 To-Do_app/ToDo_app/ToDo_app/asgi.py | 16 ++ To-Do_app/ToDo_app/ToDo_app/settings.py | 136 +++++++++++++++ To-Do_app/ToDo_app/ToDo_app/urls.py | 25 +++ To-Do_app/ToDo_app/ToDo_app/wsgi.py | 16 ++ To-Do_app/ToDo_app/manage.py | 22 +++ .../templates/Authentication/login.html | 22 +++ .../templates/Authentication/register.html | 29 ++++ .../ToDo_app/templates/Items/addItems.html | 43 +++++ To-Do_app/ToDo_app/templates/Items/index.html | 164 ++++++++++++++++++ To-Do_app/ToDo_app/templates/base.html | 77 ++++++++ To-Do_app/ToDo_app/templates/nav.html | 28 +++ To-Do_app/requirement.txt | Bin 0 -> 6578 bytes 35 files changed, 1028 insertions(+) create mode 100644 To-Do_app/Pipfile create mode 100644 To-Do_app/Pipfile.lock create mode 100644 To-Do_app/ToDo_app/Authentication/__init__.py create mode 100644 To-Do_app/ToDo_app/Authentication/admin.py create mode 100644 To-Do_app/ToDo_app/Authentication/apps.py create mode 100644 To-Do_app/ToDo_app/Authentication/migrations/__init__.py create mode 100644 To-Do_app/ToDo_app/Authentication/models.py create mode 100644 To-Do_app/ToDo_app/Authentication/tests.py create mode 100644 To-Do_app/ToDo_app/Authentication/urls.py create mode 100644 To-Do_app/ToDo_app/Authentication/views.py create mode 100644 To-Do_app/ToDo_app/Items/__init__.py create mode 100644 To-Do_app/ToDo_app/Items/admin.py create mode 100644 To-Do_app/ToDo_app/Items/apps.py create mode 100644 To-Do_app/ToDo_app/Items/migrations/0001_initial.py create mode 100644 To-Do_app/ToDo_app/Items/migrations/0002_alter_items_date.py create mode 100644 To-Do_app/ToDo_app/Items/migrations/0003_alter_items_date.py create mode 100644 To-Do_app/ToDo_app/Items/migrations/0004_items_status.py create mode 100644 To-Do_app/ToDo_app/Items/migrations/__init__.py create mode 100644 To-Do_app/ToDo_app/Items/models.py create mode 100644 To-Do_app/ToDo_app/Items/tests.py create mode 100644 To-Do_app/ToDo_app/Items/urls.py create mode 100644 To-Do_app/ToDo_app/Items/views.py create mode 100644 To-Do_app/ToDo_app/ToDo_app/__init__.py create mode 100644 To-Do_app/ToDo_app/ToDo_app/asgi.py create mode 100644 To-Do_app/ToDo_app/ToDo_app/settings.py create mode 100644 To-Do_app/ToDo_app/ToDo_app/urls.py create mode 100644 To-Do_app/ToDo_app/ToDo_app/wsgi.py create mode 100644 To-Do_app/ToDo_app/manage.py create mode 100644 To-Do_app/ToDo_app/templates/Authentication/login.html create mode 100644 To-Do_app/ToDo_app/templates/Authentication/register.html create mode 100644 To-Do_app/ToDo_app/templates/Items/addItems.html create mode 100644 To-Do_app/ToDo_app/templates/Items/index.html create mode 100644 To-Do_app/ToDo_app/templates/base.html create mode 100644 To-Do_app/ToDo_app/templates/nav.html create mode 100644 To-Do_app/requirement.txt diff --git a/To-Do_app/Pipfile b/To-Do_app/Pipfile new file mode 100644 index 0000000..a6c4430 --- /dev/null +++ b/To-Do_app/Pipfile @@ -0,0 +1,12 @@ +[[source]] +url = "https://pypi.org/simple" +verify_ssl = true +name = "pypi" + +[packages] +django = "*" + +[dev-packages] + +[requires] +python_version = "3.10" diff --git a/To-Do_app/Pipfile.lock b/To-Do_app/Pipfile.lock new file mode 100644 index 0000000..a9359d0 --- /dev/null +++ b/To-Do_app/Pipfile.lock @@ -0,0 +1,62 @@ +{ + "_meta": { + "hash": { + "sha256": "7e6dca07b964c2888324e576ba6c1bc240d74a27b75619fc88bca2ee3979baf8" + }, + "pipfile-spec": 6, + "requires": { + "python_version": "3.10" + }, + "sources": [ + { + "name": "pypi", + "url": "https://pypi.org/simple", + "verify_ssl": true + } + ] + }, + "default": { + "asgiref": { + "hashes": [ + "sha256:3e1e3ecc849832fe52ccf2cb6686b7a55f82bb1d6aee72a58826471390335e47", + "sha256:c343bd80a0bec947a9860adb4c432ffa7db769836c64238fc34bdc3fec84d590" + ], + "markers": "python_version >= '3.8'", + "version": "==3.8.1" + }, + "django": { + "hashes": [ + "sha256:8af4f166dc9a2bb822f9374cd78e34a10c286b402597fe2c7fb97c131656ba65", + "sha256:dc95c9cb2a37ba54599d9d1c8faf81609d36f3e74cd04395ce1300573e57baf9" + ], + "index": "pypi", + "markers": "python_version >= '3.10'", + "version": "==5.0.5" + }, + "sqlparse": { + "hashes": [ + "sha256:714d0a4932c059d16189f58ef5411ec2287a4360f17cdd0edd2d09d4c5087c93", + "sha256:c204494cd97479d0e39f28c93d46c0b2d5959c7b9ab904762ea6c7af211c8663" + ], + "markers": "python_version >= '3.8'", + "version": "==0.5.0" + }, + "typing-extensions": { + "hashes": [ + "sha256:83f085bd5ca59c80295fc2a82ab5dac679cbe02b9f33f7d83af68e241bea51b0", + "sha256:c1f94d72897edaf4ce775bb7558d5b79d8126906a14ea5ed1635921406c0387a" + ], + "markers": "python_version < '3.11'", + "version": "==4.11.0" + }, + "tzdata": { + "hashes": [ + "sha256:2674120f8d891909751c38abcdfd386ac0a5a1127954fbc332af6b5ceae07efd", + "sha256:9068bc196136463f5245e51efda838afa15aaeca9903f49050dfa2679db4d252" + ], + "markers": "sys_platform == 'win32'", + "version": "==2024.1" + } + }, + "develop": {} +} diff --git a/To-Do_app/ToDo_app/Authentication/__init__.py b/To-Do_app/ToDo_app/Authentication/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/To-Do_app/ToDo_app/Authentication/admin.py b/To-Do_app/ToDo_app/Authentication/admin.py new file mode 100644 index 0000000..8c38f3f --- /dev/null +++ b/To-Do_app/ToDo_app/Authentication/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/To-Do_app/ToDo_app/Authentication/apps.py b/To-Do_app/ToDo_app/Authentication/apps.py new file mode 100644 index 0000000..dcc48d9 --- /dev/null +++ b/To-Do_app/ToDo_app/Authentication/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class AuthenticationConfig(AppConfig): + default_auto_field = 'django.db.models.BigAutoField' + name = 'Authentication' diff --git a/To-Do_app/ToDo_app/Authentication/migrations/__init__.py b/To-Do_app/ToDo_app/Authentication/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/To-Do_app/ToDo_app/Authentication/models.py b/To-Do_app/ToDo_app/Authentication/models.py new file mode 100644 index 0000000..71a8362 --- /dev/null +++ b/To-Do_app/ToDo_app/Authentication/models.py @@ -0,0 +1,3 @@ +from django.db import models + +# Create your models here. diff --git a/To-Do_app/ToDo_app/Authentication/tests.py b/To-Do_app/ToDo_app/Authentication/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/To-Do_app/ToDo_app/Authentication/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/To-Do_app/ToDo_app/Authentication/urls.py b/To-Do_app/ToDo_app/Authentication/urls.py new file mode 100644 index 0000000..46eec57 --- /dev/null +++ b/To-Do_app/ToDo_app/Authentication/urls.py @@ -0,0 +1,13 @@ +from django.urls import path +from .views import ( + RegistrationView, + UserLoginView, + UserLogoutView, +) + +urlpatterns = [ + # django always checks for cross site forgery so we add csrf_exempt to let other sites send reuest to this url + path("registration", RegistrationView.as_view(), name="registration"), + path("userlogin", UserLoginView.as_view(), name="login"), + path("userlogout", UserLogoutView.as_view(), name="logout"), +] diff --git a/To-Do_app/ToDo_app/Authentication/views.py b/To-Do_app/ToDo_app/Authentication/views.py new file mode 100644 index 0000000..886f229 --- /dev/null +++ b/To-Do_app/ToDo_app/Authentication/views.py @@ -0,0 +1,85 @@ +import json +from django.shortcuts import render, redirect +from django.views import View +from django.http import JsonResponse +from django.contrib.auth.models import User +from django.db import transaction +from django.contrib import messages +from django.contrib.auth import login, logout, authenticate + + +# Create your views here. +class RegistrationView(View): + def get(self, request): + messages.get_messages(request) + return render(request, "authentication/register.html") + + def post(self, request): + + # get user data + data = request.POST + username = data.get("username") + email = data.get("email") + password = data.get("password") + + context = {"fieldValues": request.POST} + + # validate + if not User.objects.filter(username=username).exists(): + if not User.objects.filter(email=email).exists(): + if len(password) < 8: + messages.error(request, "Password should be 8 charecter long") + return render(request, "authentication/register.html", context) + else: + # new nuser creation process + try: + # adding user to data base + user = User.objects.create_user(username=username, email=email) + user.set_password(password) + user.save() + transaction.commit() + messages.success(request, "Account created") + except Exception as e: + messages.error(request, f"Server - Database warning {str(e)}") + transaction.rollback() + else: + messages.error(request, "Email already exists") + return render(request, "authentication/register.html", context) + else: + messages.error(request, "User name already exists") + return render(request, "authentication/register.html", context) + + return redirect("login") + + +class UserLoginView(View): + def get(self, request): + return render(request, "authentication/login.html") + + def post(self, request): + data = request.POST + username = data.get("username") + password = data.get("password") + + if username and password: + user = authenticate(username=username, password=password) + if user: + if user.is_active: + login(request, user) + messages.success(request, "Logged in successfully.") + return redirect("index") # Redirect to the expenses page + else: + messages.error(request, "Your account is not active.") + else: + messages.error(request, "Invalid username or password.") + else: + messages.error(request, "Please provide both username and password.") + + return redirect("login") + + +class UserLogoutView(View): + def get(self, request): + logout(request) + messages.success(request, "Logout successfully.") + return redirect("login") diff --git a/To-Do_app/ToDo_app/Items/__init__.py b/To-Do_app/ToDo_app/Items/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/To-Do_app/ToDo_app/Items/admin.py b/To-Do_app/ToDo_app/Items/admin.py new file mode 100644 index 0000000..8c38f3f --- /dev/null +++ b/To-Do_app/ToDo_app/Items/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/To-Do_app/ToDo_app/Items/apps.py b/To-Do_app/ToDo_app/Items/apps.py new file mode 100644 index 0000000..6311ed5 --- /dev/null +++ b/To-Do_app/ToDo_app/Items/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class ItemsConfig(AppConfig): + default_auto_field = 'django.db.models.BigAutoField' + name = 'Items' diff --git a/To-Do_app/ToDo_app/Items/migrations/0001_initial.py b/To-Do_app/ToDo_app/Items/migrations/0001_initial.py new file mode 100644 index 0000000..7445fff --- /dev/null +++ b/To-Do_app/ToDo_app/Items/migrations/0001_initial.py @@ -0,0 +1,38 @@ +# Generated by Django 5.0.5 on 2024-05-07 09:36 + +import django.db.models.deletion +import django.utils.timezone +from django.conf import settings +from django.db import migrations, models + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + migrations.swappable_dependency(settings.AUTH_USER_MODEL), + ] + + operations = [ + migrations.CreateModel( + name='Category', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('name', models.CharField(max_length=255)), + ], + ), + migrations.CreateModel( + name='Items', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('date', models.DateField(default=django.utils.timezone.now, null=True)), + ('description', models.TextField(null=True)), + ('category', models.CharField(max_length=100)), + ('owner', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), + ], + options={ + 'ordering': ['-date'], + }, + ), + ] diff --git a/To-Do_app/ToDo_app/Items/migrations/0002_alter_items_date.py b/To-Do_app/ToDo_app/Items/migrations/0002_alter_items_date.py new file mode 100644 index 0000000..64e88cc --- /dev/null +++ b/To-Do_app/ToDo_app/Items/migrations/0002_alter_items_date.py @@ -0,0 +1,19 @@ +# Generated by Django 5.0.5 on 2024-05-07 17:08 + +import datetime +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('Items', '0001_initial'), + ] + + operations = [ + migrations.AlterField( + model_name='items', + name='date', + field=models.DateField(default=datetime.date.today, null=True), + ), + ] diff --git a/To-Do_app/ToDo_app/Items/migrations/0003_alter_items_date.py b/To-Do_app/ToDo_app/Items/migrations/0003_alter_items_date.py new file mode 100644 index 0000000..d8e84e6 --- /dev/null +++ b/To-Do_app/ToDo_app/Items/migrations/0003_alter_items_date.py @@ -0,0 +1,18 @@ +# Generated by Django 5.0.5 on 2024-05-07 17:14 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('Items', '0002_alter_items_date'), + ] + + operations = [ + migrations.AlterField( + model_name='items', + name='date', + field=models.DateField(null=True), + ), + ] diff --git a/To-Do_app/ToDo_app/Items/migrations/0004_items_status.py b/To-Do_app/ToDo_app/Items/migrations/0004_items_status.py new file mode 100644 index 0000000..972f8af --- /dev/null +++ b/To-Do_app/ToDo_app/Items/migrations/0004_items_status.py @@ -0,0 +1,18 @@ +# Generated by Django 5.0.5 on 2024-05-07 20:08 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('Items', '0003_alter_items_date'), + ] + + operations = [ + migrations.AddField( + model_name='items', + name='status', + field=models.BooleanField(default=False), + ), + ] diff --git a/To-Do_app/ToDo_app/Items/migrations/__init__.py b/To-Do_app/ToDo_app/Items/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/To-Do_app/ToDo_app/Items/models.py b/To-Do_app/ToDo_app/Items/models.py new file mode 100644 index 0000000..57b28dc --- /dev/null +++ b/To-Do_app/ToDo_app/Items/models.py @@ -0,0 +1,28 @@ +from django.db import models +from django.contrib.auth.models import User + +# Create your models here. + + +class Items(models.Model): + date = models.DateField(null=True) + description = models.TextField(null=True) + owner = models.ForeignKey(to=User, on_delete=models.CASCADE) + status = models.BooleanField(default=False) + category = models.CharField(max_length=100) + + def get_formatted_date(self): + return self.date.strftime("%Y-%m-%d") if self.date else None + + def __str__(self): + return (str(self.owner) +" " + str(self.source)) + + class Meta: + ordering = ["-date"] + + +class Category(models.Model): + name = models.CharField(max_length=255) + + def __str__(self): + return self.name diff --git a/To-Do_app/ToDo_app/Items/tests.py b/To-Do_app/ToDo_app/Items/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/To-Do_app/ToDo_app/Items/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/To-Do_app/ToDo_app/Items/urls.py b/To-Do_app/ToDo_app/Items/urls.py new file mode 100644 index 0000000..cb574c9 --- /dev/null +++ b/To-Do_app/ToDo_app/Items/urls.py @@ -0,0 +1,10 @@ +from django.urls import path +from . import views + +urlpatterns = [ + path("", views.index, name="index"), + path("addItems", views.addItems, name="addItems"), + path("deleteItems", views.deleteItems, name="deleteItems"), + path("updateItems", views.updateItems, name="updateItems"), + path("statusItems", views.statusItems, name="statusItems"), +] diff --git a/To-Do_app/ToDo_app/Items/views.py b/To-Do_app/ToDo_app/Items/views.py new file mode 100644 index 0000000..2ab6605 --- /dev/null +++ b/To-Do_app/ToDo_app/Items/views.py @@ -0,0 +1,120 @@ +from django.shortcuts import render, redirect +from django.http import JsonResponse +from django.contrib.auth.decorators import login_required +from .models import Items, Category +from django.contrib import messages +from django.core.paginator import Paginator +import json + +existingCategory = Category.objects.all() + + +@login_required(login_url="login") +def index(request): + data = Items.objects.filter(owner=request.user) + paginator = Paginator(data, 6) + page_number = request.GET.get("page") + page_obj = Paginator.get_page(paginator, page_number) + return render( + request, + "Items/index.html", + {"categories": existingCategory, "values": data, "page_obj": page_obj}, + ) + + +@login_required(login_url="login") +def addItems(request): + viewName = "addItems" + data = request.POST + + if request.method == "POST": + description = data.get("description") + category = data.get("category") + date = data.get("date") + owner = request.user + newTopic = None + newTopic = Items.objects.create( + owner=owner, + date=date, + category=category, + description=description, + ) + newTopic.save() + messages.success(request, "New Tasks added") + return redirect("index") + + return render( + request, + "Items/addItems.html", + {"categories": existingCategory, "values": data, "viewName": viewName}, + ) + + +@login_required(login_url="login") +def updateItems(request): + viewname = "updateItems" + existingCategory = Category.objects.all() + if request.method == "GET": + op = request.GET + pk = op.get("update") + items = Items.objects.get(id=pk) + return render( + request, + "Items/addItems.html", + {"categories": existingCategory, "values": items, "viewName": viewname}, + ) + else: + if request.method == "POST": + data = request.POST + pk = data.get("update") + items = Items.objects.get(id=pk) + + description = data.get("description") + category = data.get("category") + date = data.get("date") + if category: + items.description = description + items.category = category + items.date = date + messages.success(request, "Task updated") + items.save() + return redirect("index") + else: + messages.warning(request, "Category is required") + return render( + request, + "Items/addItems.html", + { + "categories": existingCategory, + "values": items, + "viewName": viewname, + }, + ) + + return redirect("index") + + +@login_required(login_url="login") +def deleteItems(request): + + print("Entered delete") + if request.method == "POST": + op = request.POST + pk = op.get("delete") + items = Items.objects.get(id=pk) + items.delete() + messages.info(request, "Task deleted") + return redirect("index") + + +def statusItems(request): + if request.method == "POST": + data = json.loads(request.body) + pk = data.get("id") + status = data.get("status") + items = Items.objects.get(id=pk) + items.status = status + items.save() + + messages.success(request,"Status updated") + return JsonResponse({"message": "Status updated"}, status=200) diff --git a/To-Do_app/ToDo_app/ToDo_app/__init__.py b/To-Do_app/ToDo_app/ToDo_app/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/To-Do_app/ToDo_app/ToDo_app/asgi.py b/To-Do_app/ToDo_app/ToDo_app/asgi.py new file mode 100644 index 0000000..c707b2c --- /dev/null +++ b/To-Do_app/ToDo_app/ToDo_app/asgi.py @@ -0,0 +1,16 @@ +""" +ASGI config for ToDo_app project. + +It exposes the ASGI callable as a module-level variable named ``application``. + +For more information on this file, see +https://docs.djangoproject.com/en/5.0/howto/deployment/asgi/ +""" + +import os + +from django.core.asgi import get_asgi_application + +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'ToDo_app.settings') + +application = get_asgi_application() diff --git a/To-Do_app/ToDo_app/ToDo_app/settings.py b/To-Do_app/ToDo_app/ToDo_app/settings.py new file mode 100644 index 0000000..4ee0636 --- /dev/null +++ b/To-Do_app/ToDo_app/ToDo_app/settings.py @@ -0,0 +1,136 @@ +""" +Django settings for ToDo_app project. + +Generated by 'django-admin startproject' using Django 5.0.5. + +For more information on this file, see +https://docs.djangoproject.com/en/5.0/topics/settings/ + +For the full list of settings and their values, see +https://docs.djangoproject.com/en/5.0/ref/settings/ +""" + +from pathlib import Path +import os +from django.contrib.messages import constants as messages + +# Build paths inside the project like this: BASE_DIR / 'subdir'. +BASE_DIR = Path(__file__).resolve().parent.parent + + +# Quick-start development settings - unsuitable for production +# See https://docs.djangoproject.com/en/5.0/howto/deployment/checklist/ + +# SECURITY WARNING: keep the secret key used in production secret! +SECRET_KEY = "django-insecure-mc5n4uwexy&$ocm4ub25znb0l6(u^ej7k!1kf5v!fksxpb7a55" + +# SECURITY WARNING: don't run with debug turned on in production! +DEBUG = True + +ALLOWED_HOSTS = [] + + +# Application definition + +INSTALLED_APPS = [ + "django.contrib.admin", + "django.contrib.auth", + "django.contrib.contenttypes", + "django.contrib.sessions", + "django.contrib.messages", + "django.contrib.staticfiles", +] +EXTERNAL_APPS = ["Items", "Authentication"] + +INSTALLED_APPS += EXTERNAL_APPS + +MIDDLEWARE = [ + "django.middleware.security.SecurityMiddleware", + "django.contrib.sessions.middleware.SessionMiddleware", + "django.middleware.common.CommonMiddleware", + "django.middleware.csrf.CsrfViewMiddleware", + "django.contrib.auth.middleware.AuthenticationMiddleware", + "django.contrib.messages.middleware.MessageMiddleware", + "django.middleware.clickjacking.XFrameOptionsMiddleware", +] + +ROOT_URLCONF = "ToDo_app.urls" + +TEMPLATES = [ + { + "BACKEND": "django.template.backends.django.DjangoTemplates", + "DIRS": [os.path.join(BASE_DIR, "templates")], + "APP_DIRS": True, + "OPTIONS": { + "context_processors": [ + "django.template.context_processors.debug", + "django.template.context_processors.request", + "django.contrib.auth.context_processors.auth", + "django.contrib.messages.context_processors.messages", + ], + }, + }, +] + +WSGI_APPLICATION = "ToDo_app.wsgi.application" + + +# Database +# https://docs.djangoproject.com/en/5.0/ref/settings/#databases + +DATABASES = { + "default": { + "ENGINE": "django.db.backends.sqlite3", + "NAME": BASE_DIR / "db.sqlite3", + } +} + + +# Password validation +# https://docs.djangoproject.com/en/5.0/ref/settings/#auth-password-validators + +AUTH_PASSWORD_VALIDATORS = [ + { + "NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator", + }, + { + "NAME": "django.contrib.auth.password_validation.MinimumLengthValidator", + }, + { + "NAME": "django.contrib.auth.password_validation.CommonPasswordValidator", + }, + { + "NAME": "django.contrib.auth.password_validation.NumericPasswordValidator", + }, +] + + +# Internationalization +# https://docs.djangoproject.com/en/5.0/topics/i18n/ + +LANGUAGE_CODE = "en-us" + +TIME_ZONE = "UTC" + +USE_I18N = True + +USE_TZ = True + + +# Static files (CSS, JavaScript, Images) +# https://docs.djangoproject.com/en/5.0/howto/static-files/ + +STATIC_URL = "static/" + +# Default primary key field type +# https://docs.djangoproject.com/en/5.0/ref/settings/#default-auto-field + +DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField" + +MESSAGE_TAGS = { + messages.DEBUG: 'secondary', + messages.INFO: 'info', + messages.SUCCESS: 'success', + messages.WARNING: 'warning', + messages.ERROR: 'danger', # Mapping messages.ERROR to Bootstrap 'danger' class +} diff --git a/To-Do_app/ToDo_app/ToDo_app/urls.py b/To-Do_app/ToDo_app/ToDo_app/urls.py new file mode 100644 index 0000000..7ff0324 --- /dev/null +++ b/To-Do_app/ToDo_app/ToDo_app/urls.py @@ -0,0 +1,25 @@ +""" +URL configuration for ToDo_app project. + +The `urlpatterns` list routes URLs to views. For more information please see: + https://docs.djangoproject.com/en/5.0/topics/http/urls/ +Examples: +Function views + 1. Add an import: from my_app import views + 2. Add a URL to urlpatterns: path('', views.home, name='home') +Class-based views + 1. Add an import: from other_app.views import Home + 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home') +Including another URLconf + 1. Import the include() function: from django.urls import include, path + 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) +""" + +from django.contrib import admin +from django.urls import path, include + +urlpatterns = [ + path("admin/", admin.site.urls), + path("", include("Items.urls")), + path("auth",include("Authentication.urls")), +] diff --git a/To-Do_app/ToDo_app/ToDo_app/wsgi.py b/To-Do_app/ToDo_app/ToDo_app/wsgi.py new file mode 100644 index 0000000..2a821a1 --- /dev/null +++ b/To-Do_app/ToDo_app/ToDo_app/wsgi.py @@ -0,0 +1,16 @@ +""" +WSGI config for ToDo_app project. + +It exposes the WSGI callable as a module-level variable named ``application``. + +For more information on this file, see +https://docs.djangoproject.com/en/5.0/howto/deployment/wsgi/ +""" + +import os + +from django.core.wsgi import get_wsgi_application + +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'ToDo_app.settings') + +application = get_wsgi_application() diff --git a/To-Do_app/ToDo_app/manage.py b/To-Do_app/ToDo_app/manage.py new file mode 100644 index 0000000..a9f7b05 --- /dev/null +++ b/To-Do_app/ToDo_app/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', 'ToDo_app.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/To-Do_app/ToDo_app/templates/Authentication/login.html b/To-Do_app/ToDo_app/templates/Authentication/login.html new file mode 100644 index 0000000..66ab75a --- /dev/null +++ b/To-Do_app/ToDo_app/templates/Authentication/login.html @@ -0,0 +1,22 @@ +{% extends "base.html" %} + +{% block content %} +
+
+
+

Login

+ {% csrf_token %} +
+ + +
+
+ + +
+
Don't have an account Sigun Up here
+ +
+
+
+{% endblock content %} \ No newline at end of file diff --git a/To-Do_app/ToDo_app/templates/Authentication/register.html b/To-Do_app/ToDo_app/templates/Authentication/register.html new file mode 100644 index 0000000..7df31e6 --- /dev/null +++ b/To-Do_app/ToDo_app/templates/Authentication/register.html @@ -0,0 +1,29 @@ +{% extends "base.html" %} +{% block content %} +
+
+ {% csrf_token %} +

Sign Up

+
+
+ + +
+
+ + +
+
+ + +
+ +
+
Already have an account Login here
+
+
+{% endblock content %} \ No newline at end of file diff --git a/To-Do_app/ToDo_app/templates/Items/addItems.html b/To-Do_app/ToDo_app/templates/Items/addItems.html new file mode 100644 index 0000000..f707d0c --- /dev/null +++ b/To-Do_app/ToDo_app/templates/Items/addItems.html @@ -0,0 +1,43 @@ +{% extends "base.html" %} {% block content %} +

Add Item

+
+
+
+ {% csrf_token %} +
+ + +
+ +
+ + +
+
+ + +
+ {% if viewName == "addItems"%} + + {% else %} + + {% endif %} +
+
+
+ +{% endblock content %} \ No newline at end of file diff --git a/To-Do_app/ToDo_app/templates/Items/index.html b/To-Do_app/ToDo_app/templates/Items/index.html new file mode 100644 index 0000000..92e3241 --- /dev/null +++ b/To-Do_app/ToDo_app/templates/Items/index.html @@ -0,0 +1,164 @@ +{% extends "base.html" %} {% block content %} {% if values %} + +
+ + + + + + + + + + + + + {% for values in page_obj %} + + + + + + + + + + {% endfor %} + +
Sno.CategoryDescriptionDateStatusOperations
{{forloop.counter}}{{values.category}}{{values.description }}{{values.date}} + {% if not values.status %} +
+
+
+ {% csrf_token %} +
+ + +
+
+
+
+ {% else %} +
+
+
+ {% csrf_token %} +
+ + +
+
+
+
+ {% endif %} + +
+
+
+
+
+ +
+
+
+
+ {% csrf_token %} + +
+
+
+
+
+
+
+ Page {{page_obj.number}} of {{page_obj.paginator.num_pages}} + +
+ +{% else %} +
+
+
+ No values for diaply +
+ Add Items +
+
+
+{% endif %} {% endblock content%} diff --git a/To-Do_app/ToDo_app/templates/base.html b/To-Do_app/ToDo_app/templates/base.html new file mode 100644 index 0000000..08e9df2 --- /dev/null +++ b/To-Do_app/ToDo_app/templates/base.html @@ -0,0 +1,77 @@ + + + + + + + Document + + + +
+ {% if user.is_authenticated %} + {% include 'nav.html'%} + {% endif %} +
+ {% block content %}{% endblock %} +
+
+ +
+ {% for message in messages %} + + {% endfor %} +
+ + + + + + + \ No newline at end of file diff --git a/To-Do_app/ToDo_app/templates/nav.html b/To-Do_app/ToDo_app/templates/nav.html new file mode 100644 index 0000000..cb86259 --- /dev/null +++ b/To-Do_app/ToDo_app/templates/nav.html @@ -0,0 +1,28 @@ + \ No newline at end of file diff --git a/To-Do_app/requirement.txt b/To-Do_app/requirement.txt new file mode 100644 index 0000000000000000000000000000000000000000..9baef3b5ed12fc9109277be0de2d40be6da18815 GIT binary patch literal 6578 zcma)=$!?oR5QOI(Adf=9q-5DTw0!k|DI>tGS|sU zcY0-9X8KulI?i8dIVIVX?S*bn>VN0*!}hU`7vaISY-Q!Kp2pdE=iRRC^|LNt%T$^| zgYWknnFpP26wOvL(}Sijvlyo7`Pht+u(W zI>+UvY9Lx{8rP9@FJxs>&z$i<pq2T}3>JIPhs z13-AtF=ke+x+i5VP`ekk){XD1+zZ3i!T;p=yz?JF$O$L*f=;_u%plp56ezf^iD^)? z=a^1Q_H;XLWnRfgqIZ0gehIsV)la->C1L%zW-YRCSv|H7H}X6tit*&W&lWXyYvs)G zEtDhpOqZ~KJ^ck94J8l$z5z>HUF4WEx@ucRmV>Q}>IoBKE6k%qQ$vHMyI2ZL;SDjt zlD@o4zu^?zcZHd;NDit;ZQb6=Bc!OuGyN9^?es$*;0AH?&xqXW?@U2Xh^=4f;y(LT ze_x5uLs^NN&Kj}ZO8=uwrV@cy6~y~O0Zt`Shj23^WMgFGM0ysjfpBWr7Q zwQ@bhx{*#;LY*-wqRyj!+8N;5xD~!I$KLdG|C|2do$r88=JvHT)5pETRS_s2%U#!u zEIPg5My}g@v_2pWFWteYNF+~rdoAl=h{uT}-nxUm_M(-(?jpXcxq#0Zult8_Zasrl z?$2gv%&lWPmhy%-uQhdyrjh!d_R}%Ba?DUy7W@WDw0Uah>9f#)VeZ(2T2qPkSDi6S zVB@mE4lWbd`^r}L1XogM>Z|LL;fVWp;jvX0pGecA>_xq}Lla?0fZ`WP)6LWC$P+uo zUJ^`&=tiL{XU8e2UX2r9=``GNJ%@*6mwv@Q>T}}|d}1E=K|-|{7%Tz&11rWtm_C&R^kx2w)MbiMrsNAqM7YY23{Y_F#WudSpwX1A0=X9 z@5z&$;$z#6mjxan?d^fhj>ty(&2A3|ZzP+W7-+brR>G3W;nxd#n8ktBshJ1j$@z7~ znb*Oy_6u)AuJ7ogNZ|EU9x!dN7i>rtuRCmDI$M@A2S%<?H?m_iU=LEn!MS&Es*q|7ZZRig|1xg2Y4p~z z#%m?nfVbgIp7LJJo{mMBd`b@c?BC=I4uG4tl<+m#wvlCC4EVt7i9H)jZ)>aHY};|m zEQ?yED>^sk7<|9#5W@;`-bf>VM%HtCBg@{C&FH8^=M78r7xb`yvzed;B*7~f#HPcx z$qZ&9g-litRRdR7!Y)p+6-eeO+nl#2vnr&sg3vXVSLSUyL3vq_-_MeGJ;CtBb0BSo zj;t{=rS;3vvw2Yi*LCls*JLfVykZ~mW=MC2k7So^#;D*04D#MZBq<+T7+)6H;ODxV z+kr7Rd%5*eam-4=^W%3O+L@OtF(P)tcZX_e&*0waNs@kAlNmuyhyjm zdBWRsc^aHWTPySZSC1J%gm3Re4f=bItI#&m&P=|Z*Pkm@i0gw$;RgL7_{}}nG1d1 z?i|rdXZ|*nQ-V0$tC(}_bZGF40qywdj^{TbGcD>jU$rng;-y-^D|~a-@qmhF`hx|C zfT+KnVWs^}by_m*@-8}lC4ee@*Iu;u`SuXgHSIX&Q*!ibVr5rqnfU+iQhR94p4M*i zr|q%9_0-eGvfERJ{H=%m4nO$v0+#0MF`8_OOkpC-ewf=5w~@gsz5(PW(@szNEES9d zeG+|iJ;wk;h&>QP7gL6b=iZ4=M#ouZe#6t?j~U;d?)L7X*OGs#Ie@qRTH)JZoSQo{r~Sgx z&K|s`u43jzE)x}YgoS){u47xv3d$Nq(mh}#Oj>+hqu->5uRjmM2z=VDksRT*B_EYR z<`(ZH_Z$2ni{2R@b(=R$aLZAXX}(+&lO;TH*h-9;< literal 0 HcmV?d00001