-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add interviews ics calendar, interview creation script, reformat inte…
…rview csv report (#855) * add interview calendar * refactor InterviewListCSVView * fix tables * fix tables * create interview creation script
- Loading branch information
Showing
17 changed files
with
578 additions
and
370 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
115 changes: 115 additions & 0 deletions
115
apps/admission/management/commands/create_interview_from_csv.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
from admission.constants import InterviewSections | ||
from admission.management.commands._utils import CurrentCampaignMixin | ||
from admission.models import Applicant, Campaign, Comment, Interview | ||
import csv | ||
from core.models import Location | ||
from datetime import datetime | ||
from django.core.management import BaseCommand, CommandError | ||
from django.conf import settings | ||
from django.db import transaction | ||
from django.db.models import Q | ||
from django.utils import timezone | ||
from users.models import User | ||
|
||
|
||
class Command(CurrentCampaignMixin, BaseCommand): | ||
help = """ | ||
Create interview and interview comment for applicants with id from csv | ||
Example: ./manage.py create_interview_from_csv --date=2024-06-24 --section=PROGRAMMING --comment='МФТИ' | ||
""" | ||
|
||
def add_arguments(self, parser): | ||
super().add_arguments(parser) | ||
parser.add_argument( | ||
"--filename", | ||
type=str, | ||
default='ids.csv', | ||
help="csv file name", | ||
) | ||
parser.add_argument( | ||
"--delimiter", | ||
type=str, | ||
default=',', | ||
help="csv delimiter", | ||
) | ||
parser.add_argument( | ||
"--date", | ||
type=str, | ||
default="today", | ||
help="date of interview in YYYY-MM-DD format", | ||
) | ||
parser.add_argument( | ||
"--venue", | ||
type=str, | ||
default='Онлайн-собеседование в ШАД Москва 2024', | ||
help="venue of interview", | ||
) | ||
parser.add_argument( | ||
"--interviewer_id", | ||
type=int, | ||
default=15418, | ||
help="ID of interviewer", | ||
) | ||
parser.add_argument( | ||
"--score", | ||
type=int, | ||
default=5, | ||
help="interview score", | ||
) | ||
parser.add_argument( | ||
"--section", | ||
type=str, | ||
required=True, | ||
help="Section of interview", | ||
) | ||
parser.add_argument( | ||
"--comment", | ||
type=str, | ||
required=True, | ||
help="Comment text", | ||
) | ||
|
||
def handle(self, *args, **options): | ||
campaigns = self.get_current_campaigns(options, confirm=False) | ||
delimiter = options["delimiter"] | ||
filename = options["filename"] | ||
venue = Location.objects.get(name=options["venue"]) | ||
date = timezone.now().date() if options["date"] == "today" \ | ||
else datetime.strptime(options["date"], '%Y-%m-%d').date() | ||
interviewer = User.objects.get(pk=options["interviewer_id"]) | ||
section = getattr(InterviewSections, options["section"]) | ||
comment_text = options["comment"] | ||
score = options["score"] | ||
with open(filename) as csvfile: | ||
reader = csv.reader(csvfile, delimiter=delimiter) | ||
headers = next(reader) | ||
with transaction.atomic(): | ||
for applicant_number, row in enumerate(reader): | ||
id = row[0][-6:-1] | ||
try: | ||
applicant = Applicant.objects.get(id=id, campaign__in=campaigns) | ||
except Applicant.DoesNotExist: | ||
print(f'{id} does not exists') | ||
raise | ||
interview = Interview( | ||
applicant=applicant, | ||
status=Interview.COMPLETED, | ||
section=section, | ||
venue=venue, | ||
date=date) | ||
print(applicant) | ||
interview.save() | ||
interview.interviewers.add(interviewer) | ||
comment = Comment( | ||
interview=interview, | ||
interviewer=interviewer, | ||
text=comment_text, | ||
score=score) | ||
comment.save() | ||
if input(f'\nБудут созданы {applicant_number} завершенных собеседований по секции ' | ||
f'"{InterviewSections.get_choice(section).label}" на {date} c локацией "{venue}".\n' | ||
f'Собеседущий {interviewer} поставит оценку {score} с комментарием "{comment_text}"\n' | ||
f'Введите "y" для подтверждения: ') != "y": | ||
raise CommandError("Error asking for approval. Canceled") | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,7 @@ msgid "" | |
msgstr "" | ||
"Project-Id-Version: django\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"POT-Creation-Date: 2024-06-12 12:42+0000\n" | ||
"POT-Creation-Date: 2024-06-30 17:39+0000\n" | ||
"PO-Revision-Date: 2015-03-18 08:34+0000\n" | ||
"Last-Translator: Jannis Leidel <[email protected]>\n" | ||
"Language-Team: Russian (http://www.transifex.com/projects/p/django/language/" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,7 @@ msgid "" | |
msgstr "" | ||
"Project-Id-Version: PACKAGE VERSION\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"POT-Creation-Date: 2024-06-12 12:42+0000\n" | ||
"POT-Creation-Date: 2024-06-30 17:39+0000\n" | ||
"PO-Revision-Date: 2022-02-21 15:24+0000\n" | ||
"Last-Translator: Сергей Жеревчук <[email protected]>\n" | ||
"Language-Team: LANGUAGE <[email protected]>\n" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,7 @@ msgid "" | |
msgstr "" | ||
"Project-Id-Version: PACKAGE VERSION\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"POT-Creation-Date: 2024-06-12 12:42+0000\n" | ||
"POT-Creation-Date: 2024-06-30 17:39+0000\n" | ||
"PO-Revision-Date: 2019-10-31 16:30+0000\n" | ||
"Last-Translator: b' <[email protected]>'\n" | ||
"Language-Team: LANGUAGE <[email protected]>\n" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,7 @@ msgid "" | |
msgstr "" | ||
"Project-Id-Version: PACKAGE VERSION\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"POT-Creation-Date: 2024-06-12 12:42+0000\n" | ||
"POT-Creation-Date: 2024-06-30 17:39+0000\n" | ||
"PO-Revision-Date: 2020-02-03 16:52+0000\n" | ||
"Last-Translator: b' <[email protected]>'\n" | ||
"Language-Team: LANGUAGE <[email protected]>\n" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,7 @@ msgid "" | |
msgstr "" | ||
"Project-Id-Version: PACKAGE VERSION\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"POT-Creation-Date: 2024-06-12 12:42+0000\n" | ||
"POT-Creation-Date: 2024-06-30 17:39+0000\n" | ||
"PO-Revision-Date: 2020-09-09 04:43+0000\n" | ||
"Last-Translator: b' <[email protected]>'\n" | ||
"Language-Team: LANGUAGE <[email protected]>\n" | ||
|
Oops, something went wrong.