-
-
Notifications
You must be signed in to change notification settings - Fork 260
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 all 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
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,24 @@ | ||
| """Mentorship app TaskLevel model admin.""" | ||
|
|
||
| from django.contrib import admin | ||
|
|
||
| from apps.mentorship.models.task_level import TaskLevel | ||
|
|
||
|
|
||
| class TaskLevelAdmin(admin.ModelAdmin): | ||
| """Admin view for TaskLevel model.""" | ||
|
|
||
| list_display = ( | ||
| "description", | ||
| "labels", | ||
| "module", | ||
| "name", | ||
| ) | ||
|
|
||
| search_fields = ( | ||
| "name", | ||
| "module__name", | ||
| ) | ||
|
|
||
|
|
||
| admin.site.register(TaskLevel, TaskLevelAdmin) | ||
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
71 changes: 71 additions & 0 deletions
71
backend/apps/mentorship/migrations/0003_tasklevel_task_level_and_more.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,71 @@ | ||
| # Generated by Django 5.2.4 on 2025-08-04 16:06 | ||
|
|
||
| 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(default="", 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", | ||
| ), | ||
| ), | ||
| ], | ||
| 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", | ||
| ), | ||
| ), | ||
| migrations.AddConstraint( | ||
| model_name="tasklevel", | ||
| constraint=models.UniqueConstraint( | ||
| fields=("module", "name"), name="unique_module_tasklevel_name" | ||
| ), | ||
| ), | ||
| ] |
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
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,61 @@ | ||
| """TaskLevel model for the Mentorship app.""" | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| from django.db import models | ||
|
|
||
|
|
||
| class TaskLevel(models.Model): | ||
| """Task level model representing difficulty and prerequisites for mentorship tasks.""" | ||
|
|
||
| class Meta: | ||
| db_table = "mentorship_task_levels" | ||
| verbose_name_plural = "Task Levels" | ||
| ordering = ["name"] | ||
| constraints = [ | ||
| models.UniqueConstraint(fields=["module", "name"], name="unique_module_tasklevel_name") | ||
| ] | ||
|
|
||
| description = models.TextField( | ||
| verbose_name="Description", | ||
| blank=True, | ||
| default="", | ||
| ) | ||
|
|
||
| labels = models.JSONField( | ||
| default=list, | ||
| blank=True, | ||
| verbose_name="Labels", | ||
| ) | ||
|
|
||
| name = models.CharField( | ||
| max_length=200, | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| verbose_name="Name", | ||
| default="", | ||
| ) | ||
|
|
||
| # FKs. | ||
| module = models.ForeignKey( | ||
| "mentorship.Module", | ||
| on_delete=models.CASCADE, | ||
| related_name="task_levels", | ||
| verbose_name="Module", | ||
| ) | ||
|
|
||
| # M2Ms. | ||
| needs = models.ManyToManyField( | ||
| "self", | ||
| blank=True, | ||
| symmetrical=False, | ||
| related_name="required_by", | ||
| verbose_name="Prerequisite Levels", | ||
| ) | ||
|
|
||
| def __str__(self) -> str: | ||
| """Return a human-readable representation of the task level. | ||
|
|
||
| Returns: | ||
| str: Module name with task level name. | ||
|
|
||
| """ | ||
| return f"{self.module.name} - {self.name}" | ||
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.