from django.contrib import admin
from datetime import datetime
# Register your models here.
from ggongsul.challenge.models import Challenge


@admin.register(Challenge)
class ChallengeAdmin(admin.ModelAdmin):
    readonly_fields = ("created_on", "updated_on")
    list_display = ("name", "type", "start_date", "end_date", "winner_count", "status")

    def status(self, obj):
        now = datetime.now()
        status = '진행 전'
        # 진행 중
        if obj.start_date < now < obj.end_date:
            status = '진행 중'
        elif obj.end_date < now:
            status = '종료'

        return status

    status.short_description = '진행 상태'




from django.contrib import admin
from datetime import datetime
# Register your models here.
from ggongsul.challenge.models import Challenge


@admin.register(Challenge)
class ChallengeAdmin(admin.ModelAdmin):
    readonly_fields = ("created_on", "updated_on")
    list_display = ("name", "type", "start_date", "end_date", "winner_count", "status")

    def status(self, obj):
        now = datetime.now()
        status = '진행 전'
        # 진행 중
        if obj.start_date < now < obj.end_date:
            status = '진행 중'
        elif obj.end_date < now:
            status = '종료'

        return status

    status.short_description = '진행 상태'




# Register your models here. # 진행 중