-
-
Save Damephena/02aab806fea24c8a9c8e9c9ee215732c to your computer and use it in GitHub Desktop.
CVEAT: CV Builder
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.contrib import admin | |
from cv import models # new | |
# Register your models here. | |
# METHOD 1 in registering models | |
# admin.site.register(models.ResumeTemplate) | |
# admin.site.register(models.Resume) | |
# METHOD 2 in registering models. | |
# Note the extra brackets "()" | |
admin.site.register(( | |
models.ResumeTemplate, | |
models.Resume, | |
models.EducationHistory, | |
models.EmploymentHistory, | |
models.Qualification, | |
models.Reference, | |
models.Skill, | |
models.WebLink | |
)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.db import models | |
from django.dispatch import receiver | |
from django.contrib.auth.models import User | |
from django.db.models.signals import post_delete | |
class ResumeTemplate(models.Model): | |
''' | |
This is used as the template options for Resume model. | |
''' | |
name = models.CharField(max_length=300) | |
template_image = models.ImageField(upload_to='resume_samples/') | |
def __str__(self): | |
return self.name | |
def save(self, *args, **kwargs): | |
'''Deletes old file when making an update to file''' | |
try: | |
old = ResumeTemplate.objects.get(id=self.id) | |
if old.template_image != self.template_image: | |
old.template_image.delete(save=False) | |
except: | |
pass | |
super().save(*args, **kwargs) | |
class Resume(models.Model): | |
'''Resume model''' | |
user = models.ForeignKey(User, on_delete=models.CASCADE, related_name='resumes') | |
job_title = models.CharField(max_length=200) | |
first_name = models.CharField(max_length=200) | |
last_name = models.CharField(max_length=200) | |
email = models.EmailField() | |
professional_summary = models.TextField() | |
resume_template = models.ForeignKey( | |
ResumeTemplate, | |
on_delete=models.CASCADE | |
) | |
def __str__(self): | |
return self.first_name | |
class EmploymentHistory(models.Model): | |
'''Employment History model could include Internships and other work-related experiences''' | |
resume = models.ForeignKey(Resume, on_delete=models.CASCADE, related_name='employment_histories') | |
role = models.CharField(max_length=200) | |
employer = models.CharField(max_length=200) | |
city = models.CharField(max_length=200) | |
country = models.CharField(max_length=200) | |
description = models.TextField() | |
start_date = models.DateField() | |
end_date = models.DateField(null=True, blank=True) | |
class Meta: | |
verbose_name_plural = 'Empolyment Histories' | |
def __str__(self): | |
return self.role | |
class EducationHistory(models.Model): | |
'''Education history model''' | |
resume = models.ForeignKey(Resume, on_delete=models.CASCADE, related_name='educational_histories') | |
degree = models.CharField(max_length=200) | |
school = models.CharField(max_length=400) | |
city = models.CharField(max_length=200) | |
description = models.TextField() | |
start_date = models.DateField() | |
end_date = models.DateField(null=True, blank=True) | |
class Meta: | |
# To give the model a proper plural form, else, Django names it "Education Historys" | |
verbose_name_plural = 'Education Histories' | |
def __str__(self): | |
return self.degree | |
class WebLink(models.Model): | |
'''Web link model includes Twitter and other social links.''' | |
resume = models.ForeignKey(Resume, on_delete=models.CASCADE, related_name='links') | |
name = models.CharField(max_length=50) | |
link = models.CharField(max_length=1000, blank=False, null=False) | |
def __str__(self): | |
return self.name | |
class Skill(models.Model): | |
'''Skills models which can be technical and non-technical''' | |
resume = models.ForeignKey(Resume, on_delete=models.CASCADE, related_name='skills') | |
name = models.CharField(max_length=100) | |
is_soft_skill = models.BooleanField(default=False, blank=True) | |
def __str__(self): | |
return self.name | |
class Qualification(models.Model): | |
'''Qualifications besides regular education''' | |
resume = models.ForeignKey(Resume, on_delete=models.CASCADE, related_name='qualifications') | |
course = models.CharField(max_length=200, blank=False, null=False) | |
institution = models.CharField(max_length=200, blank=False, null=False) | |
start_date = models.DateField(null=False, blank=False) | |
end_date = models.DateField(null=False, blank=False) | |
def __str__(self): | |
return self.course | |
class Reference(models.Model): | |
'''Reference model holds the resume owner refrees''' | |
resume = models.ForeignKey(Resume, on_delete=models.CASCADE, related_name='references') | |
reference_full_name = models.CharField(max_length=500) | |
company = models.CharField(max_length=1000) | |
phone_number = models.CharField(max_length=17, blank=True, null=True) | |
email = models.EmailField(null=False, blank=False) | |
def __str__(self): | |
return self.reference_full_name |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment