Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions Group 7: Version 1.0.4/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Codegym2019
Group 7:Tasker
Release Version 1.0.4
Group Members:
1.Sohan Kale(lead)
2.Purva Gaikwad
3.Anivedh Auradhkar
4.Aditya Bakare
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
168 changes: 168 additions & 0 deletions Group 7: Version 1.0.4/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
from flask import Flask, render_template, request,redirect
from flask_sqlalchemy import SQLAlchemy
#from flaskwebgui import FlaskUI
import threading
import time
from win10toast import ToastNotifier
#import webbrowser
from threading import Timer

app = Flask(__name__)
#ui=FlaskUI(app)
import datetime

app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///read.db'
db = SQLAlchemy(app)
toast = ToastNotifier()
import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText


# Data for emailing Report
sender= "my@email.com"
sender_password= r"password"
msg = MIMEMultipart('alternative')
msg['Subject'] = "Daily Task Summary"
msg['From'] = sender
s = smtplib.SMTP_SSL('smtp.gmail.com')
s.login(sender, sender_password)

class Task(db.Model):

id = db.Column(db.Integer, primary_key = True)
task = db.Column(db.String(), nullable=False,default="")
time1 = db.Column( db.String(), nullable = False)
time2 = db.Column( db.String(), nullable = False)
status = db.Column( db.String(), nullable=False, default="incomplete")
is_deleted = db.Column( db.String(), nullable = False, default = "no" )

def __repr__(self):
return("Hello")

@app.route('/',methods = ['POST','GET'])
def index():
flag = 0
if request.method == 'POST':
new_task1 = request.form.get('task')
time1 = request.form.get('time1')
time2 = request.form.get('time2')
tasks = Task.query.order_by(Task.time1).all()
if tasks==[] and new_task1!="" and time1!="" and time2!="":

try:
t =Task(task=new_task1, time1 = time1,time2= time2 )
db.session.add(t)
db.session.commit()
#toast.show_toast(title=f"{t.task}", msg=f"{t.task}",threaded=True)
except:
return "There was a problem"
return redirect('/')

elif tasks != [] and new_task1!="" and time1!="" and time2!="":
flag2=0
for task in tasks:
if time1==task.time1 and time2==task.time2 and task.is_deleted=="no":
flag2=1
if flag2==0:
try:
t =Task(task=new_task1, time1 = time1,time2= time2 )
db.session.add(t)
db.session.commit()
#toast.show_toast(title=f"{t.task}", msg=f"{t.task}",threaded=True)
except:
return "There was a problem"
return redirect('/')
tasks = Task.query.order_by(Task.time1).all()
return render_template('index.html', tasks = tasks)

@app.route('/delete/<int:id>')
def delete(id):
task = Task.query.get(id)
#db.session.delete(task)
task.is_deleted = "yes"
db.session.commit()
return redirect('/')

@app.route('/update/<int:id>', methods = ['POST','GET'])
def update(id):
taask = Task.query.get_or_404(id)
tasks = Task.query.order_by(Task.time1).all()
if request.method == 'POST':
t= request.form.get('task')
time_1 = request.form.get('time1')
time_2 = request.form.get('time2')
flag = 1
for task in tasks:
if time_1 == task.time1 and task.is_deleted=="no":
flag = 0
if flag :
try:
taask.time1 = time_1
taask.time2= time_2
taask.task = t
db.session.commit()
return redirect('/')
except:
return "there was a problem"
else:
return redirect('/')

else:
return render_template('update.html',task=taask)

@app.route('/done/<int:id>')
def done(id):
taask = Task.query.get_or_404(id)
taask.status = "completed"
db.session.commit()
return redirect('/')

@app.route('/getreport', methods=['GET','POST'])
def getreport():
tasks = Task.query.order_by(Task.time1).all()
if request.method == 'POST':
try:
#s.connect()
html = render_template('getrep.html',tasks=tasks)
part2 = MIMEText(html, 'html')
reciever =request.form.get('email')
msg['To'] = reciever
msg.attach(part2)
s.sendmail(sender, reciever, msg.as_string())
s.quit()
except:
return "There was problem in email or network"

return render_template('getrep.html',tasks=tasks)

@app.route('/removeall')
def removeall():
tasks = Task.query.all()
try:
for task in tasks:
db.session.delete(task)
db.session.commit()
except:
return "there was a problem"
return redirect('/')

