Skip to content
Merged

Mvp #59

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
45 changes: 21 additions & 24 deletions backend/controller_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def edit_task_control(
with db_operation() as data_cursor:
data_cursor.execute(
"UPDATE task SET name = ?, description = ?, due = ?, est_day = ?, "
"est_hour = ?, est_min = ?, assigner_uuid = ?, assign_uuid = ?, group_id = ?, "
"est_hour = ?, est_min = ?, assigner_uuid = ?, assign_uuid = ?, group_uuid = ?, "
"recursive = ?, priority = ?, image_path = ?, completed = ? "
"WHERE uuid = ?;",
(
Expand Down Expand Up @@ -151,6 +151,14 @@ def get_user_task_control(self, user_id: str, password: str) -> dict[str, dict]:
username_result = username_cursor.fetchone()
if username_result:
assigner_username = username_result[0]

# Get assignee username
assignee_username = "Unknown"
with db_operation() as username_cursor:
username_cursor.execute("SELECT username FROM user WHERE uuid = ?;", (task[8],))
username_result = username_cursor.fetchone()
if username_result:
assignee_username = username_result[0]

new_task_list[task[0]] = {
"name": task[1],
Expand All @@ -162,17 +170,12 @@ def get_user_task_control(self, user_id: str, password: str) -> dict[str, dict]:
"assigner_id": task[7],
"assigner_username": assigner_username,
"assign_id": task[8],
"assignee_username": assignee_username,
"group_id": task[9],
"completed": bool(task[10]),
<<<<<<< Updated upstream
"priority": int(task[11]) if len(task) > 11 else 0,
"recursive": int(task[12]) if len(task) > 12 else 0,
"image_path": task[13] if len(task) > 13 else "",
=======
"priority": int(task[11]),
"recursive": int(task[12]),
"image_path": task[13],
>>>>>>> Stashed changes
}
return new_task_list

Expand All @@ -192,10 +195,7 @@ def get_group_task_control(
if not Validator().check_user_in_group(user_id=user_id, group_id=group_id):
raise BackendError("Backend Error: User is not in the group", "310")
with db_operation() as data_cursor:
data_cursor.execute(
"SELECT * FROM task WHERE group_id = ?;",
(group_id),
)
data_cursor.execute("SELECT * FROM task WHERE group_uuid = ?;", (group_id,))
task_list: list[tuple] = data_cursor.fetchall()
new_task_list: dict[str, dict] = {}
for task in task_list:
Expand All @@ -207,6 +207,14 @@ def get_group_task_control(
if username_result:
assigner_username = username_result[0]

# Get assignee username
assignee_username = "Unknown"
with db_operation() as username_cursor:
username_cursor.execute("SELECT username FROM user WHERE uuid = ?;", (task[8],))
username_result = username_cursor.fetchone()
if username_result:
assignee_username = username_result[0]

new_task_list[task[0]] = {
"name": task[1],
"description": task[2],
Expand All @@ -217,17 +225,12 @@ def get_group_task_control(
"assigner_id": task[7],
"assigner_username": assigner_username,
"assign_id": task[8],
"assignee_username": assignee_username,
"group_id": task[9],
"completed": bool(task[10]),
<<<<<<< Updated upstream
"priority": int(task[11]) if len(task) > 11 else 0,
"recursive": int(task[12]) if len(task) > 12 else 0,
"image_path": task[13] if len(task) > 13 else "",
=======
"priority": int(task[11]),
"recursive": int(task[12]),
"image_path": task[13],
>>>>>>> Stashed changes
}
return new_task_list

Expand All @@ -249,7 +252,7 @@ def get_completed_task_control(
with db_operation() as data_cursor:
data_cursor.execute(
"SELECT * FROM task WHERE assign_id = ? "
"OR group_id IN (SELECT group_id FROM group_user WHERE user_id = ?) "
"OR group_uuid IN (SELECT group_uuid FROM group_user WHERE user_id = ?) "
"AND completed = 1;",
(
group_id,
Expand Down Expand Up @@ -279,15 +282,9 @@ def get_completed_task_control(
"assign_id": task[8],
"group_id": task[9],
"completed": bool(task[10]),
<<<<<<< Updated upstream
"priority": int(task[11]) if len(task) > 11 else 0,
"recursive": int(task[12]) if len(task) > 12 else 0,
"image_path": task[13] if len(task) > 13 else "",
=======
"priority": int(task[11]),
"recursive": int(task[12]),
"image_path": task[13],
>>>>>>> Stashed changes
}
return new_task_list

Expand Down
16 changes: 16 additions & 0 deletions backend/handler_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,22 @@ def get_user_task_request(self) -> dict[str, dict[str, Any]]:
user_id=user_id, password=password
)

@handle_backend_exceptions
def get_group_task_request(self) -> dict[str, dict[str, Any]]:
"""Gets tasks for a specific group."""
request_data: dict[str, Any] = extract_request_data(
request=self.user_request,
required_fields=["user_id", "group_id", "password"],
)
user_id: str = request_data["user_id"]
group_id: str = request_data["group_id"]
password: str = request_data["password"]
return TaskController().get_group_task_control(
user_id=user_id,
group_id=group_id,
password=password
)

@handle_backend_exceptions
def get_image_request(self) -> str:
"""Gets the image."""
Expand Down
13 changes: 8 additions & 5 deletions backend/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ def handle_signup() -> Response:
@error_handling_decorator("login")
def handle_login() -> Response:
"""Login a user."""
<<<<<<< Updated upstream
user_info: dict[str, str] = UserHandle(request).login_user_request()
# Extract user_id and username
user_id: str = user_info["user_id"]
Expand All @@ -67,10 +66,6 @@ def handle_login() -> Response:
# (Front end expects this and needs it to store user info)
[{"error_no": "0", "message": "success", "user_id": user_id, "username": username}]
)
=======
user_id: str = UserHandle(request).login_user_request()
return jsonify([{"error_no": "0", "message": "success", "user_id": user_id}])
>>>>>>> Stashed changes


@app.route("/edit_user", methods=["POST"])
Expand Down Expand Up @@ -124,6 +119,14 @@ def handle_get_user_task() -> Response:
return jsonify([{"error_no": "0", "message": "success", "tasks": tasks}])


@app.route("/get_group_task", methods=["POST"])
@error_handling_decorator("get_group_task")
def handle_get_group_task() -> Response:
"""Get all tasks for a specific group."""
tasks: dict[str, dict[str, Any]] = TaskHandle(request).get_group_task_request()
return jsonify([{"error_no": "0", "message": "success", "tasks": tasks}])


@app.route("/get_image", methods=["POST"])
@error_handling_decorator("get_image")
def handle_get_image() -> Response:
Expand Down
Empty file.
Empty file.
1 change: 1 addition & 0 deletions msdocs-python-flask-webapp-quickstart
Submodule msdocs-python-flask-webapp-quickstart added at 5bfb67
2 changes: 2 additions & 0 deletions roomiebuddy/lib/common/widget/appbar/appbar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ class TAppBar extends StatelessWidget implements PreferredSizeWidget {
Widget build(BuildContext context) {
return AppBar(
automaticallyImplyLeading: false,
elevation: 0,
backgroundColor: Theme.of(context).appBarTheme.backgroundColor,
leading: showBackArrow
? IconButton(onPressed: () => Get.back(), icon: const Icon(Icons.arrow_back))
: leadingIcon != null
Expand Down
42 changes: 42 additions & 0 deletions roomiebuddy/lib/common/widget/search/task_search_delegate.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import 'package:flutter/material.dart';
import 'package:roomiebuddy/pages/subpages/home/task_detail_page.dart';

class TaskSearchDelegate extends SearchDelegate {
final List<Map<String, dynamic>> tasks;
TaskSearchDelegate({required this.tasks});

@override
List<Widget> buildActions(BuildContext context) =>
[IconButton(icon: const Icon(Icons.clear), onPressed: () => query = '')];

@override
Widget buildLeading(BuildContext context) =>
IconButton(icon: const Icon(Icons.arrow_back), onPressed: () => close(context, null));

@override
Widget buildResults(BuildContext context) {
final results = tasks
.where((task) =>
task['taskName'].toLowerCase().contains(query.toLowerCase()))
.toList();

return ListView.builder(
itemCount: results.length,
itemBuilder: (context, index) => ListTile(
title: Text(results[index]['taskName']),
subtitle: Text('Assigned by: ${results[index]['assignedBy']}'),
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (_) => TaskDetailScreen(task: results[index]),
),
);
},
),
);
}

@override
Widget buildSuggestions(BuildContext context) => buildResults(context);
}
Loading
Loading