diff --git a/README.md b/README.md index 55311e3..6381d50 100644 --- a/README.md +++ b/README.md @@ -15,67 +15,97 @@ The ultimate goal of a task management application is to empower users to manage - Language: Python 3.11.3 - Framework: Django 4.0+ - Database: Dbsqlite3 +- Methodology: Test Driven Development # Objectives -- [x] Task Creation and Organization: +### Task Creation and Organization Allow users to create tasks easily and organize them based on different parameters such as due dates, priority, categories, and projects. -- [x] Task Tracking and Status Updates: +### Task Tracking and Status Updates Enable users to track the progress of their tasks, update task statuses (e.g., to-do, in progress, completed), and get a clear overview of tasks that need attention. -- [x] Deadline Management: +### Deadline Management: Help users keep track of task deadlines by providing reminders, notifications, and a clear visualization of upcoming due dates. -- Collaboration and Sharing: +### Collaboration and Sharing: Facilitate collaboration among teams by allowing users to assign tasks to colleagues, share task details, and communicate within the application. -- Time Management: +### Time Management: Provide tools to estimate and track the time required to complete tasks, helping users allocate their time effectively and avoid overloading themselves. -- [x] Prioritization and Sorting: +### Prioritization and Sorting: Allow users to set task priorities and sort tasks based on importance, urgency, or custom criteria, aiding in making informed decisions about task order. -- [x] Customization: +### Customization: Offer flexibility in customizing task categories, labels, tags, and views to match users' preferred workflows and organizational methods. -- Data Visualization and Insights: +### Data Visualization and Insights: Provide visual representations of task distribution, completion rates, and productivity trends, allowing users to gain insights into their task management habits. -- Integration with Calendars and Tools: +### Integration with Calendars and Tools: Integrate with users' calendars and other productivity tools to synchronize task deadlines, meetings, and events. -- Mobile Accessibility: +### Mobile Accessibility: Ensure the application is accessible from mobile devices, allowing users to manage tasks on the go. -- Data Security and Privacy: +### Data Security and Privacy: Prioritize the security and privacy of user data, implementing proper authentication, encryption, and access controls. -- [x] Backup and Sync: +### Backup and Sync: Implement data backup and synchronization features to prevent data loss and ensure tasks are accessible from multiple devices. # ER-Diagram -![TaskFlow](https://github.com/devsylva/TaskFlow-API/assets/67736638/24805d00-68b8-47ab-8da8-3023583e4643) +![TaskFlow (1)](https://github.com/devsylva/TaskFlow-API/assets/67736638/21e56cdc-b00f-449d-9fa4-a9accac86420) + # Getting Started To run the API locally, follow these steps: -1. Clone the repository: `git clone https://github.com/devsylva/TaskFlow-API.git` +1. Clone the repository: + +``` +git clone https://github.com/devsylva/TaskFlow-API.git +``` + +2. Create a virtual environment inside the project directory: -2. Create a virtual environment inside the project directory: `python -m venv venv` +``` +python -m venv venv +``` + +3. Activate the virtual environment: + +``` +source venv/bin/activate +``` -3. Activate the virtual environment: `source venv/bin/activate` +4. Install dependecies: -4. Install dependecies: `pip install -r requirements.txt` +``` +pip install -r requirements.txt +``` 5. Change `.env.templates` in the src/taskflow direct to `.env` and setup your environment variables -6. Setup the database: `python manage.py migrate` +6. Setup the database: + +``` +python manage.py migrate +``` -7. Create a superuser account: `python manage.py createsuperuser` +7. Create a superuser account: -8. Start the development server: `python manage.py runserver` +``` +python manage.py createsuperuser +``` + +8. Start the development server: + +``` +python manage.py runserver +``` # Running Tests @@ -87,7 +117,7 @@ Tests are organized into different files within the app's tests directory. Here' python manage.py test ``` -2. To run a single test file, use the following command [replacing `` and `` with the appropriate values]: +2. To run a single test file, use the following command [replacing `` and `` with the appropriate values]: ``` python manage.py test .tests. diff --git a/src/task_app/views.py b/src/task_app/views.py index 6682272..07bc74c 100644 --- a/src/task_app/views.py +++ b/src/task_app/views.py @@ -13,7 +13,7 @@ # Create your views here. class TaskView(APIView): - permission_classes = [IsTaskOwner, IsAuthenticated] + permission_classes = [IsAuthenticated] """ list all task or create a new task """ @@ -27,8 +27,18 @@ def get(self, request, format=None): elif "tag" in request.GET: tag = request.GET["tag"] tagid = get_object_or_404(Tag, user=request.user, name=tag).id - tags = get_list_or_404(Task, user=request.user, tag=tagid) - serializer = TagSerializer(tags, many=True) + tasks = get_list_or_404(Task, user=request.user, tag=tagid) + serializer = TaskSerializer(tasks, many=True) + return Response(serializer.data) + elif "status" in request.GET: + status = request.GET["status"] + tasks = get_list_or_404(Task, user=request.user, status=status) + serializer = TaskSerializer(tasks, many=True) + return Response(serializer.data) + elif "priority" in request.GET: + priority = request.GET["priority"] + tasks = get_list_or_404(Task, user=request.user, priority=int(priority)) + serializer = TaskSerializer(tasks, many=True) return Response(serializer.data) tasks = Task.objects.filter(user=request.user).order_by('priority', 'deadline') diff --git a/src/user_app/views.py b/src/user_app/views.py index f9f968b..2563731 100644 --- a/src/user_app/views.py +++ b/src/user_app/views.py @@ -44,7 +44,11 @@ def signUp(request): user.is_active = False user.save() else: - return Response(serializer.errors, status=status.HTTP_500_INTERNAL_SERVER_ERROR) + return Response({ + "status": "500", + "message": "invalid data provided", + "data":serializer.errors + }, status=status.HTTP_500_INTERNAL_SERVER_ERROR) data = { "status": "success", @@ -62,7 +66,7 @@ class ConfirmEmailView(APIView): def get(self, request, uidb64, token): try: - uid = smart_str(urlsafe_base64_decode(uidb64)) + uid = urlsafe_base64_decode(uidb64).decode() user = get_user_model().objects.get(pk=uid) except (TypeError, ValueError, OverflowError, get_user_model().DoesNotExist): return Response({"error": "Invalid user ID"}, status=400)