-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* started on V2 of feedback * Made more tests for retrieveing feedback details * Started working on the filtering for status and status for feedback * started on fix for filter * fixed filtering * format * format * trigger --------- Co-authored-by: Tam Le <[email protected]>
- Loading branch information
Showing
15 changed files
with
362 additions
and
75 deletions.
There are no files selected for viewing
This file contains 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 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 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,46 @@ | ||
from django.db.models import Q | ||
from django_filters import rest_framework as filters | ||
from django_filters.rest_framework import OrderingFilter | ||
|
||
from app.feedback.models import Feedback | ||
from app.feedback.models.bug import Bug | ||
from app.feedback.models.idea import Idea | ||
|
||
|
||
class FeedbackFilter(filters.FilterSet): | ||
feedback_type = filters.CharFilter( | ||
method="filter_feedback_type", label="List of feedback type" | ||
) | ||
|
||
status = filters.CharFilter( | ||
method="filter_status", | ||
label="List of feedback status", | ||
) | ||
|
||
ordering = OrderingFilter( | ||
fields=( | ||
"created_at", | ||
"updated_at", | ||
) | ||
) | ||
|
||
def filter_feedback_type(self, queryset, _name, feedback_type): | ||
if feedback_type == "Idea": | ||
return queryset.filter(Q(instance_of=Idea)) | ||
elif feedback_type == "Bug": | ||
return queryset.filter(Q(instance_of=Bug)) | ||
else: | ||
return queryset | ||
|
||
def filter_status(self, queryset, _name, value): | ||
return queryset.filter(status=value) | ||
|
||
class Meta: | ||
model = Feedback | ||
fields = [ | ||
"title", | ||
"author", | ||
"status", | ||
"created_at", | ||
"updated_at", | ||
] |
32 changes: 32 additions & 0 deletions
32
app/feedback/migrations/0002_alter_feedback_options_bug_browser_bug_platform_and_more.py
This file contains 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,32 @@ | ||
# Generated by Django 4.2.5 on 2024-10-21 18:04 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("feedback", "0001_initial"), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterModelOptions( | ||
name="feedback", | ||
options={"ordering": ("-created_at",)}, | ||
), | ||
migrations.AddField( | ||
model_name="bug", | ||
name="Browser", | ||
field=models.CharField(default="", max_length=200), | ||
), | ||
migrations.AddField( | ||
model_name="bug", | ||
name="Platform", | ||
field=models.CharField(default="", max_length=200), | ||
), | ||
migrations.AddField( | ||
model_name="bug", | ||
name="Url", | ||
field=models.URLField(blank=True, null=True), | ||
), | ||
] |
28 changes: 28 additions & 0 deletions
28
app/feedback/migrations/0003_rename_browser_bug_browser_and_more.py
This file contains 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,28 @@ | ||
# Generated by Django 4.2.5 on 2024-10-21 22:18 | ||
|
||
from django.db import migrations | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("feedback", "0002_alter_feedback_options_bug_browser_bug_platform_and_more"), | ||
] | ||
|
||
operations = [ | ||
migrations.RenameField( | ||
model_name="bug", | ||
old_name="Browser", | ||
new_name="browser", | ||
), | ||
migrations.RenameField( | ||
model_name="bug", | ||
old_name="Platform", | ||
new_name="platform", | ||
), | ||
migrations.RenameField( | ||
model_name="bug", | ||
old_name="Url", | ||
new_name="url", | ||
), | ||
] |
This file contains 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,5 +1,9 @@ | ||
from django.db import models | ||
|
||
from app.feedback.models.feedback import Feedback | ||
|
||
|
||
class Bug(Feedback): | ||
pass | ||
url = models.URLField(max_length=200, blank=True, null=True) | ||
browser = models.CharField(max_length=200, default="") | ||
platform = models.CharField(max_length=200, default="") |
This file contains 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 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,11 @@ | ||
from app.feedback.serializers.bug import BugListSerializer | ||
from app.feedback.serializers.idea import IdeaListSerializer | ||
from app.feedback.serializers.bug import ( | ||
BugDetailSerializer, | ||
BugCreateSerializer, | ||
BugUpdateSerializer, | ||
) | ||
from app.feedback.serializers.idea import ( | ||
IdeaDetailSerializer, | ||
IdeaCreateSerializer, | ||
IdeaUpdateSerializer, | ||
) | ||
from app.feedback.serializers.feedback import FeedbackListPolymorphicSerializer |
This file contains 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 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 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 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
File renamed without changes.
Oops, something went wrong.