Пример #1
0
 def get(self, request):
     request.session['page'] = 'Buat Kelas'
     context = {
         'kelas_form':
         KelasForm(tingkat_list=tingkat_choice(get_sekolah()),
                   walikelas_list=walikelas_choice(get_validwalikelas())),
     }
     return render(request, 'pages/kelas/buat-kelas.html', context)
Пример #2
0
class SiswaForm(forms.ModelForm):
    kelas = KelasSelect(queryset=Kelas.objects.filter(tahun_pelajaran=active_tp()), required=False)
    try:
        diterima_di_tingkat = forms.ChoiceField(choices = tingkat_choice(get_sekolah()))
    except Exception as e:
        print(e)
    class Meta:
        model = Siswa
        fields = '__all__'
        widgets = {
            'tanggal_lahir': type.DateInput(),
            'email': type.EmailInput(),
        }
Пример #3
0
 def get(self, request):
     request.session['page'] = 'Dashboard'
     semester = active_semester()
     list_tp = TahunPelajaran.objects.all()
     list_tp = [tp for tp in list_tp]
     siswa_pria = [
         Siswa.objects.exclude(kelas=None).filter(kelas__tahun_pelajaran=tp,
                                                  gender='P').count()
         for tp in list_tp
     ]
     siswa_wanita = [
         Siswa.objects.exclude(kelas=None).filter(kelas__tahun_pelajaran=tp,
                                                  gender='W').count()
         for tp in list_tp
     ]
     tp = active_tp()
     context = {
         'sekolah':
         get_sekolah(),
         'semester':
         semester,
         'siswa_berkelas':
         Siswa.objects.exclude(kelas=None).filter(
             kelas__tahun_pelajaran=tp).count(),
         'siswa_nokelas':
         Siswa.objects.exclude(kelas__tahun_pelajaran=tp).filter(
             kelas=None).count(),
         'jumlah_kelas':
         Kelas.objects.filter(tahun_pelajaran=tp).count(),
         'jumlah_jurusan':
         Jurusan.objects.count(),
         'jumlah_guru':
         Guru.objects.count(),
         'jumlah_walikelas':
         Guru.objects.filter(is_walikelas=True, is_staftu=False).count(),
         'jumlah_tu':
         Guru.objects.filter(is_staftu=True, is_walikelas=False).count(),
         'jumlah_admin':
         Guru.objects.filter(
             Q(
                 Q(is_walikelas=True) & Q(is_staftu=True)
                 | Q(is_superuser=True))).count(),
         'jumlah_mapel':
         MataPelajaran.objects.count(),
         'jumlah_ekskul':
         Ekskul.objects.count(),
         'chart_data':
         zip(list_tp, siswa_pria, siswa_wanita),
     }
     return render(request, 'pages/dashboard.html', context)
Пример #4
0
class KelasForm(forms.ModelForm):
    try:
        tingkat = forms.ChoiceField(choices=tingkat_choice(get_sekolah()))
        walikelas = forms.ChoiceField(choices=walikelas_choice(get_validwalikelas()), required=False)
    except Exception:
        pass

    def __init__(self, tingkat_list, walikelas_list, *args, **kwargs):
        super(KelasForm, self).__init__(*args, **kwargs)
        self.fields["tingkat"] = forms.ChoiceField(choices=tingkat_list)
        self.fields["walikelas"] = forms.ChoiceField(choices=walikelas_list, required=False)
    class Meta:
        model = Kelas
        fields = ('tingkat', 'jurusan', 'kelas')
Пример #5
0
 def post(self, request):
     kelas_form = KelasForm(tingkat_choice(get_sekolah()),
                            walikelas_choice(get_validwalikelas()),
                            request.POST)
     try:
         if kelas_form.is_valid():
             try:
                 kelas_form.cleaned_data['walikelas'] = Guru.objects.get(
                     nip=kelas_form.cleaned_data['walikelas'])
             except Guru.DoesNotExist:
                 kelas_form.cleaned_data['walikelas'] = None
             Kelas.objects.create(**form_value(kelas_form),
                                  tahun_pelajaran=active_tp())
             messages.success(
                 request,
                 'Kelas berhasil dibuat, segera lengkapi data kelas tadi')
     except ValidationError:
         messages.error(request, 'Kelas itu sudah ada')
     finally:
         return redirect('list-kelas')