- 
          
- 
                Notifications
    You must be signed in to change notification settings 
- Fork 250
Added Task model #1787
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
      
      
    
      
        
          +211
        
        
          −1
        
        
          
        
      
    
  
  
     Merged
                    Added Task model #1787
Changes from 3 commits
      Commits
    
    
            Show all changes
          
          
            5 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      
    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
    
  
  
    
              
        
          
  
    
      
          
            98 changes: 98 additions & 0 deletions
          
          98 
        
  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,98 @@ | ||
| # Generated by Django 5.2.4 on 2025-07-23 08:44 | ||
|  | ||
| 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)), | ||
| ( | ||
| "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", | ||
| ), | ||
| ), | ||
| ( | ||
| "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"), | ||
| ), | ||
| ( | ||
| "assignee", | ||
| models.ForeignKey( | ||
| blank=True, | ||
| help_text="The GitHub user 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")}, | ||
| }, | ||
| ), | ||
| ] | ||
  
    
      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 | 
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| from .experience_level import ExperienceLevel | ||
| from .matching_attributes import MatchingAttributes | ||
| from .start_end_range import StartEndRange | ||
| from .status import 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
    
  
  
    
              | 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,65 @@ | ||
| """Task model for the Mentorship app.""" | ||
|  | ||
| from __future__ import annotations | ||
|  | ||
| from django.db import models | ||
|  | ||
| from apps.common.models import TimestampedModel | ||
| from apps.mentorship.models.common import Status | ||
|  | ||
|  | ||
| class Task(Status, 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"] | ||
|  | ||
| # 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.", | ||
| ) | ||
|  | ||
| 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", | ||
| ) | ||
|  | ||
| 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)" | ||
| ) | 
  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.