Skip to content

Commit

Permalink
feat: add verification by admin
Browse files Browse the repository at this point in the history
  • Loading branch information
mnqrt committed Aug 25, 2024
1 parent 927f3ee commit 5e82cfb
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
4 changes: 3 additions & 1 deletion main/admin.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from django.contrib import admin
from .models import Calculator, Course, ReviewLike, ScoreComponent, Tag, Profile, Review, ReviewTag
from .models import Calculator, Course, ReviewLike, ScoreComponent, Tag, Profile, Review, ReviewTag, Question, Answer, QuestionImageAdmin, AnswerImageAdmin

# Register your models here.
admin.site.register(Course)
Expand All @@ -10,3 +10,5 @@
admin.site.register(ReviewTag)
admin.site.register(Calculator)
admin.site.register(ScoreComponent)
admin.site.register(Question, QuestionImageAdmin)
admin.site.register(Answer, AnswerImageAdmin)
16 changes: 15 additions & 1 deletion main/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
import environ

from django.utils import timezone
from django.utils.html import format_html
from django.contrib import admin

env = environ.Env()
expires_in = 60*60*7 # 7 Hours
Expand Down Expand Up @@ -260,4 +262,16 @@ class Meta:
unique_together = ('user', 'content_type', 'object_id')

def __str__(self):
return f'{self.user.username} liked {self.content_object}: {self.content_type} {self.object_id}'
return f'{self.user.username} liked {self.content_object}: {self.content_type} {self.object_id}'

class QuestionImageAdmin(admin.ModelAdmin):
def image_tag(self, obj):
return format_html('<img src="{}" style="max-width:200px; max-height:200px"/>'.format(get_attachment_presigned_url(obj.attachment)))

list_display = ['question_text','image_tag',]

class AnswerImageAdmin(admin.ModelAdmin):
def image_tag(self, obj):
return format_html('<img src="{}" style="max-width:200px; max-height:200px"/>'.format(get_attachment_presigned_url(obj.attachment)))

list_display = ['answer_text','image_tag',]

0 comments on commit 5e82cfb

Please sign in to comment.