from django.contrib import admin

from .forms import JobPostingForm
from .models import JobPosting


class JobPostingAdmin(admin.ModelAdmin):
    form = JobPostingForm
    model = JobPosting

    list_display = [
        "company_name",
        "job_name",
        "salary",
        "number_of_hours",
        "publish_date",
    ]

    def add_view(self, request, form_url="", extra_context=None):
        extra_context = extra_context or {}
        extra_context["help_text"] = "Fette Schriften sind Pflichtfelder."
        return super().add_view(
            request,
            form_url,
            extra_context=extra_context,
        )

    def change_view(self, request, object_id, form_url="", extra_context=None):
        extra_context = extra_context or {}
        extra_context["help_text"] = "Fette Schriften sind Pflichtfelder."
        return super().change_view(
            request,
            object_id,
            form_url,
            extra_context=extra_context,
        )


admin.site.register(JobPosting, JobPostingAdmin)
