diff --git a/core/urls.py b/core/urls.py new file mode 100644 index 0000000..ad99771 --- /dev/null +++ b/core/urls.py @@ -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')), +] diff --git a/izaac/settings.py b/izaac/settings.py index 524de5e..0266369 100644 --- a/izaac/settings.py +++ b/izaac/settings.py @@ -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 diff --git a/jobposting/__init__.py b/jobposting/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/jobposting/admin.py b/jobposting/admin.py new file mode 100644 index 0000000..8c38f3f --- /dev/null +++ b/jobposting/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/jobposting/apps.py b/jobposting/apps.py new file mode 100644 index 0000000..e47013e --- /dev/null +++ b/jobposting/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class JobpostingConfig(AppConfig): + default_auto_field = "django.db.models.BigAutoField" + name = "jobposting" diff --git a/jobposting/migrations/__init__.py b/jobposting/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/jobposting/models.py b/jobposting/models.py new file mode 100644 index 0000000..ba6e529 --- /dev/null +++ b/jobposting/models.py @@ -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})" diff --git a/jobposting/tests.py b/jobposting/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/jobposting/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/jobposting/views.py b/jobposting/views.py new file mode 100644 index 0000000..91ea44a --- /dev/null +++ b/jobposting/views.py @@ -0,0 +1,3 @@ +from django.shortcuts import render + +# Create your views here. diff --git a/requirements.txt b/requirements.txt index e45b4ed..cba7d94 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,6 @@ django gunicorn djangorestframework -psycopg2-binary \ No newline at end of file +psycopg2-binary +django-allauth +dj-rest-auth \ No newline at end of file