Skip to content

Commit

Permalink
add admin
Browse files Browse the repository at this point in the history
  • Loading branch information
jefer94 committed Sep 18, 2024
1 parent e0efb84 commit a8ac365
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 1 deletion.
20 changes: 19 additions & 1 deletion breathecode/notify/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,17 @@
from breathecode.utils import AdminExportCsvMixin

from .actions import send_slack, sync_slack_team_channel
from .models import CohortProxy, Device, HookError, SlackChannel, SlackTeam, SlackUser, SlackUserTeam, UserProxy
from .models import (
CohortProxy,
Device,
HookError,
Notification,
SlackChannel,
SlackTeam,
SlackUser,
SlackUserTeam,
UserProxy,
)
from .tasks import async_slack_team_users
from .utils.hook_manager import HookManager

Expand Down Expand Up @@ -181,3 +191,11 @@ class HookErrorAdmin(admin.ModelAdmin):
list_display = ["event", "message", "created_at", "updated_at"]
search_fields = ["message", "event"]
list_filter = ["event"]


@admin.register(Notification)
class NotificationAdmin(admin.ModelAdmin):
list_display = ("operation_code", "status", "type", "user", "academy", "done_at", "sent_at", "seen_at")
search_fields = ("operation_code", "message", "user__username", "user__email", "academy__name")
list_filter = ("status", "type")
raw_id_fields = ("user", "academy")
65 changes: 65 additions & 0 deletions breathecode/notify/migrations/0013_notification.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# Generated by Django 5.1.1 on 2024-09-18 18:22

import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("admissions", "0064_academy_legal_name"),
("notify", "0012_hookerror"),
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]

operations = [
migrations.CreateModel(
name="Notification",
fields=[
("id", models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
("operation_code", models.CharField(max_length=20)),
("message", models.TextField(blank=True, default=None, null=True)),
("meta", models.JSONField(blank=True, default=None, null=True)),
(
"status",
models.CharField(
choices=[("PENDING", "Pending"), ("DONE", "Done"), ("SENT", "Sent"), ("SEEN", "Seen")],
default="PENDING",
max_length=10,
),
),
(
"type",
models.CharField(
choices=[("INFO", "Info"), ("WARNING", "Warning"), ("ERROR", "Error")],
default="INFO",
max_length=10,
),
),
("done_at", models.DateTimeField(blank=True, default=None, null=True)),
("sent_at", models.DateTimeField(blank=True, default=None, null=True)),
("seen_at", models.DateTimeField(blank=True, default=None, null=True)),
(
"academy",
models.ForeignKey(
blank=True,
default=None,
null=True,
on_delete=django.db.models.deletion.CASCADE,
to="admissions.academy",
),
),
(
"user",
models.ForeignKey(
blank=True,
default=None,
null=True,
on_delete=django.db.models.deletion.CASCADE,
to=settings.AUTH_USER_MODEL,
),
),
],
),
]

0 comments on commit a8ac365

Please sign in to comment.