def notification_scheduler():
toast = ToastNotifier()
import datetime
while True:
tasks = Task.query.order_by(Task.time1).all()
for task in tasks:
now = datetime.datetime.now()
current_time = now.strftime("%H:%M:%S")
if task.time1 in current_time and task.is_deleted =="no":
toast.show_toast(title=f"{task.task}", msg=f"{task.task}",threaded=True)
time.sleep(30)
print(current_time)
time.sleep(1)


if __name__ == "__main__":
x = threading.Thread(target=notification_scheduler , args=(),daemon=True)
x.start()
app.run(debug=True,)
Binary file added Group 7: Version 1.0.4/app.pyc
Binary file not shown.
Binary file added Group 7: Version 1.0.4/read.db
Binary file not shown.
12 changes: 12 additions & 0 deletions Group 7: Version 1.0.4/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Click==7.0
Flask==1.1.1
itsdangerous==1.1.0
Jinja2==2.10.3
MarkupSafe==1.1.1
Werkzeug==0.16.0
flask-sqlalchemy
win10toast==0.9
SQlAlchemy==1.3.11
requests==2.22.0
flaskwebgui==0.0.8

74 changes: 74 additions & 0 deletions Group 7: Version 1.0.4/templates/getrep.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Tasker</title>
<style>
table {
font-family: arial, sans-serif;
border-collapse: collapse;
width: 100%;
}

td, th {
border: 1px solid #dddddd;
text-align: left;
padding: 8px;
}

tr:nth-child(even) {
background-color: #dddddd;
}
.button {
background-color: #4CAF50;
border: none;
color: white;
padding: 15px 32px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
margin: 4px 2px;
cursor: pointer;
}
</style>
</head>
<body>
<div>
</br>
</br>
</br>
<h1 align="center">REPORT</h1>
<form action="/getreport" align="center" method="POST" >

<input type="email" name="email" id = "email" value="Enter your email to send report" ></br></br>
<input type="submit" value="Send" class="button">

</form>
<form action="/removeall" align="center">
<input type="submit" value="Delete All" class="button">
</form>
<table border="1" align="center">

<tr>
<th>Task</th>
<th>From</th>
<th>To</th>
<th>Status</th>

</tr>
{% for task in tasks %}
<tr>
<td>{{task.task}}</td>
<td>{{task.time1}}</td>
<td>{{task.time2}}</td>
<td>{{task.status}}</td>
</tr>
{% endfor %}
</table>
</div>

</body>
</html>
106 changes: 106 additions & 0 deletions Group 7: Version 1.0.4/templates/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Tasker</title>
<style>
table {
font-family: arial, sans-serif;
border-collapse: collapse;
width: 100%;
}

td, th {
border: 1px solid #dddddd;
text-align: left;
padding: 8px;
}

tr:nth-child(even) {
background-color: #dddddd;
}
.button {
background-color: #4CAF50;
border: none;
color: white;
padding: 15px 32px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
margin: 4px 2px;
cursor: pointer;
}
.button[type=submit]:hover {
background-color: #45a049;
}
input[type=text], select {
width: 50%;
padding: 12px 20px;
margin: 8px 0;
display: inline-block;
border: 2px solid #000000;
border-radius: 4px;
box-sizing: border-box;
}
input[type=time], select {
width: 10%;
padding: 12px 20px;
margin: 8px 0;
display: inline-block;
border: 2px solid #000000;
border-radius: 4px;
box-sizing: border-box;
}


</style>
</head>
<body>
<div>

<h1 align="center">TASKER</h1>
<form action="/" method="POST" align="center" >

<p><b>Task :</b> <input type="text" name="task" id = "task" ></br></p>
From:
<input type="time" name="time1" id="time1" font-size="5">
To:
<input type="time" name="time2" id="time2"></br></br>
<button type="submit" class="button"> Submit</button>
</form>
<form action="/getreport" align="center">
<button type="submit" class="button" onclick="getreport()"> Get Report</button></br></br>
</form>

<table border="1" align="center">
<tr>
<th>Tasks</th>
<th>From</th>
<th>To</th>
<th>Status</th>
<th>Option</th>
</tr>
{% for task in tasks %}
{% if task.is_deleted == 'no' %}
<tr>
<td>{{task.task}}</td>
<td>{{task.time1}}</td>
<td>{{task.time2}}</td>
<td>{{task.status}}</td>

<td><a href = "/delete/{{task.id}}">Delete</a>

<a href = "/update/{{task.id}}">Update</a>
<a href = "/done/{{task.id}}">Done</a>
</td>
{% endif %}
{% endfor %}
</table>
</div>


</body>
</html>
Loading