Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit a2e54d3

Browse files
committed
removed test files
1 parent 459d605 commit a2e54d3

File tree

4 files changed

+33
-255
lines changed

4 files changed

+33
-255
lines changed

‎planner copy.py‎

Lines changed: 0 additions & 244 deletions
This file was deleted.

‎planner.py‎

Lines changed: 33 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
connect = sql.connect('planner.db')
55
cursor = connect.cursor()
66

7-
cursor.execute("CREATE TABLE IF NOT EXISTS tasks (task_id INTEGER PRIMARY KEY, task TEXT UNIQUE, time REAL, date TEXT, type_id INTEGER, FOREIGN KEY(type_id) REFERENCES types(type_id))")
7+
cursor.execute("CREATE TABLE IF NOT EXISTS tasks (task_id INTEGER PRIMARY KEY, task TEXT UNIQUE, time REAL, year TEXT, month TEXT, day TEXT, type_id INTEGER, FOREIGN KEY(type_id) REFERENCES types(type_id))")
88
cursor.execute("CREATE TABLE IF NOT EXISTS types (type_id INTEGER PRIMARY KEY, type TEXT UNIQUE)")
99

1010
cursor.execute('SELECT * FROM types')
@@ -42,7 +42,7 @@ def get_choice(max, phrase, do_phrase=True):
4242
return choice
4343

4444
def get_all():
45-
cursor.execute("SELECT ta.task, ty.type, ta.date, ta.time FROM tasks ta JOIN types ty ON ta.type_id = ty.type_id ORDER BY ta.date")
45+
cursor.execute("SELECT ta.task, ty.type, (ta.month || '/' || ta.day || '/' || ta.year) AS date, ta.time FROM tasks ta JOIN types ty ON ta.type_id = ty.type_id ORDER BY ta.year, ta.month, ta.day, ta.time")
4646
return cursor.fetchall()
4747

4848
def get_tasks():
@@ -69,6 +69,7 @@ def get_value(data, new=False):
6969
print('\nNot a valid number.')
7070
time.sleep(.5)
7171
else:
72+
date = []
7273
correct = False
7374
cursor.execute("SELECT strftime('%Y', date('now'))")
7475
current_date = cursor.fetchall()
@@ -82,6 +83,7 @@ def get_value(data, new=False):
8283
time.sleep(.5)
8384
else:
8485
correct = True
86+
date.append(year)
8587
correct = False
8688
while not correct:
8789
caught = False
@@ -101,6 +103,7 @@ def get_value(data, new=False):
101103
time.sleep(.5)
102104
else:
103105
correct = True
106+
date.append(month)
104107
correct = False
105108
cursor.execute("SELECT strftime('%d', date('now'))")
106109
current_date = cursor.fetchall()
@@ -123,14 +126,15 @@ def get_value(data, new=False):
123126
time.sleep(.5)
124127
else:
125128
correct = True
126-
date=f'{month}-{day}-{year}'
129+
date.append(day)
127130
return date
128131
if value < 0:
129132
print('\nNot a valid number.')
130133
time.sleep(.5)
131134
except ValueError:
132135
print('\nNot a valid number.')
133136
time.sleep(.5)
137+
value = -1
134138
return value
135139

136140
def display_tasks():
@@ -161,9 +165,9 @@ def display_types():
161165
choice = get_choice(5, '\nWould you like to:\n1). Add\n2). Edit\n3). Delete\n4). Reset planner\n5). Go back')
162166

163167
if choice == 1:
164-
bad = False
165168
passed = False
166169
while not passed:
170+
bad = False
167171
task = input('Task: ')
168172
tasks = get_tasks()
169173
for i in tasks:
@@ -172,21 +176,37 @@ def display_types():
172176
print('\nTask already exists.\n')
173177
time.sleep(.5)
174178
bad = True
179+
break
180+
if bad:
181+
break
175182
if not bad:
176183
passed = True
177184
display_types()
178185
type_id = get_value('type')
179186
hours = get_value('hours')
180187
date = get_value('date')
181-
values = (None, task, hours, date, type_id)
182-
cursor.execute("INSERT INTO tasks VALUES (?, ?, ?, ?, ?)", values)
188+
values = (None, task, hours, date[0], date[1], date[2], type_id)
189+
cursor.execute("INSERT INTO tasks VALUES (?, ?, ?, ?, ?, ?, ?)", values)
183190
connect.commit()
184191

185192
elif choice == 2:
186193
display_tasks()
187-
print('\nWhich task would you like to edit?')
188-
edit = input('-> ')
189-
choice = get_choice(3, '\nWould you like to edit:\n1). Task\n2). Type\n3). Time')
194+
tasks = get_tasks()
195+
bad = True
196+
while bad:
197+
print('\nWhich task would you like to edit?')
198+
edit = input('-> ')
199+
for i in tasks:
200+
for j in i:
201+
if edit == j:
202+
bad = False
203+
break
204+
if not bad:
205+
break
206+
if bad:
207+
print('\nNot a valid task.')
208+
time.sleep(.5)
209+
choice = get_choice(4, '\nWould you like to edit:\n1). Task\n2). Type\n3). Due date\n4). Time')
190210
if choice == 1:
191211
task = input('Task: ')
192212
values = (task, edit)
@@ -198,6 +218,10 @@ def display_types():
198218
cursor.execute("UPDATE tasks SET type_id = ? WHERE task = ?", values)
199219
elif choice == 3:
200220
choice = None
221+
date = get_value('date')
222+
values = (date[0], date[1], date[2], edit)
223+
cursor.execute("UPDATE tasks SET year = ?, month = ?, day = ? WHERE task = ?", values)
224+
elif choice == 4:
201225
hours = get_value('hours')
202226
values = (hours, edit)
203227
cursor.execute("UPDATE tasks SET time = ? WHERE task = ?", values)

‎test.db‎

Whitespace-only changes.

‎test.py‎

Lines changed: 0 additions & 2 deletions
This file was deleted.

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /