+ {% block form_before %}{% endblock %}
+
+
+
+ {{original.icon}}
+ اموزش بخش {{original.content_type}}
+
+
+
+
+ {% component "unfold/components/flex.html" with class="flex-col gap-4 lg:flex-row" %}
+ {% component "unfold/components/button.html" with href=original.section_url %}
+ نمایش بخش مربوطه
+ {% endcomponent %}
+ {% endcomponent %}
+
+
+ {% if adminform.model_admin.change_form_outer_before_template %}
+ {% include adminform.model_admin.change_form_outer_before_template %}
+ {% endif %}
+
+
+ {% if original and original.video %}
+
+
+
+
+ {% else %}
+
no video available.
+ {% endif %}
+
+
+
+
+ {% if request.user.video_uploader %}
+
+ {% endif %}
+ {% if adminform.model_admin.change_form_outer_after_template %}
+ {% include adminform.model_admin.change_form_outer_after_template %}
+ {% endif %}
+
+ {% block form_after %}{% endblock %}
+
+{% endblock %}
\ No newline at end of file
diff --git a/backend/ticket/admin.py b/backend/ticket/admin.py
index 121c965..5ae80c6 100644
--- a/backend/ticket/admin.py
+++ b/backend/ticket/admin.py
@@ -1,6 +1,6 @@
from django.contrib import admin
from .models import *
-from unfold.admin import ModelAdmin, TabularInline
+from unfold.admin import TabularInline
from import_export.admin import ImportExportModelAdmin
from unfold.contrib.import_export.forms import ExportForm, ImportForm, SelectableFieldsExportForm
@@ -10,7 +10,7 @@ from unfold.contrib.filters.admin import (
ChoicesDropdownFilter,
MultipleChoicesDropdownFilter,
)
-
+from utils.admin import ModelAdmin
diff --git a/backend/ticket/migrations/0008_alter_ticket_ticket_category.py b/backend/ticket/migrations/0008_alter_ticket_ticket_category.py
new file mode 100644
index 0000000..e700fbb
--- /dev/null
+++ b/backend/ticket/migrations/0008_alter_ticket_ticket_category.py
@@ -0,0 +1,18 @@
+# Generated by Django 5.1.2 on 2025-02-14 21:23
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('ticket', '0007_alter_ticket_ticket_category'),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ model_name='ticket',
+ name='ticket_category',
+ field=models.CharField(choices=[('finance_and_accounting', 'مالی و حسابداری'), ('user_profile', 'پروفایل کاربری'), ('order_tracking', 'پیگیری سفارش'), ('authentication', 'احراز هویت'), ('product', 'محصول'), ('bug_and_error_reporting', 'اعلام باگ و خطا در وبسایت'), ('other', 'سایر')], max_length=30, verbose_name='دسته بندی تیکت'),
+ ),
+ ]
diff --git a/backend/utils/admin.py b/backend/utils/admin.py
index 61cabce..67786f3 100644
--- a/backend/utils/admin.py
+++ b/backend/utils/admin.py
@@ -1,7 +1,7 @@
from order.models import OrderModel
from product.models import DollorModel, CommentModel
from ticket.models import Ticket
-
+from home.models import LearnVideoModel
def admin_pending_count(request):
pending_count = OrderModel.objects.filter(status='ADMIN_PENDING').count()
@@ -15,4 +15,32 @@ def comment_count(request):
return CommentModel.objects.filter(review_status='not_reviwed').count()
def new_ticket_count(request):
- return Ticket.objects.filter(status__in=['open', 'in_progress']).count()
\ No newline at end of file
+ return Ticket.objects.filter(status__in=['open', 'in_progress']).count()
+
+def new_learn_video_count(request):
+ return LearnVideoModel.objects.filter(viewd=False).count()
+
+
+from django.contrib import admin, messages
+from unfold.admin import ModelAdmin
+from home.models import LearnVideoModel
+from import_export.admin import ImportExportModelAdmin
+from unfold.contrib.import_export.forms import ExportForm, ImportForm, SelectableFieldsExportForm
+from unfold.decorators import action, display
+from django.shortcuts import redirect
+from django.contrib.contenttypes.models import ContentType
+
+
+class ModelAdmin(ModelAdmin):
+ actions_list = ['redirect_to_learn']
+ @action(description=f"چگونگی استفاده این بخش")
+ def redirect_to_learn(self, request):
+ content_type = ContentType.objects.get_for_model(self.model)
+ try:
+ learn_video = LearnVideoModel.objects.get(
+ content_type=content_type,
+ )
+ return redirect(f'/admin/home/learnvideomodel/{learn_video.id}/change/')
+ except Exception as e:
+ messages.error(request, f"برای بخش {content_type} ویدیویی اپلود نشده است")
+ return redirect(f'/admin/home/learnvideomodel/')
\ No newline at end of file