Skip to content
Open

Leo #46

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
dcd42ae
fix(user): simplify username retrieval in User model by removing web3…
leojay-net Apr 28, 2025
349efd3
fix(serializers): require address and signature fields in EthereumAut…
leojay-net Apr 28, 2025
9cb80fe
second fix
leojay-net Apr 28, 2025
f5169ed
fix(user_profile): ensure user is saved during organization and recip…
leojay-net Apr 28, 2025
4e5b656
feat(notifications): add notifications app with models, serializers, …
leojay-net Apr 29, 2025
6b33fb4
feat(user_profile): enhance create method to support updating existin…
leojay-net Apr 29, 2025
1adcab8
feat(recipient_profile): add salary, position, and status fields to R…
leojay-net Apr 29, 2025
847f0bd
feat(payroll): add payroll app with models, serializers, and views fo…
leojay-net Apr 30, 2025
7bdd38a
feat(settings): add JWT configuration for token management and authen…
leojay-net Apr 30, 2025
12998b0
feat(payroll): create initial migration for PayRoll model with fields…
leojay-net Apr 30, 2025
bd8b87e
feat(auth): set expiration for refresh and access tokens in EthereumA…
leojay-net Apr 30, 2025
af577b0
feat(payroll): implement payroll management with CRUD operations, val…
leojay-net Apr 30, 2025
0ee5e52
feat(auth): update JWT token lifetimes and customize token creation i…
leojay-net Apr 30, 2025
4b3ecb5
feat(auth): refactor token creation to use user instance and correctl…
leojay-net Apr 30, 2025
6cc8a68
feat(auth): update JWT settings for access and refresh token lifetime…
leojay-net Apr 30, 2025
d838acc
feat(payroll): enhance validation message and clarify duplicate payro…
leojay-net Apr 30, 2025
0d61f76
feat(profile): update recipient profile creation logic and improve ba…
leojay-net May 1, 2025
c9b7d3e
feat(recipient): create user for recipient during profile creation an…
leojay-net May 1, 2025
798af8e
feat(recipient): streamline recipient profile creation and enhance er…
leojay-net May 1, 2025
4c2cc4b
feat(recipient): implement recipient profile creation with organizati…
leojay-net May 1, 2025
1022f13
feat(recipient): update recipient profile serializer to include user_…
leojay-net May 1, 2025
59ee8af
feat(user_profile): update recipient and organization profiles with u…
leojay-net May 6, 2025
06ff06d
Merge branch 'leo' of https://github.com/Web3-gen/Backend into leo
leojay-net May 6, 2025
cf6aab1
feat(recipient_profile): update recipient profile creation endpoint a…
leojay-net May 6, 2025
1d8f016
feat(user_auth): enhance user model with 'both' user type; update ser…
leojay-net May 7, 2025
003d1dd
feat(recipient_profile): change user field from OneToOneField to Fore…
leojay-net May 13, 2025
d0c0893
feat(recipient_profile): enhance recipient profile creation with user…
leojay-net May 14, 2025
659b9e0
feat(recipient_profile): update recipient profile serializer and view…
leojay-net May 14, 2025
b7419e3
feat(payroll): change amount field from DecimalField to BigIntegerFie…
web-ghost-dotcom May 15, 2025
57e6589
feat(leaveRequest): add leave request model, views, serializers, and …
web-ghost-dotcom May 17, 2025
32c2690
feat(leaveRequest): enhance get_leave_requests to filter by user type…
web-ghost-dotcom May 18, 2025
add7425
feat(recipient_profile): update permission handling for recipient pro…
web-ghost-dotcom May 18, 2025
7875e6c
feat(leaveRequest): enforce recipient privileges for leave request cr…
web-ghost-dotcom May 21, 2025
85545cf
refactor(leaveRequest): remove redundant comment when retrieving reci…
web-ghost-dotcom May 21, 2025
ae273c1
feat(leaveRequest): enhance leave request handling with improved user…
web-ghost-dotcom May 21, 2025
86038f6
feat(leaveRequest): update get_leave_requests description to include …
web-ghost-dotcom May 21, 2025
a023a2e
feat(payroll): enhance payroll operations with notification creation …
web-ghost-dotcom May 23, 2025
03d16a8
fix(verifyAddress): change response status to 200 for non-existent us…
web-ghost-dotcom May 24, 2025
36837c9
fix(payroll): update notification message to use organization name in…
leojay-net May 29, 2025
4424333
refactor(payroll): clean up serializer code and remove duplicate payr…
leojay-net May 29, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions HR_Backend/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import os
from decouple import config
from dotenv import load_dotenv
from django.utils.timezone import timedelta
# Load environment variables from .env file
load_dotenv()

