-
Notifications
You must be signed in to change notification settings - Fork 0
/
models.py
83 lines (65 loc) · 5.25 KB
/
models.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# models.py
from django.db import models
from django.http import HttpResponse
from datetime import date
from django.contrib.auth.models import BaseUserManager, AbstractBaseUser
# Create your models here.
def HomePage(request):
return HttpResponse("<h1>Hello World</h1>")
class CustomUserManager(BaseUserManager):
def create_user(self, email, username, password=None):
if not email:
raise ValueError("Users must have an email address")
if not username:
raise ValueError("Users must have a username")
user = self.model(
email=self.normalize_email(email),
username=username,
)
user.set_password(password)
user.save(using=self._db)
return user
def create_superuser(self, email, username, password=None):
user = self.create_user(
email,
username=username,
password=password,
)
user.is_admin = True
user.save(using=self._db)
return user
class CustomUser(AbstractBaseUser):
username = models.CharField(max_length=30, unique=True)
email = models.EmailField(max_length=255, unique=True)
objects = CustomUserManager()
USERNAME_FIELD = 'email'
REQUIRED_FIELDS = ['username']
def __str__(self):
return self.email
def has_perm(self, perm, obj=None):
return True
def has_module_perms(self, app_label):
return True
@property
def is_staff(self):
return self.is_admin
class JobListing(models.Model):
id = models.BigAutoField(primary_key=True)
company_name = models.CharField(max_length=100)
job_title = models.CharField(max_length=100)
location = models.CharField(max_length=100)
salary = models.CharField(max_length=50)
overview = models.TextField(default="") # Provide a default value here
requirements = models.TextField(default="") # Provide a default value here
responsibilities = models.TextField()
skills_needed = models.TextField()
image = models.CharField(max_length=100, blank=True)
date_added = models.DateField(default=date.today)
last_day_to_apply = models.DateField(default=date.today)
experience_level = models.CharField(max_length=50, default='Mid')
remote = models.CharField(max_length=50, default='Hybrid')
job_type = models.CharField(max_length=50, default='Full-time')
industry = models.CharField(max_length=100, default='Null')
category = models.CharField(max_length=100, default='General')
def __str__(self):
return self.job_title