-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
261 additions
and
32 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -111,6 +111,7 @@ | |
"apps.polls", | ||
"apps.topicprio", | ||
"apps.debate", | ||
"apps.ai_reports", | ||
) | ||
|
||
MIDDLEWARE = ( | ||
|
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
Empty file.
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,15 @@ | ||
from django.contrib import admin | ||
|
||
from .models import AiReport | ||
|
||
|
||
@admin.register(AiReport) | ||
class AiReportAdmin(admin.ModelAdmin): | ||
model = AiReport | ||
fields = [ | ||
"is_pending", | ||
"category", | ||
"explanation", | ||
"confidence", | ||
] | ||
raw_id_fields = ("comment",) |
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,5 @@ | ||
from django.apps import AppConfig | ||
|
||
|
||
class AiReportsConfig(AppConfig): | ||
name = "apps.ai_reports" |
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,59 @@ | ||
# Generated by Django 3.2.19 on 2023-07-27 15:31 | ||
|
||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
import django.utils.timezone | ||
|
||
|
||
class Migration(migrations.Migration): | ||
initial = True | ||
|
||
dependencies = [ | ||
("a4comments", "0013_set_project"), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name="AiReport", | ||
fields=[ | ||
( | ||
"id", | ||
models.AutoField( | ||
auto_created=True, | ||
primary_key=True, | ||
serialize=False, | ||
verbose_name="ID", | ||
), | ||
), | ||
( | ||
"created", | ||
models.DateTimeField( | ||
default=django.utils.timezone.now, | ||
editable=False, | ||
verbose_name="Created", | ||
), | ||
), | ||
( | ||
"modified", | ||
models.DateTimeField( | ||
blank=True, editable=False, null=True, verbose_name="Modified" | ||
), | ||
), | ||
("is_pending", models.BooleanField(default=True)), | ||
("category", models.CharField(max_length=50)), | ||
("explanation", models.TextField()), | ||
("confidence", models.FloatField(default=0)), | ||
( | ||
"comment", | ||
models.OneToOneField( | ||
on_delete=django.db.models.deletion.CASCADE, | ||
related_name="ai_report", | ||
to="a4comments.comment", | ||
), | ||
), | ||
], | ||
options={ | ||
"abstract": False, | ||
}, | ||
), | ||
] |
Empty file.
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,16 @@ | ||
from django.db import models | ||
|
||
from adhocracy4.comments.models import Comment | ||
from adhocracy4.models.base import TimeStampedModel | ||
|
||
|
||
class AiReport(TimeStampedModel): | ||
is_pending = models.BooleanField(default=True) | ||
category = models.CharField(max_length=50) | ||
explanation = models.TextField() | ||
confidence = models.FloatField(default=0) | ||
comment = models.OneToOneField( | ||
Comment, | ||
on_delete=models.CASCADE, | ||
related_name="ai_report", | ||
) |
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,13 @@ | ||
from rest_framework import serializers | ||
|
||
from apps.ai_reports.models import AiReport | ||
|
||
|
||
class AiReportSerializer(serializers.ModelSerializer): | ||
class Meta: | ||
model = AiReport | ||
fields = ( | ||
"explanation", | ||
"category", | ||
"comment", | ||
) |
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
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,3 @@ | ||
### Added | ||
|
||
- Ai report serializer for comments viewset (#7571) |
Empty file.
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,5 @@ | ||
from pytest_factoryboy import register | ||
|
||
from . import factories | ||
|
||
register(factories.AiReportFactory) |
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,16 @@ | ||
import random | ||
|
||
import factory | ||
|
||
from adhocracy4.test import factories as a4_factories | ||
from apps.ai_reports.models import AiReport | ||
|
||
|
||
class AiReportFactory(factory.django.DjangoModelFactory): | ||
class Meta: | ||
model = AiReport | ||
|
||
category = factory.Faker("word") | ||
explanation = factory.Faker("sentence", nb_words=6) | ||
confidence = random.random() | ||
comment = factory.SubFactory(a4_factories.ModuleFactory) |
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,8 +1,10 @@ | ||
from pytest_factoryboy import register | ||
|
||
from tests.ai_reports.factories import AiReportFactory | ||
from tests.ideas.factories import IdeaFactory | ||
|
||
from .factories import ModeratorCommentFeedbackFactory | ||
|
||
register(AiReportFactory) | ||
register(IdeaFactory) | ||
register(ModeratorCommentFeedbackFactory) |
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,7 +1,9 @@ | ||
from pytest_factoryboy import register | ||
|
||
from tests.ai_reports.factories import AiReportFactory | ||
from tests.ideas.factories import IdeaFactory | ||
from tests.moderatorfeedback.factories import ModeratorCommentFeedbackFactory | ||
|
||
register(IdeaFactory) | ||
register(ModeratorCommentFeedbackFactory) | ||
register(AiReportFactory) |
Oops, something went wrong.