Expand Down Expand Up @@ -46,6 +47,9 @@
'waitlist.apps.WaitlistConfig',
'web3auth.apps.Web3AuthConfig',
'user_profile.apps.UserProfileConfig',
'notifications.apps.NotificationsConfig',
'payroll.apps.PayrollConfig',
'leaveRequest.apps.LeaverequestConfig',

# Third-party apps
'corsheaders',
Expand Down Expand Up @@ -188,4 +192,44 @@

AUTH_USER_MODEL = 'web3auth.User'

SIMPLE_JWT = {
"ACCESS_TOKEN_LIFETIME": timedelta(minutes=300),
"REFRESH_TOKEN_LIFETIME": timedelta(days=2),
"ROTATE_REFRESH_TOKENS": True,
"BLACKLIST_AFTER_ROTATION": True,
"UPDATE_LAST_LOGIN": True,

"ALGORITHM": "HS256",
"SIGNING_KEY": SECRET_KEY,
"VERIFYING_KEY": "",
"AUDIENCE": None,
"ISSUER": None,
"JSON_ENCODER": None,
"JWK_URL": None,
"LEEWAY": 0,

"AUTH_HEADER_TYPES": ("Bearer",),
"AUTH_HEADER_NAME": "HTTP_AUTHORIZATION",
"USER_ID_FIELD": "id",
"USER_ID_CLAIM": "user_id",
"USER_AUTHENTICATION_RULE": "rest_framework_simplejwt.authentication.default_user_authentication_rule",

"AUTH_TOKEN_CLASSES": ("rest_framework_simplejwt.tokens.AccessToken",),
"TOKEN_TYPE_CLAIM": "token_type",
"TOKEN_USER_CLASS": "rest_framework_simplejwt.models.TokenUser",

"JTI_CLAIM": "jti",

"SLIDING_TOKEN_REFRESH_EXP_CLAIM": "refresh_exp",
"SLIDING_TOKEN_LIFETIME": timedelta(minutes=5),
"SLIDING_TOKEN_REFRESH_LIFETIME": timedelta(days=1),

"TOKEN_OBTAIN_SERIALIZER": "rest_framework_simplejwt.serializers.TokenObtainPairSerializer",
"TOKEN_REFRESH_SERIALIZER": "rest_framework_simplejwt.serializers.TokenRefreshSerializer",
"TOKEN_VERIFY_SERIALIZER": "rest_framework_simplejwt.serializers.TokenVerifySerializer",
"TOKEN_BLACKLIST_SERIALIZER": "rest_framework_simplejwt.serializers.TokenBlacklistSerializer",
"SLIDING_TOKEN_OBTAIN_SERIALIZER": "rest_framework_simplejwt.serializers.TokenObtainSlidingSerializer",
"SLIDING_TOKEN_REFRESH_SERIALIZER": "rest_framework_simplejwt.serializers.TokenRefreshSlidingSerializer",
}

