Skip to content

Commit

Permalink
Create interview backend
Browse files Browse the repository at this point in the history
  • Loading branch information
Mathias-a committed Oct 3, 2023
1 parent 1a016e5 commit a183624
Show file tree
Hide file tree
Showing 10 changed files with 71 additions and 72 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
ADMISSION_DATA = {
'admission_text': 'This is the admission text',
'applicant_priority': 0,
'interview_time': None,
'interview_location': None,
'recruiter_priority': 0,
'recruiter_status': 0
}
Expand Down
12 changes: 3 additions & 9 deletions backend/samfundet/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
RecruitmentPosition,
RecruitmentAdmission,
InterviewRoom,
InterviewNotes,
Interview,
)
from .models.general import (
Tag,
Expand Down Expand Up @@ -542,24 +542,18 @@ class RecruitmentAdmissionAdmin(CustomGuardedModelAdmin):
'id',
'recruitment_position',
'recruitment',
'interview_time',
'interview_location',
'user',
]
list_display = [
'id',
'recruitment_position',
'recruitment',
'interview_time',
'interview_location',
'user',
]
search_fields = [
'id',
'recruitment_position',
'recruitment',
'interview_time',
'interview_location',
'user',
]
list_select_related = True
Expand All @@ -582,8 +576,8 @@ class InterviewRoomAdmin(CustomGuardedModelAdmin):
list_select_related = ['recruitment', 'gang']


@admin.register(InterviewNotes)
class InterviewNotesAdmin(CustomGuardedModelAdmin):
@admin.register(Interview)
class InterviewAdmin(CustomGuardedModelAdmin):
list_filter = ['id', 'notes']
list_display = ['id', 'notes']
search_fields = ['id', 'notes']
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Generated by Django 4.2.3 on 2023-10-03 18:59

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


class Migration(migrations.Migration):

dependencies = [
('samfundet', '0038_alter_recruitmentadmission_interview_location_and_more'),
]

operations = [
migrations.RemoveField(
model_name='recruitmentadmission',
name='interview_location',
),
migrations.RemoveField(
model_name='recruitmentadmission',
name='interview_time',
),
migrations.RemoveField(
model_name='recruitmentadmission',
name='room',
),
migrations.CreateModel(
name='Interview',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('interview_time', models.DateTimeField(help_text='The time of the interview')),
('notes', models.TextField(help_text='Notes for the interview')),
('admissions', models.ForeignKey(help_text='The admission that is being interviewed', on_delete=django.db.models.deletion.CASCADE, related_name='interviews', to='samfundet.recruitmentadmission')),
('room', models.ForeignKey(blank=True, help_text='Room where the interview is held', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='interviews', to='samfundet.interviewroom')),
],
),
]
35 changes: 17 additions & 18 deletions backend/samfundet/models/recruitment.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,6 @@ def clean(self) -> None:
super().clean()


class InterviewNotes(models.Model):
notes = models.TextField(help_text='Notes for the interview')
timestamp = models.DateTimeField(help_text='Timestamp of the notes')


