Skip to content

Commit

Permalink
Merge pull request shreys7#1 from shreys7/feature/todos-app
Browse files Browse the repository at this point in the history
Added main logic for todos App
  • Loading branch information
shreys7 authored Dec 2, 2019
2 parents cb41b10 + 3122d46 commit 0b3efae
Show file tree
Hide file tree
Showing 27 changed files with 374 additions and 3 deletions.
57 changes: 57 additions & 0 deletions todoApp/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]

# C extensions
*.so

# Distribution / packaging
.Python
env/
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
*.egg-info/
.installed.cfg
*.egg

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*,cover

# Translations
*.mo
*.pot

# Django stuff:
*.log

# Sphinx documentation
docs/_build/

# PyBuilder
target/
Binary file modified todoApp/db.sqlite3
Binary file not shown.
9 changes: 9 additions & 0 deletions todoApp/staticfiles/css/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.page-header {
margin-top: 30px;
}

.fa-trash-alt {
color: red;
float: right;
cursor: pointer;
}
Binary file removed todoApp/todoApp/__pycache__/__init__.cpython-37.pyc
Binary file not shown.
Binary file removed todoApp/todoApp/__pycache__/settings.cpython-37.pyc
Binary file not shown.
Binary file removed todoApp/todoApp/__pycache__/urls.cpython-37.pyc
Binary file not shown.
Binary file removed todoApp/todoApp/__pycache__/wsgi.cpython-37.pyc
Binary file not shown.
11 changes: 10 additions & 1 deletion todoApp/todoApp/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
# Application definition

INSTALLED_APPS = [
'todos.apps.TodosConfig',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
Expand Down Expand Up @@ -105,7 +106,7 @@

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'
TIME_ZONE = 'Asia/kolkata'

USE_I18N = True

Expand All @@ -117,4 +118,12 @@
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/2.2/howto/static-files/

MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
MEDIA_URL = '/media/'

STATIC_ROOT = os.path.join(BASE_DIR, 'static')
STATIC_URL = '/static/'

STATICFILES_DIRS = (
os.path.join(BASE_DIR, 'staticfiles'),
)
9 changes: 7 additions & 2 deletions todoApp/todoApp/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,13 @@
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path
from django.urls import path, include
from django.conf.urls.static import static
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
from . import settings

urlpatterns = [
path('todos/', include('todos.urls')),
path('admin/', admin.site.urls),
]
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
urlpatterns += staticfiles_urlpatterns()
Empty file added todoApp/todos/__init__.py
Empty file.
4 changes: 4 additions & 0 deletions todoApp/todos/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from django.contrib import admin
from .models import Todo

admin.site.register(Todo)
5 changes: 5 additions & 0 deletions todoApp/todos/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from django.apps import AppConfig


class TodosConfig(AppConfig):
name = 'todos'
24 changes: 24 additions & 0 deletions todoApp/todos/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Generated by Django 2.2.7 on 2019-12-01 17:46

from django.db import migrations, models


class Migration(migrations.Migration):

initial = True

dependencies = [
]

operations = [
migrations.CreateModel(
name='Todo',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=100)),
('created_date', models.DateField(verbose_name='Created')),
('deadline', models.DateField(verbose_name='Deadline')),
('description', models.CharField(max_length=200)),
],
),
]
23 changes: 23 additions & 0 deletions todoApp/todos/migrations/0002_auto_20191201_2357.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Generated by Django 2.2.7 on 2019-12-01 18:27

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('todos', '0001_initial'),
]

operations = [
migrations.AlterField(
model_name='todo',
name='created_date',
field=models.DateTimeField(verbose_name='Created'),
),
migrations.AlterField(
model_name='todo',
name='deadline',
field=models.DateTimeField(verbose_name='Deadline'),
),
]
29 changes: 29 additions & 0 deletions todoApp/todos/migrations/0003_auto_20191202_0000.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Generated by Django 2.2.7 on 2019-12-01 18:30

from django.db import migrations, models
import django.utils.timezone


class Migration(migrations.Migration):

dependencies = [
('todos', '0002_auto_20191201_2357'),
]

operations = [
migrations.RemoveField(
model_name='todo',
name='created_date',
),
migrations.AddField(
model_name='todo',
name='created_at',
field=models.DateTimeField(auto_now_add=True, default=django.utils.timezone.now, verbose_name='Created'),
preserve_default=False,
),
migrations.AddField(
model_name='todo',
name='update_at',
field=models.DateTimeField(auto_now=True, verbose_name='Updated'),
),
]
18 changes: 18 additions & 0 deletions todoApp/todos/migrations/0004_auto_20191202_0004.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 2.2.7 on 2019-12-01 18:34

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('todos', '0003_auto_20191202_0000'),
]