CORS_ALLOW_ALL_ORIGINS = True
3 changes: 3 additions & 0 deletions HR_Backend/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,8 @@
path('api/v1/waitlist/', include('waitlist.urls')),
path('api/v1/web3auth/', include('web3auth.urls')),
path('api/v1/profile/', include('user_profile.urls')),
path('api/v1/notifications/', include('notifications.urls')),
path('api/v1/payroll/', include('payroll.urls')),
path('api/v1/leave_requests/', include('leaveRequest.urls')),

]
Binary file modified db.sqlite3
Binary file not shown.
Empty file added leaveRequest/__init__.py
Empty file.
3 changes: 3 additions & 0 deletions leaveRequest/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.contrib import admin

# Register your models here.
6 changes: 6 additions & 0 deletions leaveRequest/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from django.apps import AppConfig


class LeaverequestConfig(AppConfig):
default_auto_field = "django.db.models.BigAutoField"
name = "leaveRequest"
67 changes: 67 additions & 0 deletions leaveRequest/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# Generated by Django 5.2 on 2025-05-17 23:32

import django.db.models.deletion
from django.db import migrations, models


class Migration(migrations.Migration):

initial = True

dependencies = [
("user_profile", "0007_alter_recipientprofile_user"),
]

operations = [
migrations.CreateModel(
name="LeaveRequest",
fields=[
(
"id",
models.BigAutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("start_date", models.DateField()),
("end_date", models.DateField()),
(
"leave_type",
models.CharField(
choices=[
("sick", "Sick Leave"),
("vacation", "Vacation Leave"),
("personal", "Personal Leave"),
("other", "Other"),
],
max_length=30,
),
),
("reason", models.TextField()),
(
"status",
models.CharField(
choices=[
("pending", "Pending"),
("approved", "Approved"),
("rejected", "Rejected"),
],
default="pending",
max_length=30,
),
),
("created_at", models.DateTimeField(auto_now_add=True)),
("updated_at", models.DateTimeField(auto_now=True)),
(
"recipient",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
related_name="leave_requests",
to="user_profile.recipientprofile",
),
),
],
),
]
Empty file.
40 changes: 40 additions & 0 deletions leaveRequest/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
from django.db import models
from user_profile.models import RecipientProfile

class LeaveRequest(models.Model):
"""
Model to store leave request information for users.
"""

recipient = models.ForeignKey(
RecipientProfile,
on_delete=models.CASCADE,
related_name="leave_requests",
)
start_date = models.DateField()
end_date = models.DateField()
leave_type = models.CharField(
max_length=30,
choices=[
("sick", "Sick Leave"),
("vacation", "Vacation Leave"),
("personal", "Personal Leave"),
("other", "Other"),
],
)
reason = models.TextField()
status = models.CharField(
max_length=30,
choices=[
("pending", "Pending"),
("approved", "Approved"),
("rejected", "Rejected"),
],
default="pending",
)
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)


def __str__(self):
return f"Leave Request from {self.recipient.name} - {self.status}"
26 changes: 26 additions & 0 deletions leaveRequest/serializers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
from rest_framework import serializers
from .models import LeaveRequest
from user_profile.serializers import RecipientProfileSerializer


class LeaveRequestSerializer(serializers.ModelSerializer):
"""
Serializer for LeaveRequest model.
"""

recipient = RecipientProfileSerializer(read_only=True)

class Meta:
model = LeaveRequest
fields = [
"id",
"recipient",
"start_date",
"end_date",
"leave_type",
"reason",
"status",
"created_at",
"updated_at",
]
read_only_fields = ["id", "created_at", "updated_at"]
3 changes: 3 additions & 0 deletions leaveRequest/tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.test import TestCase

# Create your tests here.
10 changes: 10 additions & 0 deletions leaveRequest/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from .views import LeaveRequestView
from django.urls import path, include
from rest_framework.routers import DefaultRouter


router = DefaultRouter()
router.register(r"leave_requests", LeaveRequestView, basename="leave_requests")
urlpatterns = [
path("", include(router.urls)),
]
Loading