Hari-Prasath-M91 commited on
Commit
cb31ff7
·
1 Parent(s): 5056f0b
Files changed (1) hide show
  1. app.py +10 -32
app.py CHANGED
@@ -25,8 +25,7 @@ session_state = {
25
  "report_data": None,
26
  "final_report": None,
27
  "dependencies": None,
28
- "updated_roadmap"
29
- : None
30
  }
31
 
32
 
@@ -91,13 +90,13 @@ def add_test(roadmap, date, physics = [], chemistry = [], maths = []):
91
  return roadmap
92
 
93
  def add_tasks(roadmap, tasks):
94
- from_date = parser.parse(tasks.from_date).strftime("%Y-%m-%d")
95
- to_date = parser.parse(tasks.to_date).strftime("%Y-%m-%d")
96
 
97
  current_date = from_date
98
  date_found = False
99
  while current_date <= to_date:
100
- date_str = current_date
101
 
102
  # Find the day in the roadmap
103
  day = next((d for d in roadmap["schedule"] if d["date"] == date_str), None)
@@ -1278,7 +1277,7 @@ def taskadder(tasks: Tasks):
1278
 
1279
  return {"successful": "Task successfully added to the roadmap"}
1280
 
1281
- @app.get("/taskadditionform", response_class=HTMLResponse)
1282
  def task_form():
1283
  return """
1284
  <!DOCTYPE html>
@@ -1287,25 +1286,13 @@ def task_form():
1287
  <title>Task Scheduler</title>
1288
  <style>
1289
  body { font-family: Arial; padding: 20px; }
1290
- .subject-block, .task-block { border: 1px solid #ccc; padding: 15px; margin-top: 10px; border-radius: 5px; position: relative; }
1291
  .task-block { margin-left: 20px; }
1292
- .remove-btn {
1293
- position: absolute;
1294
- top: 5px;
1295
- right: 5px;
1296
- background: red;
1297
- color: white;
1298
- border: none;
1299
- border-radius: 50%;
1300
- width: 25px;
1301
- height: 25px;
1302
- font-weight: bold;
1303
- cursor: pointer;
1304
- }
1305
  </style>
1306
  </head>
1307
  <body>
1308
- <h2>📅 Task Scheduler</h2>
1309
  <label>From Date: <input type="date" id="from_date"></label>
1310
  <label>To Date: <input type="date" id="to_date"></label>
1311
  <div id="subjects_container"></div>
@@ -1326,11 +1313,6 @@ def task_form():
1326
  subjectSelect.appendChild(opt);
1327
  });
1328
 
1329
- const removeSubjectBtn = document.createElement('button');
1330
- removeSubjectBtn.className = 'remove-btn';
1331
- removeSubjectBtn.innerText = '✕';
1332
- removeSubjectBtn.onclick = () => subjectBlock.remove();
1333
-
1334
  const tasksContainer = document.createElement('div');
1335
  tasksContainer.className = 'tasks-container';
1336
 
@@ -1339,8 +1321,7 @@ def task_form():
1339
  addTaskBtn.type = 'button';
1340
  addTaskBtn.onclick = () => addTask(tasksContainer);
1341
 
1342
- subjectBlock.appendChild(removeSubjectBtn);
1343
- subjectBlock.appendChild(document.createTextNode(" Subject: "));
1344
  subjectBlock.appendChild(subjectSelect);
1345
  subjectBlock.appendChild(addTaskBtn);
1346
  subjectBlock.appendChild(tasksContainer);
@@ -1353,7 +1334,6 @@ def task_form():
1353
  const taskBlock = document.createElement('div');
1354
  taskBlock.className = 'task-block';
1355
  taskBlock.innerHTML = `
1356
- <button class="remove-btn" onclick="this.parentElement.remove()">✕</button>
1357
  Chapter: <input type="text" class="chapter">
1358
  Description: <input type="text" class="description">
1359
  Time (hrs): <input type="number" class="time" min="1">
@@ -1378,9 +1358,7 @@ def task_form():
1378
  estimated_time: parseInt(task.querySelector('.time').value)
1379
  }));
1380
 
1381
- if (tasks.length > 0) {
1382
- subjects.push({ subject: subjectName, tasks });
1383
- }
1384
  });
1385
 
1386
  const data = {
 
25
  "report_data": None,
26
  "final_report": None,
27
  "dependencies": None,
28
+ "updated_roadmap": None
 
29
  }
30
 
31
 
 
90
  return roadmap
91
 
92
  def add_tasks(roadmap, tasks):
93
+ from_date = datetime.strptime(parser.parse(tasks.from_date).strftime("%Y-%m-%d"), "%Y-%m-%d")
94
+ to_date = datetime.strptime(parser.parse(tasks.to_date).strftime("%Y-%m-%d"), "%Y-%m-%d")
95
 
96
  current_date = from_date
97
  date_found = False
98
  while current_date <= to_date:
99
+ date_str = current_date.strftime("%Y-%m-%d")
100
 
101
  # Find the day in the roadmap
102
  day = next((d for d in roadmap["schedule"] if d["date"] == date_str), None)
 
1277
 
1278
  return {"successful": "Task successfully added to the roadmap"}
1279
 
1280
+ @app.get("/taskform", response_class=HTMLResponse)
1281
  def task_form():
1282
  return """
1283
  <!DOCTYPE html>
 
1286
  <title>Task Scheduler</title>
1287
  <style>
1288
  body { font-family: Arial; padding: 20px; }
1289
+ .subject-block, .task-block { border: 1px solid #ccc; padding: 15px; margin-top: 10px; border-radius: 5px; }
1290
  .task-block { margin-left: 20px; }
1291
+ input, select { margin: 5px; }
 
 
 
 
 
 
 
 
 
 
 
 
1292
  </style>
1293
  </head>
1294
  <body>
1295
+ <h2>Task Scheduler</h2>
1296
  <label>From Date: <input type="date" id="from_date"></label>
1297
  <label>To Date: <input type="date" id="to_date"></label>
1298
  <div id="subjects_container"></div>
 
1313
  subjectSelect.appendChild(opt);
1314
  });
1315
 
 
 
 
 
 
1316
  const tasksContainer = document.createElement('div');
1317
  tasksContainer.className = 'tasks-container';
1318
 
 
1321
  addTaskBtn.type = 'button';
1322
  addTaskBtn.onclick = () => addTask(tasksContainer);
1323
 
1324
+ subjectBlock.appendChild(document.createTextNode("Subject: "));
 
1325
  subjectBlock.appendChild(subjectSelect);
1326
  subjectBlock.appendChild(addTaskBtn);
1327
  subjectBlock.appendChild(tasksContainer);
 
1334
  const taskBlock = document.createElement('div');
1335
  taskBlock.className = 'task-block';
1336
  taskBlock.innerHTML = `
 
1337
  Chapter: <input type="text" class="chapter">
1338
  Description: <input type="text" class="description">
1339
  Time (hrs): <input type="number" class="time" min="1">
 
1358
  estimated_time: parseInt(task.querySelector('.time').value)
1359
  }));
1360
 
1361
+ subjects.push({ subject: subjectName, tasks });
 
 
1362
  });
1363
 
1364
  const data = {