├── AlpineTodo ├── __init__.py ├── __pycache__ │ ├── __init__.cpython-38.pyc │ ├── settings.cpython-38.pyc │ ├── urls.cpython-38.pyc │ └── wsgi.cpython-38.pyc ├── asgi.py ├── settings.py ├── urls.py └── wsgi.py ├── manage.py ├── tasks ├── __init__.py ├── __pycache__ │ ├── __init__.cpython-38.pyc │ ├── admin.cpython-38.pyc │ ├── models.cpython-38.pyc │ ├── urls.cpython-38.pyc │ └── views.cpython-38.pyc ├── admin.py ├── apps.py ├── migrations │ ├── 0001_initial.py │ ├── 0002_auto_20200921_0812.py │ ├── __init__.py │ └── __pycache__ │ │ ├── 0001_initial.cpython-38.pyc │ │ ├── 0002_auto_20200921_0812.cpython-38.pyc │ │ └── __init__.cpython-38.pyc ├── models.py ├── tests.py ├── urls.py └── views.py └── templates └── index.html /AlpineTodo/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bitgeese/Alpine.js-Django-Todo-List/199cb2d384829f53378ab9d883f7a3c0a7a87f2b/AlpineTodo/__init__.py -------------------------------------------------------------------------------- /AlpineTodo/__pycache__/__init__.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bitgeese/Alpine.js-Django-Todo-List/199cb2d384829f53378ab9d883f7a3c0a7a87f2b/AlpineTodo/__pycache__/__init__.cpython-38.pyc -------------------------------------------------------------------------------- /AlpineTodo/__pycache__/settings.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bitgeese/Alpine.js-Django-Todo-List/199cb2d384829f53378ab9d883f7a3c0a7a87f2b/AlpineTodo/__pycache__/settings.cpython-38.pyc -------------------------------------------------------------------------------- /AlpineTodo/__pycache__/urls.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bitgeese/Alpine.js-Django-Todo-List/199cb2d384829f53378ab9d883f7a3c0a7a87f2b/AlpineTodo/__pycache__/urls.cpython-38.pyc -------------------------------------------------------------------------------- /AlpineTodo/__pycache__/wsgi.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bitgeese/Alpine.js-Django-Todo-List/199cb2d384829f53378ab9d883f7a3c0a7a87f2b/AlpineTodo/__pycache__/wsgi.cpython-38.pyc -------------------------------------------------------------------------------- /AlpineTodo/asgi.py: -------------------------------------------------------------------------------- 1 | """ 2 | ASGI config for AlpineTodo 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', 'AlpineTodo.settings') 15 | 16 | application = get_asgi_application() 17 | -------------------------------------------------------------------------------- /AlpineTodo/settings.py: -------------------------------------------------------------------------------- 1 | """ 2 | Django settings for AlpineTodo project. 3 | 4 | Generated by 'django-admin startproject' using Django 3.1.1. 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 | import os 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 = '2ez=)xh%dze^oko7#*ms=na%i61e5*i%5z1*v+y%+yz#_n$+nb' 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 | 'tasks', 41 | 'ordered_model', 42 | ] 43 | 44 | MIDDLEWARE = [ 45 | 'django.middleware.security.SecurityMiddleware', 46 | 'django.contrib.sessions.middleware.SessionMiddleware', 47 | 'django.middleware.common.CommonMiddleware', 48 | 'django.middleware.csrf.CsrfViewMiddleware', 49 | 'django.contrib.auth.middleware.AuthenticationMiddleware', 50 | 'django.contrib.messages.middleware.MessageMiddleware', 51 | 'django.middleware.clickjacking.XFrameOptionsMiddleware', 52 | ] 53 | 54 | ROOT_URLCONF = 'AlpineTodo.urls' 55 | 56 | TEMPLATES = [ 57 | { 58 | 'BACKEND': 'django.template.backends.django.DjangoTemplates', 59 | 'DIRS': [os.path.join(BASE_DIR, 'templates')] 60 | , 61 | 'APP_DIRS': True, 62 | 'OPTIONS': { 63 | 'context_processors': [ 64 | 'django.template.context_processors.debug', 65 | 'django.template.context_processors.request', 66 | 'django.contrib.auth.context_processors.auth', 67 | 'django.contrib.messages.context_processors.messages', 68 | ], 69 | }, 70 | }, 71 | ] 72 | 73 | WSGI_APPLICATION = 'AlpineTodo.wsgi.application' 74 | 75 | 76 | # Database 77 | # https://docs.djangoproject.com/en/3.1/ref/settings/#databases 78 | 79 | DATABASES = { 80 | 'default': { 81 | 'ENGINE': 'django.db.backends.sqlite3', 82 | 'NAME': BASE_DIR / 'db.sqlite3', 83 | } 84 | } 85 | 86 | 87 | # Password validation 88 | # https://docs.djangoproject.com/en/3.1/ref/settings/#auth-password-validators 89 | 90 | AUTH_PASSWORD_VALIDATORS = [ 91 | { 92 | 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', 93 | }, 94 | { 95 | 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', 96 | }, 97 | { 98 | 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', 99 | }, 100 | { 101 | 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', 102 | }, 103 | ] 104 | 105 | 106 | # Internationalization 107 | # https://docs.djangoproject.com/en/3.1/topics/i18n/ 108 | 109 | LANGUAGE_CODE = 'en-us' 110 | 111 | TIME_ZONE = 'UTC' 112 | 113 | USE_I18N = True 114 | 115 | USE_L10N = True 116 | 117 | USE_TZ = True 118 | 119 | 120 | # Static files (CSS, JavaScript, Images) 121 | # https://docs.djangoproject.com/en/3.1/howto/static-files/ 122 | 123 | STATIC_URL = '/static/' 124 | -------------------------------------------------------------------------------- /AlpineTodo/urls.py: -------------------------------------------------------------------------------- 1 | from django.contrib import admin 2 | from django.urls import path, include 3 | 4 | urlpatterns = [ 5 | path('admin/', admin.site.urls), 6 | path('', include('tasks.urls')), 7 | ] 8 | -------------------------------------------------------------------------------- /AlpineTodo/wsgi.py: -------------------------------------------------------------------------------- 1 | """ 2 | WSGI config for AlpineTodo 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', 'AlpineTodo.settings') 15 | 16 | application = get_wsgi_application() 17 | -------------------------------------------------------------------------------- /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', 'AlpineTodo.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 | -------------------------------------------------------------------------------- /tasks/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bitgeese/Alpine.js-Django-Todo-List/199cb2d384829f53378ab9d883f7a3c0a7a87f2b/tasks/__init__.py -------------------------------------------------------------------------------- /tasks/__pycache__/__init__.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bitgeese/Alpine.js-Django-Todo-List/199cb2d384829f53378ab9d883f7a3c0a7a87f2b/tasks/__pycache__/__init__.cpython-38.pyc -------------------------------------------------------------------------------- /tasks/__pycache__/admin.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bitgeese/Alpine.js-Django-Todo-List/199cb2d384829f53378ab9d883f7a3c0a7a87f2b/tasks/__pycache__/admin.cpython-38.pyc -------------------------------------------------------------------------------- /tasks/__pycache__/models.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bitgeese/Alpine.js-Django-Todo-List/199cb2d384829f53378ab9d883f7a3c0a7a87f2b/tasks/__pycache__/models.cpython-38.pyc -------------------------------------------------------------------------------- /tasks/__pycache__/urls.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bitgeese/Alpine.js-Django-Todo-List/199cb2d384829f53378ab9d883f7a3c0a7a87f2b/tasks/__pycache__/urls.cpython-38.pyc -------------------------------------------------------------------------------- /tasks/__pycache__/views.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bitgeese/Alpine.js-Django-Todo-List/199cb2d384829f53378ab9d883f7a3c0a7a87f2b/tasks/__pycache__/views.cpython-38.pyc -------------------------------------------------------------------------------- /tasks/admin.py: -------------------------------------------------------------------------------- 1 | from django.contrib import admin 2 | 3 | # Register your models here. 4 | -------------------------------------------------------------------------------- /tasks/apps.py: -------------------------------------------------------------------------------- 1 | from django.apps import AppConfig 2 | 3 | 4 | class TasksConfig(AppConfig): 5 | name = 'tasks' 6 | -------------------------------------------------------------------------------- /tasks/migrations/0001_initial.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 3.1.1 on 2020-09-19 14:41 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='Task', 16 | fields=[ 17 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), 18 | ('title', models.CharField(max_length=255)), 19 | ('completed', models.BooleanField(default=False)), 20 | ], 21 | ), 22 | ] 23 | -------------------------------------------------------------------------------- /tasks/migrations/0002_auto_20200921_0812.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 3.1.1 on 2020-09-21 08:12 2 | 3 | from django.db import migrations, models 4 | 5 | 6 | class Migration(migrations.Migration): 7 | 8 | dependencies = [ 9 | ('tasks', '0001_initial'), 10 | ] 11 | 12 | operations = [ 13 | migrations.AlterModelOptions( 14 | name='task', 15 | options={'ordering': ('order',)}, 16 | ), 17 | migrations.AddField( 18 | model_name='task', 19 | name='order', 20 | field=models.PositiveIntegerField(db_index=True, default=1, editable=False, verbose_name='order'), 21 | preserve_default=False, 22 | ), 23 | ] 24 | -------------------------------------------------------------------------------- /tasks/migrations/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bitgeese/Alpine.js-Django-Todo-List/199cb2d384829f53378ab9d883f7a3c0a7a87f2b/tasks/migrations/__init__.py -------------------------------------------------------------------------------- /tasks/migrations/__pycache__/0001_initial.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bitgeese/Alpine.js-Django-Todo-List/199cb2d384829f53378ab9d883f7a3c0a7a87f2b/tasks/migrations/__pycache__/0001_initial.cpython-38.pyc -------------------------------------------------------------------------------- /tasks/migrations/__pycache__/0002_auto_20200921_0812.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bitgeese/Alpine.js-Django-Todo-List/199cb2d384829f53378ab9d883f7a3c0a7a87f2b/tasks/migrations/__pycache__/0002_auto_20200921_0812.cpython-38.pyc -------------------------------------------------------------------------------- /tasks/migrations/__pycache__/__init__.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bitgeese/Alpine.js-Django-Todo-List/199cb2d384829f53378ab9d883f7a3c0a7a87f2b/tasks/migrations/__pycache__/__init__.cpython-38.pyc -------------------------------------------------------------------------------- /tasks/models.py: -------------------------------------------------------------------------------- 1 | from django.db import models 2 | from ordered_model.models import OrderedModel 3 | 4 | 5 | class Task(OrderedModel): 6 | STATUS = ( 7 | ('in progress', 'In Progress'), 8 | ('finished', 'Finished') 9 | ) 10 | title = models.CharField(max_length=255) 11 | completed = models.BooleanField(default=False) 12 | -------------------------------------------------------------------------------- /tasks/tests.py: -------------------------------------------------------------------------------- 1 | from django.test import TestCase 2 | 3 | # Create your tests here. 4 | -------------------------------------------------------------------------------- /tasks/urls.py: -------------------------------------------------------------------------------- 1 | from django.urls import path 2 | 3 | from . import views 4 | 5 | urlpatterns = [ 6 | path('', views.index, name='index'), 7 | path('tasks/', views.task_list, name='task_list'), 8 | path('tasks/create/', views.create_task, name='create_task'), 9 | path('tasks//delete/', views.delete_task, name='delete_task'), 10 | path('tasks//update/', views.update_task_status, name='update_task'), 11 | path('tasks//updateOrder/', views.update_task_order, name='update_task_order'), 12 | ] 13 | -------------------------------------------------------------------------------- /tasks/views.py: -------------------------------------------------------------------------------- 1 | from django.http import JsonResponse 2 | from django.shortcuts import get_object_or_404, render 3 | from django.views.decorators.csrf import csrf_exempt 4 | 5 | from tasks.models import Task 6 | 7 | 8 | def index(request): 9 | return render(request, 'index.html') 10 | 11 | 12 | def task_list(request): 13 | tasks = [{"id": task.id, 14 | "title": task.title, 15 | "completed": task.completed, 16 | 'position': task.order} for task in Task.objects.all()] 17 | return JsonResponse(status=200, data=tasks, safe=False) 18 | 19 | 20 | def create_task(request): 21 | title = request.POST.get('title') 22 | if not title: 23 | return JsonResponse(status=400, data={'error': 'title is required'}) 24 | task = Task.objects.create(title=title) 25 | return JsonResponse(status=201, data={'title': task.title, 26 | 'completed': task.completed, 27 | 'id': task.id, 28 | 'position': task.order}, safe=False) 29 | 30 | 31 | def delete_task(request, task_id): 32 | task = get_object_or_404(Task, pk=task_id) 33 | task.delete() 34 | return JsonResponse(status=204, data={'message': 'task deleted'}) 35 | 36 | 37 | def update_task_status(request, task_id): 38 | task = get_object_or_404(Task, pk=task_id) 39 | status = request.POST.get('status') 40 | if not status: 41 | return JsonResponse(status=400, data={'error': 'status is required'}) 42 | task.completed = int(status) 43 | task.save() 44 | return JsonResponse(status=204, data={'message': 'task status updated'}) 45 | 46 | 47 | def update_task_order(request, task_id): 48 | task = get_object_or_404(Task, pk=task_id) 49 | order = request.POST.get('position') 50 | if not order: 51 | return JsonResponse(status=400, data={'error': 'position is required'}) 52 | task.to(int(order)) 53 | return JsonResponse(data={"message": "position updated"}, status=200) 54 | 55 | -------------------------------------------------------------------------------- /templates/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Simple ToDo List 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 |
21 |

Simple To-Do List

22 |
23 | 24 | 25 |
26 |
27 | 28 | 29 |
30 |
31 | 32 | 33 |
34 | 54 |
55 | 56 |
57 | 58 | 59 | 124 | 153 | 154 | 155 | --------------------------------------------------------------------------------