class RecruitmentAdmission(models.Model):
admission_text = models.TextField(help_text='Admission text for the admission')
recruitment_position = models.ForeignKey(
Expand All @@ -126,17 +121,6 @@ class RecruitmentAdmission(models.Model):
user = models.ForeignKey(User, on_delete=models.CASCADE, help_text='The user that is applying', related_name='admissions')
applicant_priority = models.IntegerField(help_text='The priority of the admission')

interview_time = models.DateTimeField(help_text='The time of the interview', null=True, blank=True)
interview_location = models.CharField(max_length=100, help_text='Where the intevjuee should wait', null=True, blank=True)
room = models.ForeignKey(
InterviewRoom,
on_delete=models.SET_NULL,
null=True,
blank=True,
help_text='Room where the interview is held',
related_name='interviews',
)

PRIORITY_CHOICES = [
(0, 'Not Set'),
(1, 'Not Wanted'),
Expand All @@ -156,7 +140,22 @@ class RecruitmentAdmission(models.Model):

recruiter_status = models.IntegerField(choices=STATUS_CHOICES, default=0, help_text='The status of the admission')

interview_notes = models.ForeignKey(InterviewNotes, on_delete=models.SET_NULL, help_text='Notes for the interview', blank=True, null=True)

def __str__(self) -> str:
return f'Admission: {self.user} for {self.recruitment_position} in {self.recruitment}'


class Interview(models.Model):
admissions = models.ForeignKey(
RecruitmentAdmission, on_delete=models.CASCADE, help_text='The admission that is being interviewed', related_name='interviews'
)
interview_time = models.DateTimeField(help_text='The time of the interview')
room = models.ForeignKey(
InterviewRoom,
on_delete=models.SET_NULL,
null=True,
blank=True,
help_text='Room where the interview is held',
related_name='interviews',
)
notes = models.TextField(help_text='Notes for the interview')

10 changes: 3 additions & 7 deletions backend/samfundet/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
RecruitmentPosition,
RecruitmentAdmission,
InterviewRoom,
InterviewNotes,
Interview,
)
from .models.event import (Event, EventGroup, EventCustomTicket)
from .models.general import (
Expand Down Expand Up @@ -531,8 +531,6 @@ class Meta:
fields = [
'admission_text',
'recruitment_position',
'interview_time',
'interview_location',
]

def create(self, validated_data: dict) -> RecruitmentAdmission:
Expand All @@ -547,8 +545,6 @@ def create(self, validated_data: dict) -> RecruitmentAdmission:
recruitment=recruitment,
user=user,
applicant_priority=applicant_priority,
interview_time=validated_data.get('interview_time'),
interview_location=validated_data.get('interview_location')
)

return recruitment_admission
Expand Down Expand Up @@ -576,8 +572,8 @@ class Meta:
fields = '__all__'


class InterviewNotesSerializer(serializers.ModelSerializer):
class InterviewSerializer(serializers.ModelSerializer):

class Meta:
model = InterviewNotes
model = Interview
fields = '__all__'
1 change: 0 additions & 1 deletion backend/samfundet/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -528,4 +528,3 @@ def test_recruitment_admission_for_applicant(
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]['interview_location'] == fixture_recruitment_admission.interview_location
2 changes: 1 addition & 1 deletion backend/samfundet/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
router.register('recruitment-position', views.RecruitmentPositionView, 'recruitment_position')
router.register('recruitment-admisisons-for-applicant', views.RecruitmentAdmissionForApplicantView, 'recruitment_admissions_for_applicant')
router.register('recruitment-admisisons-for-gang', views.RecruitmentAdmissionForGangView, 'recruitment_admissions_for_gang')
router.register('interview-notes', views.InterviewNotesView, 'interview_notes')
router.register('interview', views.InterviewView, 'interview')

app_name = 'samfundet'

Expand Down
16 changes: 11 additions & 5 deletions backend/samfundet/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,13 @@

from .homepage import homepage
from .models.event import Event, EventGroup
from .models.recruitment import (Recruitment, RecruitmentPosition, RecruitmentAdmission, InterviewRoom, InterviewNotes)
from .models.recruitment import (
Recruitment,
RecruitmentPosition,
RecruitmentAdmission,
InterviewRoom,
Interview,
)
from .models.general import (
Tag,
User,
Expand Down Expand Up @@ -70,7 +76,7 @@
KeyValueSerializer,
MenuItemSerializer,
GangTypeSerializer,
InterviewNotesSerializer,
InterviewSerializer,
BlogPostSerializer,
EventGroupSerializer,
RecruitmentSerializer,
Expand Down Expand Up @@ -622,7 +628,7 @@ def list(self, request: Request) -> Response:
return Response(serialized_rooms.data)


class InterviewNotesView(ModelViewSet):
class InterviewView(ModelViewSet):
permission_classes = [AllowAny]
serializer_class = InterviewNotesSerializer
queryset = InterviewNotes.objects.all()
serializer_class = InterviewSerializer
queryset = Interview.objects.all()
2 changes: 0 additions & 2 deletions frontend/src/dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -348,8 +348,6 @@ export type RecruitmentAdmissionDto = {
recruitment: number;
user: UserDto;
applicant_priority: number;
interview_time?: string;
interview_location?: string;
recruiter_priority?: number;
recruiter_status?: number;
};

0 comments on commit a183624

Please sign in to comment.