video player and model and video guide routing and stuff

This commit is contained in:
Parsa Nazer
2025-02-16 21:42:29 +03:30
parent d8f7be7772
commit 81df30c806
28 changed files with 531 additions and 25 deletions
+30 -2
View File
@@ -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()
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/')