示例#1
0
文件: views.py 项目: harizMunawar/REI
    def get(self, request, nis):
        semester = active_semester()
        try:
            siswa = Siswa.objects.prefetch_related('kelas').get(nis=nis)
            kelas_aktif = siswa.kelas.get(
                tahun_pelajaran=semester.tahun_pelajaran)
        except Siswa.DoesNotExist:
            raise Http404
        except Kelas.DoesNotExist:
            kelas_aktif = None

        initial = get_initial(siswa)
        initial['kelas'] = kelas_aktif
        request.session['page'] = f'Detail {siswa.nama}'

        if not kelas_aktif:
            messages.info(
                request, f'{siswa.nama} belum memiliki kelas di semester ini')

        absen, created = Absensi.objects.get_or_create(siswa=siswa,
                                                       semester=semester,
                                                       defaults={
                                                           'izin': 0,
                                                           'sakit': 0,
                                                           'bolos': 0
                                                       })

        context = {
            'siswa':
            siswa,
            'kelas':
            kelas_aktif,
            'absensi':
            absen,
            'semester':
            semester,
            'siswa_form':
            SiswaForm(initial=initial),
            'absen_form':
            AbsenForm(initial=get_initial(absen)),
            'nilai_form':
            zip_pelnilai(siswa, semester),
            'data_ekskul':
            zip_eksnilai(siswa, semester),
            'ekskul_form':
            TambahEkskulSiswaForm(
                ekskul_list=tambahmapel_choice(get_validekskul(siswa))),
            'usia':
            calculate_age(siswa.tanggal_lahir),
        }
        return render(request, 'pages/siswa/detail-siswa.html', context)
示例#2
0
文件: views.py 项目: harizMunawar/REI
 def get(self, request):
     request.session['page'] = 'Detail Sekolah'
     sekolah = Sekolah.objects.get()
     sekolah_form = SekolahForm(initial=get_initial(sekolah))
     context = {
         'sekolah_form': sekolah_form,
     }
     return render(request, 'pages/detail-sekolah.html', context)
示例#3
0
    def get(self, request, guru):
        try:
            guru = Guru.objects.get(nip=guru)
            kelas = Kelas.objects.get(walikelas=guru,
                                      tahun_pelajaran=active_tp())
        except Guru.DoesNotExist:
            raise Http404
        except Kelas.DoesNotExist:
            kelas = None
        request.session['page'] = f'Profil {guru.nama}'

        context = {
            'profile_form': GuruEditForm(initial=get_initial(guru)),
            'password_form': PasswordChangeForm(),
            'gelar_form': GelarForm(),
            'guru': guru,
            'kelas': kelas,
        }
        return render(request, 'pages/guru/detail-guru.html', context)
示例#4
0
文件: views.py 项目: harizMunawar/REI
 def get(self, request, matapelajaran):
     try:
         matapelajaran = MataPelajaran.objects.get(pk=matapelajaran)
     except ObjectDoesNotExist:
         raise Http404
     tp = active_tp()
     request.session['page'] = f'Detail {matapelajaran.nama}'
     initial = get_initial(matapelajaran)
     kkm, created = KKM.objects.get_or_create(matapelajaran=matapelajaran,
                                              tahun_pelajaran=tp)
     initial['pengetahuan'] = kkm.pengetahuan
     initial['keterampilan'] = kkm.keterampilan
     context = {
         'matapelajaran': matapelajaran,
         'kkm': kkm,
         'mapelkkm_form': EditMatapelajaranForm(initial=initial),
         'list_kelas': matapelajaran.kelas.filter(tahun_pelajaran=tp),
     }
     return render(request, 'pages/matapelajaran/detail-matapelajaran.html',
                   context)
示例#5
0
文件: views.py 项目: harizMunawar/REI
    def get(self, request, kelas):
        request.session['page'] = f'Detail {kelas}'
        tp = active_tp()
        try:
            kelas = Kelas.objects.get(nama=kelas, tahun_pelajaran=tp)
        except ObjectDoesNotExist:
            raise Http404

        try:
            active_walikelas = Guru.objects.get(kelas=kelas)
        except ObjectDoesNotExist:
            active_walikelas = None

        if active_walikelas == request.user or request.user.is_superuser:
            auth_walikelas = True
        else:
            auth_walikelas = False

        initial = get_initial(kelas)
        if initial['walikelas']:
            initial['walikelas'] = Guru.objects.get(pk=initial['walikelas'])
        if initial['jurusan']:
            initial['jurusan'] = Jurusan.objects.get(
                id=initial['jurusan']).nama

        list_siswa = Siswa.objects.filter(kelas=kelas).order_by('nama')
        if list_siswa:
            finished, unfinished, status = list_siswa_status(
                list_siswa=list_siswa, semester=active_semester())
        else:
            finished = []
            unfinished = []

        list_mapel = MataPelajaran.objects.filter(
            kelas=kelas,
            kelas__tahun_pelajaran=tp).order_by('kelompok', 'nama')
        if list_mapel: list_mapel = zip_pelkkm(list_mapel, tp)
        context = {
            'kelas':
            kelas,
            'auth_walikelas':
            auth_walikelas,
            'kelas_form':
            DisabledKelasForm(initial=initial),
            'list_siswa':
            list_siswa,
            'jumlah_siswa':
            list_siswa.count(),
            'status_siswa':
            f'{len(finished)} Siswa tuntas / {len(unfinished)} Siswa belum tuntas',
            'list_matapelajaran':
            list_mapel,
            'active_walikelas':
            active_walikelas,
            'valid_walikelas':
            get_validwalikelas(),
            'tambahmapel_form':
            TambahMatapelajaranKelas(
                mapel_list=tambahmapel_choice(get_validpelajaran(kelas.nama))),
            'tambahanggota_form':
            TambahAnggotaKelas(
                anggota_list=tambahanggota_choice(get_validsiswabaru())),
        }
        return render(request, 'pages/kelas/detail-kelas.html', context)