IZAAC_BASE - modele jobposting, wymagane biblioteki, ustawienia projektu
All checks were successful
continuous-integration/drone Build is passing

This commit is contained in:
Jakub K 2023-11-11 21:18:23 +01:00
parent dacc0e8c98
commit 16598a03ea
10 changed files with 143 additions and 1 deletions

6
core/urls.py Normal file
View File

@ -0,0 +1,6 @@
from django.urls import path, include
urlpatterns = [
path("api/v1/", include('dj_rest_auth.urls')),
path('api/v1/registration/', include('dj_rest_auth.registration.urls')),
]

View File

@ -28,6 +28,16 @@ DEBUG = True
ALLOWED_HOSTS = ['izaac.izaac.pl', 'localhost', '127.0.0.1']
REST_FRAMEWORK = {
'DEFAULT_AUTHENTICATION_CLASSES': [
'rest_framework.authentication.SessionAuthentication',
'rest_framework.authentication.TokenAuthentication',
],
'DEFAULT_PERMISSION_CLASSES': [
'rest_framework.permissions.IsAuthenticated',
],
}
# Application definition
INSTALLED_APPS = [
@ -37,10 +47,24 @@ INSTALLED_APPS = [
"django.contrib.sessions",
"django.contrib.messages",
"django.contrib.staticfiles",
'django.contrib.sites',
"rest_framework",
"rest_framework.authtoken",
"dj_rest_auth",
'allauth',
'allauth.account',
'allauth.socialaccount',
'dj_rest_auth.registration',
"core",
"jobposting",
]
SITE_ID = 1
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend' # Do testów lokalnych
ACCOUNT_EMAIL_VERIFICATION = 'none' # Lub 'mandatory' jeśli chcesz wymagać weryfikacji e-mail
MIDDLEWARE = [
"django.middleware.security.SecurityMiddleware",
"django.contrib.sessions.middleware.SessionMiddleware",
@ -49,6 +73,7 @@ MIDDLEWARE = [
"django.contrib.auth.middleware.AuthenticationMiddleware",
"django.contrib.messages.middleware.MessageMiddleware",
"django.middleware.clickjacking.XFrameOptionsMiddleware",
"allauth.account.middleware.AccountMiddleware",
]
ROOT_URLCONF = "izaac.urls"
@ -71,6 +96,40 @@ TEMPLATES = [
WSGI_APPLICATION = "izaac.wsgi.application"
REST_AUTH = {
'LOGIN_SERIALIZER': 'dj_rest_auth.serializers.LoginSerializer',
'TOKEN_SERIALIZER': 'dj_rest_auth.serializers.TokenSerializer',
'JWT_SERIALIZER': 'dj_rest_auth.serializers.JWTSerializer',
'JWT_SERIALIZER_WITH_EXPIRATION': 'dj_rest_auth.serializers.JWTSerializerWithExpiration',
'JWT_TOKEN_CLAIMS_SERIALIZER': 'rest_framework_simplejwt.serializers.TokenObtainPairSerializer',
'USER_DETAILS_SERIALIZER': 'dj_rest_auth.serializers.UserDetailsSerializer',
'PASSWORD_RESET_SERIALIZER': 'dj_rest_auth.serializers.PasswordResetSerializer',
'PASSWORD_RESET_CONFIRM_SERIALIZER': 'dj_rest_auth.serializers.PasswordResetConfirmSerializer',
'PASSWORD_CHANGE_SERIALIZER': 'dj_rest_auth.serializers.PasswordChangeSerializer',
'REGISTER_SERIALIZER': 'dj_rest_auth.registration.serializers.RegisterSerializer',
'REGISTER_PERMISSION_CLASSES': ('rest_framework.permissions.AllowAny',),
'TOKEN_MODEL': 'rest_framework.authtoken.models.Token',
'TOKEN_CREATOR': 'dj_rest_auth.utils.default_create_token',
'PASSWORD_RESET_USE_SITES_DOMAIN': False,
'OLD_PASSWORD_FIELD_ENABLED': False,
'LOGOUT_ON_PASSWORD_CHANGE': False,
'SESSION_LOGIN': True,
'USE_JWT': False,
'JWT_AUTH_COOKIE': None,
'JWT_AUTH_REFRESH_COOKIE': None,
'JWT_AUTH_REFRESH_COOKIE_PATH': '/',
'JWT_AUTH_SECURE': False,
'JWT_AUTH_HTTPONLY': True,
'JWT_AUTH_SAMESITE': 'Lax',
'JWT_AUTH_RETURN_EXPIRATION': False,
'JWT_AUTH_COOKIE_USE_CSRF': False,
'JWT_AUTH_COOKIE_ENFORCE_CSRF_ON_UNAUTHENTICATED': False,
}
# Database
# https://docs.djangoproject.com/en/4.1/ref/settings/#databases

0
jobposting/__init__.py Normal file
View File

3
jobposting/admin.py Normal file
View File

@ -0,0 +1,3 @@
from django.contrib import admin
# Register your models here.

6
jobposting/apps.py Normal file
View File

@ -0,0 +1,6 @@
from django.apps import AppConfig
class JobpostingConfig(AppConfig):
default_auto_field = "django.db.models.BigAutoField"
name = "jobposting"

View File

60
jobposting/models.py Normal file
View File

@ -0,0 +1,60 @@
from django.db import models
from django.contrib.auth.models import User
from django.utils import timezone
class JobListing(models.Model):
status_choices = [
('A', 'Aktywna'),
('C', 'Zakończona'),
('W', 'Oczekująca na sprawdzenie'),
('R', 'Zarchiwizowana'),
('','')
]
paid_status = [
('P', 'Oplacona'),
('N', 'Nieoplacona'),
('D', 'Inny status')
]
company_name = models.CharField(max_length=255)
name = models.CharField(max_length=255)
content = models.TextField()
min_salary = models.DecimalField(max_digits=10, decimal_places=2)
max_salary = models.DecimalField(max_digits=10, decimal_places=2)
location = models.CharField(max_length=255)
coordinates = models.CharField(max_length=255) # rozwaz GEODJANGO
created_by = models.ForeignKey(User, on_delete=models.CASCADE, related_name='job_listings')
created_at = models.DateTimeField(default=timezone.now)
status = models.CharField(max_length=1, choices=status_choices, default='A')
status_paid = models.CharField(max_length=1, choices=paid_status, default='N')
category = models.CharField(max_length=255, null=True, blank=True)
expiration_date = models.DateField(null=True, blank=True)
company_description = models.TextField(null=True, blank=True)
# company_logo = models.ImageField(upload_to='company_logos/', null=True, blank=True)
experience_level = models.CharField(max_length=255, null=True, blank=True)
contract_type = models.CharField(max_length=255, null=True, blank=True)
is_remote = models.BooleanField(default=False)
updated_at = models.DateTimeField(auto_now=True)
def __str__(self):
return f"{self.name} at {self.company_name}"
class Skill(models.Model):
name = models.CharField(max_length=255)
proficiency_choices = [
('B', 'Podstawowy'),
('A', 'Zaawansowany'),
('E', 'Ekspert'),
]
proficiency = models.CharField(max_length=1, choices=proficiency_choices)
def __str__(self):
return self.name
class JobSkill(models.Model):
job_listing = models.ForeignKey(JobListing, on_delete=models.CASCADE, related_name='job_skills')
skill = models.ForeignKey(Skill, on_delete=models.CASCADE, related_name='job_skills')
proficiency = models.CharField(max_length=255)
def __str__(self):
return f"{self.skill.name} for {self.job_listing.name} ({self.proficiency})"

3
jobposting/tests.py Normal file
View File

@ -0,0 +1,3 @@
from django.test import TestCase
# Create your tests here.

3
jobposting/views.py Normal file
View File

@ -0,0 +1,3 @@
from django.shortcuts import render
# Create your views here.

View File

@ -1,4 +1,6 @@
django
gunicorn
djangorestframework
psycopg2-binary
psycopg2-binary
django-allauth
dj-rest-auth