-
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.
Merge pull request #41 from OZ-Coding-School/dev
Dev -> main 관리자 페이지 알림, popular 태그
- Loading branch information
Showing
36 changed files
with
693 additions
and
18 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
File renamed without changes.
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,29 @@ | ||
from django.contrib import admin | ||
|
||
from .models import PaymentNotification, QuestionNotification | ||
|
||
|
||
@admin.register(QuestionNotification) | ||
class QuestionNotificationAdmin(admin.ModelAdmin): | ||
list_display = ("message", "class_field", "created_at", "is_read") | ||
list_filter = ("is_read", "question__class_id") | ||
search_fields = ("message", "question__class_id__title") | ||
|
||
def class_field(self, obj): | ||
return obj.question.class_id.title | ||
|
||
class_field.admin_order_field = "question__class_id__title" # type: ignore | ||
class_field.short_description = "Class Title" # type: ignore | ||
|
||
|
||
@admin.register(PaymentNotification) | ||
class PaymentNotificationAdmin(admin.ModelAdmin): | ||
list_display = ("message", "payment_method", "created_at", "is_read") | ||
list_filter = ("is_read", "payment__payment_method") | ||
search_fields = ("message", "payment__order_id") | ||
|
||
def payment_method(self, obj): | ||
return obj.payment.payment_method | ||
|
||
payment_method.admin_order_field = "payment__payment_method" # type: ignore | ||
payment_method.short_description = "Payment Method" # type: ignore |
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,6 @@ | ||
from django.apps import AppConfig | ||
|
||
|
||
class NotificationsConfig(AppConfig): | ||
default_auto_field = "django.db.models.BigAutoField" | ||
name = "notifications" |
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,44 @@ | ||
# Generated by Django 5.1 on 2024-09-06 05:59 | ||
|
||
import django.db.models.deletion | ||
import django.utils.timezone | ||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
initial = True | ||
|
||
dependencies = [ | ||
("questions", "0006_remove_question_answer_user_id_alter_question_answer"), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name="Notification", | ||
fields=[ | ||
( | ||
"id", | ||
models.BigAutoField( | ||
auto_created=True, | ||
primary_key=True, | ||
serialize=False, | ||
verbose_name="ID", | ||
), | ||
), | ||
("created_at", models.DateTimeField(default=django.utils.timezone.now)), | ||
("updated_at", models.DateTimeField(auto_now=True)), | ||
("message", models.CharField(max_length=255)), | ||
("is_read", models.BooleanField(default=False)), | ||
( | ||
"question", | ||
models.ForeignKey( | ||
on_delete=django.db.models.deletion.CASCADE, | ||
to="questions.question", | ||
), | ||
), | ||
], | ||
options={ | ||
"abstract": False, | ||
}, | ||
), | ||
] |
11 changes: 11 additions & 0 deletions
11
customk/notifications/migrations/0002_auto_20240906_1518.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,11 @@ | ||
# Generated by Django 5.1 on 2024-09-06 06:18 | ||
|
||
from django.db import migrations | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("notifications", "0001_initial"), | ||
] | ||
|
||
operations = [] |
11 changes: 11 additions & 0 deletions
11
customk/notifications/migrations/0003_auto_20240906_1550.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,11 @@ | ||
# Generated by Django 5.1 on 2024-09-06 06:50 | ||
|
||
from django.db import migrations | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("notifications", "0002_auto_20240906_1518"), | ||
] | ||
|
||
operations = [] |
62 changes: 62 additions & 0 deletions
62
customk/notifications/migrations/0004_rename_notification_paymentnotification_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,62 @@ | ||
# Generated by Django 5.1 on 2024-09-08 12:36 | ||
|
||
import django.db.models.deletion | ||
import django.utils.timezone | ||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("notifications", "0003_auto_20240906_1550"), | ||
("payments", "0002_payment_refunded_amount"), | ||
("questions", "0006_remove_question_answer_user_id_alter_question_answer"), | ||
] | ||
|
||
operations = [ | ||
migrations.RenameModel( | ||
old_name="Notification", | ||
new_name="PaymentNotification", | ||
), | ||
migrations.RemoveField( | ||
model_name="paymentnotification", | ||
name="question", | ||
), | ||
migrations.AddField( | ||
model_name="paymentnotification", | ||
name="payment", | ||
field=models.ForeignKey( | ||
default="", | ||
on_delete=django.db.models.deletion.CASCADE, | ||
to="payments.payment", | ||
), | ||
preserve_default=False, | ||
), | ||
migrations.CreateModel( | ||
name="QuestionNotification", | ||
fields=[ | ||
( | ||
"id", | ||
models.BigAutoField( | ||
auto_created=True, | ||
primary_key=True, | ||
serialize=False, | ||
verbose_name="ID", | ||
), | ||
), | ||
("created_at", models.DateTimeField(default=django.utils.timezone.now)), | ||
("updated_at", models.DateTimeField(auto_now=True)), | ||
("message", models.CharField(max_length=255)), | ||
("is_read", models.BooleanField(default=False)), | ||
( | ||
"question", | ||
models.ForeignKey( | ||
on_delete=django.db.models.deletion.CASCADE, | ||
to="questions.question", | ||
), | ||
), | ||
], | ||
options={ | ||
"abstract": False, | ||
}, | ||
), | ||
] |
23 changes: 23 additions & 0 deletions
23
customk/notifications/migrations/0005_alter_paymentnotification_payment.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,23 @@ | ||
# Generated by Django 5.1 on 2024-09-08 12:41 | ||
|
||
import django.db.models.deletion | ||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("notifications", "0004_rename_notification_paymentnotification_and_more"), | ||
("payments", "0002_payment_refunded_amount"), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name="paymentnotification", | ||
name="payment", | ||
field=models.ForeignKey( | ||
null=True, | ||
on_delete=django.db.models.deletion.CASCADE, | ||
to="payments.payment", | ||
), | ||
), | ||
] |
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,27 @@ | ||
from django.db import models | ||
|
||
from common.models import CommonModel | ||
from payments.models import Payment | ||
from questions.models import Question | ||
|
||
|
||
class QuestionNotification(CommonModel): | ||
message = models.CharField(max_length=255) | ||
question = models.ForeignKey(Question, on_delete=models.CASCADE) | ||
is_read = models.BooleanField(default=False) | ||
|
||
def __str__(self): | ||
return self.message | ||
|
||
|
||
class PaymentNotification(CommonModel): | ||
message = models.CharField(max_length=255) | ||
payment = models.ForeignKey( | ||
Payment, | ||
on_delete=models.CASCADE, | ||
null=True, | ||
) | ||
is_read = models.BooleanField(default=False) | ||
|
||
def __str__(self): | ||
return self.message |
File renamed without changes.
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.urls import path | ||
|
||
from . import views | ||
|
||
urlpatterns = [ | ||
path( | ||
"unread_question_notifications_count/", | ||
views.unread_question_notifications_count, | ||
name="unread_question_notifications_count", | ||
), | ||
path( | ||
"unread_payment_notifications_count/", | ||
views.unread_payment_notifications_count, | ||
name="unread_payment_notifications_count", | ||
), | ||
] |
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 django.http import JsonResponse | ||
|
||
from .models import PaymentNotification, QuestionNotification | ||
|
||
|
||
def unread_question_notifications_count(request): | ||
count = QuestionNotification.objects.filter(is_read=False).count() | ||
return JsonResponse({"count": count}) | ||
|
||
|
||
def unread_payment_notifications_count(request): | ||
count = PaymentNotification.objects.filter(is_read=False).count() | ||
return JsonResponse({"count": count}) |
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,30 @@ | ||
from django.contrib import admin | ||
|
||
from payments.models import ReferralCode | ||
from payments.models import Payment, ReferralCode | ||
|
||
|
||
@admin.register(ReferralCode) | ||
class ReferralCodeAdmin(admin.ModelAdmin): # type: ignore | ||
pass | ||
|
||
|
||
@admin.register(Payment) | ||
class PaymentAdmin(admin.ModelAdmin): | ||
list_display = ( | ||
"order_id", | ||
"status", | ||
"amount", | ||
"refunded_amount", | ||
"currency", | ||
"payment_method", | ||
"payer_email", | ||
"user_id", | ||
"class_id", | ||
"class_date_id", | ||
"quantity", | ||
"referral_code", | ||
"transaction_id", | ||
) | ||
search_fields = ("order_id", "payment_method", "payer_email", "transaction_id") | ||
list_filter = ("status", "currency", "payment_method") | ||
readonly_fields = [field.name for field in Payment._meta.fields] |
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
Oops, something went wrong.