73 lines
1.8 KiB
Python
73 lines
1.8 KiB
Python
|
|
from django.contrib import admin
|
||
|
|
|
||
|
|
from apps.profiles.models import (
|
||
|
|
Company,
|
||
|
|
Education,
|
||
|
|
Experience,
|
||
|
|
Profile,
|
||
|
|
ProfileSkill,
|
||
|
|
School,
|
||
|
|
Skill,
|
||
|
|
)
|
||
|
|
|
||
|
|
|
||
|
|
class ExperienceInline(admin.TabularInline):
|
||
|
|
model = Experience
|
||
|
|
extra = 0
|
||
|
|
fields = ("title", "company_name", "start_date", "end_date", "is_primary")
|
||
|
|
readonly_fields = fields
|
||
|
|
can_delete = False
|
||
|
|
show_change_link = True
|
||
|
|
|
||
|
|
|
||
|
|
class EducationInline(admin.TabularInline):
|
||
|
|
model = Education
|
||
|
|
extra = 0
|
||
|
|
fields = ("school_name", "degrees", "majors", "end_date")
|
||
|
|
readonly_fields = fields
|
||
|
|
can_delete = False
|
||
|
|
|
||
|
|
|
||
|
|
class ProfileSkillInline(admin.TabularInline):
|
||
|
|
model = ProfileSkill
|
||
|
|
extra = 0
|
||
|
|
autocomplete_fields = ("skill",)
|
||
|
|
|
||
|
|
|
||
|
|
@admin.register(Profile)
|
||
|
|
class ProfileAdmin(admin.ModelAdmin):
|
||
|
|
list_display = (
|
||
|
|
"full_name", "job_title", "current_company", "location_country", "years_experience",
|
||
|
|
) # fmt: skip
|
||
|
|
list_filter = ("location_country", "job_title_role", "industry")
|
||
|
|
search_fields = ("full_name", "job_title", "skills_text", "companies_text")
|
||
|
|
list_select_related = ("current_company",)
|
||
|
|
inlines = (ProfileSkillInline, ExperienceInline, EducationInline)
|
||
|
|
readonly_fields = (
|
||
|
|
"created_at",
|
||
|
|
"updated_at",
|
||
|
|
"skills_text",
|
||
|
|
"companies_text",
|
||
|
|
"education_text",
|
||
|
|
)
|
||
|
|
|
||
|
|
|
||
|
|
@admin.register(Skill)
|
||
|
|
class SkillAdmin(admin.ModelAdmin):
|
||
|
|
list_display = ("name", "slug", "profile_count")
|
||
|
|
search_fields = ("name", "slug")
|
||
|
|
ordering = ("-profile_count",)
|
||
|
|
|
||
|
|
|
||
|
|
@admin.register(Company)
|
||
|
|
class CompanyAdmin(admin.ModelAdmin):
|
||
|
|
list_display = ("name", "industry", "size", "country")
|
||
|
|
search_fields = ("name",)
|
||
|
|
list_filter = ("size", "industry")
|
||
|
|
|
||
|
|
|
||
|
|
@admin.register(School)
|
||
|
|
class SchoolAdmin(admin.ModelAdmin):
|
||
|
|
list_display = ("name", "type", "country")
|
||
|
|
search_fields = ("name",)
|