Skip to content

Commit

Permalink
create interview model
Browse files Browse the repository at this point in the history
  • Loading branch information
Mathias-a committed Oct 3, 2023
1 parent ce04d9c commit b2b81e8
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 27 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Generated by Django 4.2.3 on 2023-10-03 18:59
# Generated by Django 4.2.3 on 2023-10-03 20:13

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

Expand All @@ -23,14 +24,24 @@ class Migration(migrations.Migration):
model_name='recruitmentadmission',
name='room',
),
migrations.AlterField(
model_name='recruitmentposition',
name='interviewers',
field=models.ManyToManyField(blank=True, help_text='Interviewers for the position', related_name='interviewers', to=settings.AUTH_USER_MODEL),
),
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')),
('interview_time', models.DateTimeField(blank=True, help_text='The time of the interview', null=True)),
('interview_location', models.CharField(blank=True, help_text='The location of the interview', max_length=255, null=True)),
('notes', models.TextField(blank=True, help_text='Notes for the interview', null=True)),
('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')),
],
),
migrations.AddField(
model_name='recruitmentadmission',
name='interview',
field=models.ForeignKey(blank=True, help_text='The interview for the admission', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='admissions', to='samfundet.interview'),
),
]
37 changes: 21 additions & 16 deletions backend/samfundet/models/recruitment.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,23 @@ def clean(self) -> None:
super().clean()


class Interview(models.Model):
# User visible fields
interview_time = models.DateTimeField(help_text='The time of the interview', null=True, blank=True)
interview_location = models.CharField(max_length=255, help_text='The location of the interview', null=True, blank=True)

# Admin visible fields
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', null=True, blank=True)


class RecruitmentAdmission(models.Model):
admission_text = models.TextField(help_text='Admission text for the admission')
recruitment_position = models.ForeignKey(
Expand All @@ -121,6 +138,10 @@ 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 = models.ForeignKey(
Interview, on_delete=models.SET_NULL, null=True, blank=True, help_text='The interview for the admission', related_name='admissions'
)

PRIORITY_CHOICES = [
(0, 'Not Set'),
(1, 'Not Wanted'),
Expand All @@ -142,19 +163,3 @@ class RecruitmentAdmission(models.Model):

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')
15 changes: 8 additions & 7 deletions backend/samfundet/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -557,23 +557,24 @@ class Meta:
fields = ['id', 'first_name', 'last_name', 'email']


class RecruitmentAdmissionForGangSerializer(serializers.ModelSerializer):
user = ApplicantInfoSerializer(read_only=True)
class InterviewRoomSerializer(serializers.ModelSerializer):

class Meta:
model = RecruitmentAdmission
model = InterviewRoom
fields = '__all__'


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

class Meta:
model = InterviewRoom
model = Interview
fields = '__all__'


class InterviewSerializer(serializers.ModelSerializer):
class RecruitmentAdmissionForGangSerializer(serializers.ModelSerializer):
user = ApplicantInfoSerializer(read_only=True)
interview = InterviewSerializer(many=True, read_only=False)

class Meta:
model = Interview
model = RecruitmentAdmission
fields = '__all__'
9 changes: 9 additions & 0 deletions frontend/src/dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -341,8 +341,17 @@ export type RecruitmentPositionDto = {
interviewers: UserDto[];
};

export type InterviewDto = {
id: number;
interview_time: string;
interview_location: string;
room: string;
notes: string;
};

export type RecruitmentAdmissionDto = {
id: number;
interview: InterviewDto;
admission_text: string;
recruitment_position?: number;
recruitment: number;
Expand Down

0 comments on commit b2b81e8

Please sign in to comment.