operations = [
migrations.AlterField(
model_name='todo',
name='deadline',
field=models.DateTimeField(blank=True, verbose_name='Deadline'),
),
]
18 changes: 18 additions & 0 deletions todoApp/todos/migrations/0005_auto_20191202_0011.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 2.2.7 on 2019-12-01 18:41

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('todos', '0004_auto_20191202_0004'),
]

operations = [
migrations.AlterField(
model_name='todo',
name='deadline',
field=models.DateTimeField(blank=True, null=True, verbose_name='Deadline'),
),
]
17 changes: 17 additions & 0 deletions todoApp/todos/migrations/0006_remove_todo_deadline.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Generated by Django 2.2.7 on 2019-12-01 20:59

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('todos', '0005_auto_20191202_0011'),
]

operations = [
migrations.RemoveField(
model_name='todo',
name='deadline',
),
]
18 changes: 18 additions & 0 deletions todoApp/todos/migrations/0007_auto_20191202_0323.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 2.2.7 on 2019-12-01 21:53

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('todos', '0006_remove_todo_deadline'),
]

operations = [
migrations.RenameField(
model_name='todo',
old_name='name',
new_name='title',
),
]
22 changes: 22 additions & 0 deletions todoApp/todos/migrations/0008_auto_20191202_0809.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Generated by Django 2.2.7 on 2019-12-02 02:39

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('todos', '0007_auto_20191202_0323'),
]

operations = [
migrations.RemoveField(
model_name='todo',
name='description',
),
migrations.AddField(
model_name='todo',
name='isCompleted',
field=models.BooleanField(default=False),
),
]
Empty file.
10 changes: 10 additions & 0 deletions todoApp/todos/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from django.db import models

class Todo(models.Model):
title = models.CharField(max_length=100)
created_at = models.DateTimeField('Created', auto_now_add=True)
update_at = models.DateTimeField('Updated', auto_now=True)
isCompleted = models.BooleanField(default=False)

def __str__(self):
return self.title
23 changes: 23 additions & 0 deletions todoApp/todos/templates/todos/base.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{% load static %}
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
<!--- Our CSS file -->
<link rel="stylesheet" href="{% static 'css/style.css' %}">

{% block title %}
{% endblock %}
</head>
<body>
<script src="https://code.jquery.com/jquery-3.4.1.slim.min.js" integrity="sha384-J6qa4849blE2+poT4WnyKhv5vZF5SrPo0iEjwBvKU7imGFAV0wwj1yYfoRSJoZ+n" crossorigin="anonymous"></script><script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script><script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js" integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6" crossorigin="anonymous"></script> <script src="https://kit.fontawesome.com/15974f9624.js" crossorigin="anonymous"></script>
{% block content %}
{% endblock %}

</body>
</html>
44 changes: 44 additions & 0 deletions todoApp/todos/templates/todos/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{% extends 'todos/base.html' %}

{% block title %}
<title>Todo list</title>
{% endblock %}

{% block content %}
<div class="container">
<div class="page-header text-center">
<h1>Todo List</h1>
</div>
<form method="post" action="{% url 'todos:add' %}">
{% csrf_token %}
<div class="form-row">
<div class="col-md-6">
<input type="text" class="form-control" name="title" value="" placeholder="Do laundry">
</div>
<div class="col-md-6">
<button type="submit" name="submit" class="btn btn-success">Add To Do</button>
</div>
</div>
</form>
<div class="list-group">
{% for todo in todo_list %}
{% if todo.isCompleted %}
<div class="list-group-item col-md-6">
{{ todo.title }}
<a href="{% url 'todos:delete' todo.id %}">
<i class="far fa-trash-alt"></i>
</a>
</div>
{% else %}
<div class="list-group-item col-md-6">
{{ todo.title }}
<a href="{% url 'todos:delete' todo.id %}">
<i class="far fa-trash-alt" type="submit" name="submit"></i>
</a>
</div>
{% endif %}
{% endfor %}
</div>
</div>

{% endblock %}
3 changes: 3 additions & 0 deletions todoApp/todos/tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.test import TestCase

# Create your tests here.
Loading

0 comments on commit 0b3efae

Please sign in to comment.