Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Applicant overview page #829

Merged
merged 27 commits into from
Feb 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
07c1aa6
get data into frontend
Mathias-a Nov 7, 2023
b03e18d
Add communication with backend
Mathias-a Nov 15, 2023
aac9c49
fix sorting
Mathias-a Nov 15, 2023
7880b4a
improve position seed script
Mathias-a Nov 15, 2023
68ec617
fix priority
Mathias-a Nov 15, 2023
b1688a2
fix tests, and move choices to global file
Mathias-a Nov 16, 2023
427963e
cleanup
Mathias-a Nov 16, 2023
457f4ae
Fix tests, improve error handling
Mathias-a Nov 16, 2023
ef46566
Merge branch 'master' into 687-view-and-manage-own-admission-applicat…
magsyg Dec 20, 2023
6053abd
fix migration
Dec 20, 2023
6c4fdc8
Merge branch 'master' into 687-view-and-manage-own-admission-applicat…
magsyg Feb 8, 2024
2a5f30e
finalize view own applications
Feb 8, 2024
691f890
finalize view own applications
Feb 8, 2024
daaefdc
Merge branch '687-view-and-manage-own-admission-applications' of http…
Feb 8, 2024
799f982
ruff
Feb 8, 2024
4017879
mmore ruff
Feb 8, 2024
3965a03
Merge branch 'master' into 687-view-and-manage-own-admission-applicat…
magsyg Feb 8, 2024
3a356aa
more ruff
Feb 8, 2024
c53abe0
Merge branch '687-view-and-manage-own-admission-applications' of http…
Feb 8, 2024
5b334f8
mmore ruff :)
Feb 8, 2024
f4d26c3
fix traslat
Feb 8, 2024
247a3be
fix
Feb 8, 2024
c1e5201
reformat again
Feb 8, 2024
575eba0
ruff
Feb 8, 2024
b5af892
Merge branch 'master' into 687-view-and-manage-own-admission-applicat…
magsyg Feb 8, 2024
4b3ce89
fun merge
Feb 8, 2024
206a786
Merge branch 'master' into 687-view-and-manage-own-admission-applicat…
magsyg Feb 8, 2024
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
88 changes: 43 additions & 45 deletions backend/Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ def seed():
position_data = POSITION_DATA.copy()
position_data.update(
{
'name_nb': f'Stilling {i}',
'name_en': f'Position {i}',
'name_nb': f'{gang.abbreviation} stilling {i}',
'name_en': f'{gang.abbreviation} position {i}',
'gang': gang,
'recruitment': recruitment,
}
Expand Down
3 changes: 0 additions & 3 deletions backend/samfundet/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -587,19 +587,16 @@ def admissions_count(self, obj: RecruitmentPosition) -> int:
@admin.register(RecruitmentAdmission)
class RecruitmentAdmissionAdmin(CustomBaseAdmin):
sortable_by = [
'id',
'recruitment_position',
'recruitment',
'user',
]
list_display = [
'id',
'recruitment_position',
'recruitment',
'user',
]
search_fields = [
'id',
'recruitment_position',
'recruitment',
'user',
Expand Down
1 change: 0 additions & 1 deletion backend/samfundet/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
https://docs.pytest.org/en/7.1.x/how-to/fixtures.html
"""


TestCase.databases = {'default', 'billig'}


Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Generated by Django 5.0 on 2024-02-08 17:15

import uuid
from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
("samfundet", "0007_recruitmentadmission_withdrawn_and_more"),
]

operations = [
migrations.AlterField(
model_name="recruitmentadmission",
name="id",
field=models.UUIDField(
default=uuid.uuid4, editable=False, primary_key=True, serialize=False
),
),
]
12 changes: 9 additions & 3 deletions backend/samfundet/models/recruitment.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
#
# This file contains models spesific to the recruitment system
#

from __future__ import annotations

import uuid

from django.db import models
from django.utils import timezone
from django.core.exceptions import ValidationError

from root.utils.mixins import CustomBaseModel, FullCleanSaveMixin

from samfundet.models.model_choices import RecruitmentStatusChoices, RecruitmentPriorityChoices

from .general import Gang, User, Organization
from .model_choices import RecruitmentStatusChoices, RecruitmentPriorityChoices


class Recruitment(CustomBaseModel):
Expand Down Expand Up @@ -155,6 +155,7 @@ class Interview(CustomBaseModel):


class RecruitmentAdmission(CustomBaseModel):
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
admission_text = models.TextField(help_text='Admission text for the admission')
recruitment_position = models.ForeignKey(
RecruitmentPosition, on_delete=models.CASCADE, help_text='The recruitment position that is recruiting', related_name='admissions'
Expand Down Expand Up @@ -184,6 +185,11 @@ def __str__(self) -> str:

def save(self, *args: tuple, **kwargs: dict) -> None:
"""If the admission is saved without an interview, try to find an interview from a shared position."""
if not self.applicant_priority:
current_applications_count = RecruitmentAdmission.objects.filter(user=self.user).count()
# Set the applicant_priority to the number of applications + 1 (for the current application)
self.applicant_priority = current_applications_count + 1
"""If the admission is saved without an interview, try to find an interview from a shared position."""
if self.withdrawn:
self.recruiter_priority = RecruitmentPriorityChoices.NOT_WANTED
self.recruiter_status = RecruitmentStatusChoices.AUTOMATIC_REJECTION
Expand Down
35 changes: 35 additions & 0 deletions backend/samfundet/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -589,12 +589,47 @@ def update(self, instance: RecruitmentPosition, validated_data: dict) -> Recruit
return updated_instance


class ApplicantInterviewSerializer(serializers.ModelSerializer):
class Meta:
model = Interview
fields = [
'id',
'interview_time',
'interview_location',
]


class RecruitmentPositionForApplicantSerializer(serializers.ModelSerializer):
class Meta:
model = RecruitmentPosition
fields = [
'id',
'name_nb',
'name_en',
'short_description_nb',
'short_description_en',
'long_description_nb',
'long_description_en',
'is_funksjonaer_position',
'default_admission_letter_nb',
'default_admission_letter_en',
'gang',
'recruitment',
]


class RecruitmentAdmissionForApplicantSerializer(serializers.ModelSerializer):
interview = ApplicantInterviewSerializer(read_only=True)
recruitment_position = RecruitmentPositionForApplicantSerializer(read_only=True)

class Meta:
model = RecruitmentAdmission
fields = [
'id',
'admission_text',
'recruitment_position',
'applicant_priority',
'interview',
'created_at',
'withdrawn',
]
Expand Down
2 changes: 1 addition & 1 deletion backend/samfundet/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -678,4 +678,4 @@ def test_recruitment_admission_for_applicant(
# Assert the returned data based on the logic in the view
assert len(response.data) == 1
assert response.data[0]['admission_text'] == fixture_recruitment_admission.admission_text
assert response.data[0]['recruitment_position'] == fixture_recruitment_admission.recruitment_position.id
assert response.data[0]['recruitment_position']['id'] == fixture_recruitment_admission.recruitment_position.id
Loading
Loading