-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
194 additions
and
23 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/bin/bash | ||
|
||
export KATALOG="$1/raport.txt" | ||
|
||
IFS=$(echo -en "\n\b") | ||
|
||
for a in $1/*xlsx; do | ||
python src/manage.py import_oplaty_publikacje --dry "$a" >> "$KATALOG" ; | ||
done |
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,6 @@ | ||
#!/bin/bash | ||
|
||
python src/manage.py mapuj_kola_naukowe &> res.txt | ||
grep "nie ma zadnego" res.txt > brak_kol.txt | ||
grep "Przypisano" res.txt > przypisano.txt | ||
grep "ma ilość przypisań" res.txt > wiele_kol.txt |
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
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 |
---|---|---|
@@ -0,0 +1,99 @@ | ||
from django.core.management import BaseCommand, CommandError, CommandParser | ||
from django.db import transaction | ||
|
||
from bpp.models import Autorzy, Jednostka | ||
|
||
|
||
class Command(BaseCommand): | ||
help = ( | ||
'Dla osob które maja prace z jednostki (parametru -- domyslnie "Uniwersytet Medyczny w Lublinie") ' | ||
"oraz wpisany kierunek studiów, ta procedura przypisuje im koła naukowe, do których są przypisani " | ||
"jako autor w modelu Autor_Jednostka. " | ||
"Jeżeli autor jest przypisany do kilku kół naukowych, system wyrzuca dla niego komunikat i nic nie robi. " | ||
"Podobnie gdy autor nie jest w ogóle przypisany do żadnego koła" | ||
) | ||
|
||
def add_arguments(self, parser: CommandParser): | ||
|
||
parser.add_argument( | ||
"--jednostka", | ||
default="Uniwersytet Medyczny w Lublinie", | ||
help="Jednostka z której zostaną przypisani do kół przemapowywani studenci", | ||
) | ||
parser.add_argument( | ||
"--rok", | ||
type=int, | ||
default=2022, | ||
help="Ogranicz do roku", | ||
) | ||
parser.add_argument( | ||
"--dry-run", | ||
action="store_true", | ||
default=False, | ||
) | ||
|
||
@transaction.atomic | ||
def handle(self, jednostka, rok, dry_run, *args, **options): | ||
for _jedn in Jednostka.objects.exclude( | ||
rodzaj_jednostki=Jednostka.RODZAJ_JEDNOSTKI.KOLO_NAUKOWE | ||
): | ||
if ( | ||
_jedn.nazwa.lower().find("koło naukowe") >= 0 | ||
or _jedn.nazwa.lower().find("skn ") >= 0 | ||
): | ||
print( | ||
f"Jednostka {_jedn.nazwa} wydaje się byc kołem naukowym, " | ||
f"ale nie ma określonego własciwego rodzaju jednostki. Ustawiam rodzaj na koło naukowe" | ||
) | ||
_jedn.rodzaj_jednostki = Jednostka.RODZAJ_JEDNOSTKI.KOLO_NAUKOWE | ||
_jedn.save() | ||
|
||
jednostka_id = -1 | ||
try: | ||
jednostka_id = Jednostka.objects.get(nazwa=jednostka).pk | ||
except Jednostka.DoesNotExist: | ||
raise CommandError( | ||
f'Brak jednostki o nazwie "{jednostka}". ' | ||
f"Uzyj parametru --jednostka i podaj inną nazwę" | ||
) | ||
|
||
for aj in Autorzy.objects.filter(jednostka__pk=jednostka_id, rekord__rok=rok): | ||
# Znajdź dla autora jednostkę będącą kołem naukowym | ||
autor = aj.autor | ||
|
||
if aj.kierunek_studiow_id is None: | ||
print( | ||
f"Autor {autor} nie ma określonego kierunku studiów, nie przypiszę żadnego koła naukowego. " | ||
f"Rekord: {aj.rekord.tytul_oryginalny}, {aj.rekord_id}" | ||
) | ||
|
||
kolo_naukowe = autor.jednostki.filter( | ||
rodzaj_jednostki=Jednostka.RODZAJ_JEDNOSTKI.KOLO_NAUKOWE | ||
) | ||
|
||
if not kolo_naukowe.exists(): | ||
print( | ||
f"Autor {autor} nie ma zadnego kola naukowego, nie mam gdzie przypisać -- " | ||
f"praca {aj.rekord.tytul_oryginalny}, {aj.rekord_id}" | ||
) | ||
continue | ||
|
||
elif kolo_naukowe.count() == 1: | ||
aj = aj.original | ||
aj.jednostka = kolo_naukowe.first() | ||
aj.save() | ||
print( | ||
f"Przypisano autorowi {autor} koło {kolo_naukowe.first().nazwa} " | ||
f"dla pracy {aj.rekord.tytul_oryginalny}, {aj.rekord_id}" | ||
) | ||
continue | ||
|
||
else: | ||
print( | ||
f"Autor {autor} ma ilość przypisań do kół = {kolo_naukowe.count()}, proszę określić ręcznie. " | ||
f"Rekord {aj.rekord.tytul_oryginalny}, {aj.rekord_id}" | ||
) | ||
continue | ||
|
||
if dry_run: | ||
transaction.rollback() |
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
VERSION = "202211.1095" | ||
VERSION = "202212.1096" | ||
|
||
if __name__ == "__main__": | ||
import sys | ||
|
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