-
-
Notifications
You must be signed in to change notification settings - Fork 264
Added TaskLevel Model #1819
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Added TaskLevel Model #1819
Changes from 6 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
579f7fd
Added Task module
Rajgupta36 d95d42a
Update code
Rajgupta36 b3c42aa
Update code
Rajgupta36 488a4af
Added TaskLevel Model
Rajgupta36 0905691
spell fix
Rajgupta36 df2e34f
update code
Rajgupta36 678afcc
resolve conflits
Rajgupta36 38717cb
update code
Rajgupta36 637eca5
updated schema
Rajgupta36 63a5bac
merge upstream into main
Rajgupta36 17d1a7b
update code
Rajgupta36 3f51a6c
update code
Rajgupta36 849b5d7
Merge branch 'main' into schema/task-level
arkid15r File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
102 changes: 102 additions & 0 deletions
102
backend/apps/mentorship/migrations/0002_module_labels_task.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,102 @@ | ||
| # Generated by Django 5.2.4 on 2025-07-23 19:42 | ||
|
|
||
| import django.db.models.deletion | ||
| from django.db import migrations, models | ||
|
|
||
|
|
||
| class Migration(migrations.Migration): | ||
| dependencies = [ | ||
| ("github", "0032_user_github_user_created_at_desc_and_more"), | ||
| ("mentorship", "0001_initial"), | ||
| ] | ||
| operations = [ | ||
| migrations.AddField( | ||
| model_name="module", | ||
| name="labels", | ||
| field=models.JSONField(blank=True, default=list, verbose_name="Labels"), | ||
| ), | ||
| migrations.CreateModel( | ||
| name="Task", | ||
| fields=[ | ||
| ( | ||
| "id", | ||
| models.BigAutoField( | ||
| auto_created=True, | ||
| primary_key=True, | ||
| serialize=False, | ||
| verbose_name="ID", | ||
| ), | ||
| ), | ||
| ("nest_created_at", models.DateTimeField(auto_now_add=True)), | ||
| ("nest_updated_at", models.DateTimeField(auto_now=True)), | ||
| ( | ||
| "assigned_at", | ||
| models.DateTimeField( | ||
| auto_now_add=True, | ||
| help_text="Timestamp when the task was assigned to the mentee.", | ||
| ), | ||
| ), | ||
| ( | ||
| "deadline_at", | ||
| models.DateTimeField( | ||
| blank=True, | ||
| help_text="Optional deadline for the task.", | ||
| null=True, | ||
| ), | ||
| ), | ||
| ( | ||
| "metadata", | ||
| models.JSONField(blank=True, default=dict, help_text="Optional data"), | ||
| ), | ||
| ( | ||
| "status", | ||
| models.CharField( | ||
| choices=[ | ||
| ("TODO", "To Do"), | ||
| ("IN_PROGRESS", "In Progress"), | ||
| ("IN_REVIEW", "In Review"), | ||
| ("COMPLETED", "Completed"), | ||
| ], | ||
| default="TODO", | ||
| max_length=20, | ||
| verbose_name="Task status", | ||
| ), | ||
| ), | ||
| ( | ||
| "assignee", | ||
| models.ForeignKey( | ||
| blank=True, | ||
| help_text="The mentee assigned to this task.", | ||
| null=True, | ||
| on_delete=django.db.models.deletion.SET_NULL, | ||
| related_name="tasks", | ||
| to="github.user", | ||
| ), | ||
| ), | ||
| ( | ||
| "issue", | ||
| models.ForeignKey( | ||
| help_text="The GitHub issue this task corresponds to.", | ||
| on_delete=django.db.models.deletion.PROTECT, | ||
| related_name="mentorship_tasks", | ||
| to="github.issue", | ||
| ), | ||
| ), | ||
| ( | ||
| "module", | ||
| models.ForeignKey( | ||
| help_text="The module this task is part of.", | ||
| on_delete=django.db.models.deletion.CASCADE, | ||
| related_name="tasks", | ||
| to="mentorship.module", | ||
| ), | ||
| ), | ||
| ], | ||
| options={ | ||
| "verbose_name_plural": "Tasks", | ||
| "db_table": "mentorship_tasks", | ||
| "ordering": ["deadline_at"], | ||
| "unique_together": {("issue", "assignee")}, | ||
| }, | ||
| ), | ||
| ] |
65 changes: 65 additions & 0 deletions
65
backend/apps/mentorship/migrations/0003_tasklevel_task_level.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| # Generated by Django 5.2.4 on 2025-07-23 19:51 | ||
|
|
||
| import django.db.models.deletion | ||
| from django.db import migrations, models | ||
|
|
||
|
|
||
| class Migration(migrations.Migration): | ||
| dependencies = [ | ||
| ("mentorship", "0002_module_labels_task"), | ||
| ] | ||
|
|
||
| operations = [ | ||
| migrations.CreateModel( | ||
| name="TaskLevel", | ||
| fields=[ | ||
| ( | ||
| "id", | ||
| models.BigAutoField( | ||
| auto_created=True, primary_key=True, serialize=False, verbose_name="ID" | ||
| ), | ||
| ), | ||
| ( | ||
| "description", | ||
| models.TextField(blank=True, default="", verbose_name="Description"), | ||
| ), | ||
| ("labels", models.JSONField(blank=True, default=list, verbose_name="Labels")), | ||
| ("name", models.CharField(max_length=200, verbose_name="Name")), | ||
| ( | ||
| "module", | ||
| models.ForeignKey( | ||
| on_delete=django.db.models.deletion.CASCADE, | ||
| related_name="task_levels", | ||
| to="mentorship.module", | ||
| verbose_name="Module", | ||
| ), | ||
| ), | ||
| ( | ||
| "needs", | ||
| models.ManyToManyField( | ||
| blank=True, | ||
| related_name="required_by", | ||
| to="mentorship.tasklevel", | ||
| verbose_name="Prerequisite Levels", | ||
| ), | ||
| ), | ||
Rajgupta36 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ], | ||
| options={ | ||
| "verbose_name_plural": "Task Levels", | ||
| "db_table": "mentorship_task_levels", | ||
| "ordering": ["name"], | ||
| }, | ||
| ), | ||
| migrations.AddField( | ||
| model_name="task", | ||
| name="level", | ||
| field=models.ForeignKey( | ||
| blank=True, | ||
| help_text="The difficulty level of this task.", | ||
| null=True, | ||
| on_delete=django.db.models.deletion.SET_NULL, | ||
| related_name="tasks", | ||
| to="mentorship.tasklevel", | ||
| ), | ||
| ), | ||
| ] | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| """Mentorship app start/end range.""" | ||
|
|
||
| from django.db import models | ||
|
|
||
|
|
||
| class Status(models.Model): | ||
| """Defines the possible states of a task.""" | ||
|
|
||
| class Meta: | ||
| abstract = True | ||
|
|
||
| class StatusChoices(models.TextChoices): | ||
| """Status choices.""" | ||
|
|
||
| TODO = "TODO", "To Do" | ||
| IN_PROGRESS = "IN_PROGRESS", "In Progress" | ||
| IN_REVIEW = "IN_REVIEW", "In Review" | ||
| COMPLETED = "COMPLETED", "Completed" | ||
|
|
||
| status = models.CharField( | ||
| max_length=20, | ||
| choices=StatusChoices.choices, | ||
| default=StatusChoices.TODO, | ||
| verbose_name="Task status", | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| """Task model for the Mentorship app.""" | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| from django.db import models | ||
|
|
||
| from apps.common.models import TimestampedModel | ||
|
|
||
|
|
||
| class Task(TimestampedModel): | ||
| """Connects a Module, a GitHub Issue, and a Mentee to track work.""" | ||
|
|
||
| class Meta: | ||
| db_table = "mentorship_tasks" | ||
| verbose_name_plural = "Tasks" | ||
| unique_together = ("issue", "assignee") | ||
| ordering = ["deadline_at"] | ||
Rajgupta36 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| class StatusChoices(models.TextChoices): | ||
| """Status choices.""" | ||
|
|
||
| TODO = "TODO", "To Do" | ||
| IN_PROGRESS = "IN_PROGRESS", "In Progress" | ||
| IN_REVIEW = "IN_REVIEW", "In Review" | ||
| COMPLETED = "COMPLETED", "Completed" | ||
|
|
||
| # FKs. | ||
| assignee = models.ForeignKey( | ||
| "github.User", | ||
| on_delete=models.SET_NULL, | ||
| null=True, | ||
| blank=True, | ||
| related_name="tasks", | ||
| help_text="The mentee assigned to this task.", | ||
| ) | ||
|
|
||
| issue = models.ForeignKey( | ||
| "github.Issue", | ||
| on_delete=models.PROTECT, | ||
| related_name="mentorship_tasks", | ||
| help_text="The GitHub issue this task corresponds to.", | ||
| ) | ||
|
|
||
| level = models.ForeignKey( | ||
| "mentorship.TaskLevel", | ||
| null=True, | ||
| blank=True, | ||
| on_delete=models.SET_NULL, | ||
| related_name="tasks", | ||
| help_text="The difficulty level of this task.", | ||
| ) | ||
|
|
||
| module = models.ForeignKey( | ||
| "mentorship.Module", | ||
| on_delete=models.CASCADE, | ||
| related_name="tasks", | ||
| help_text="The module this task is part of.", | ||
| ) | ||
|
|
||
| assigned_at = models.DateTimeField( | ||
| auto_now_add=True, | ||
| help_text="Timestamp when the task was assigned to the mentee.", | ||
| ) | ||
|
|
||
| deadline_at = models.DateTimeField( | ||
| null=True, blank=True, help_text="Optional deadline for the task." | ||
| ) | ||
|
|
||
| metadata = models.JSONField( | ||
| default=dict, | ||
| blank=True, | ||
| help_text="Optional data", | ||
| ) | ||
|
|
||
| status = models.CharField( | ||
| max_length=20, | ||
| choices=StatusChoices.choices, | ||
| default=StatusChoices.TODO, | ||
| verbose_name="Task status", | ||
| ) | ||
|
|
||
| def __str__(self) -> str: | ||
| """Return a human-readable representation of the task.""" | ||
| return ( | ||
| f"Task for '{self.issue.title}' assigned to {self.assignee.login}" | ||
| if self.assignee | ||
| else f"Task: {self.issue.title} (Unassigned)" | ||
| ) | ||
Rajgupta36 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.