def tempat_wawancara(request): if 'user_login' not in request.session.keys(): return HttpResponseRedirect(reverse('login')) if (request.session['role'] != 'admin'): return HttpResponseRedirect(reverse('dashboard')) if request.method == "POST": form = TempatWawancaraForm(request.POST) if form.is_valid(): with connection.cursor() as cursor: new_tempat_wawancara = insert( table_name=TempatWawancara._meta.db_table, kode=form.cleaned_data['kode'], nama=form.cleaned_data['nama'], lokasi=form.cleaned_data['lokasi']) cursor.execute(new_tempat_wawancara) response = {} response['status_tempat'] = 'berhasil menambahkan data' response['form'] = TempatWawancaraForm() return render(request, 'tempat_wawancara.html', response) else: response = {} response['status_tempat'] = 'kode yang dimasukkan sudah eksis' response['form'] = TempatWawancaraForm() return render(request, 'tempat_wawancara.html', response) else: response = {} response['form'] = TempatWawancaraForm() return render(request, 'tempat_wawancara.html', response)
def daftar_skema(request): if request.method == "POST": form = daftarSkemaForm(request.POST) if form.is_valid(): donatur = Donatur.objects.get( username=request.session.get('user_login')) nomor_identitas_donatur = donatur.nomor_identitas with connection.cursor() as cursor: new_skemaBeasiswa = insert( table_name=SkemaBeasiswa._meta.db_table, kode=form.cleaned_data['kode'], nama=form.cleaned_data['nama'], jenis=form.cleaned_data['jenis'], deskripsi=form.cleaned_data['deskripsi'], nomor_identitas_donatur=nomor_identitas_donatur) # new_skemaBeasiswaAktif = insert(table_name=SkemaBeasiswaAktif._meta.db_table, # kode_skema_beasiswa=form.cleaned_data['kode_skema_beasiswa'], # no_urut=form.cleaned_data['no_urut'], # tgl_mulai_pendaftaran=form.cleaned_data['tgl_mulai_pendaftaran'], # tgl_tutup_pendaftaran=form.cleaned_data['tgl_tutup_pendaftaran'], # periode_penerimaan=form.cleaned_data['periode_penerimaan'], # status=form.cleaned_data['status'], # jumlah_pendaftar=form.cleaned_data['jumlah_pendaftar']) cursor.execute(new_skemaBeasiswa) # cursor.execute(new_skemaBeasiswaAktif) else: form = daftarSkemaForm() return render(request, 'daftar_skema.html', {'form': form})
def registrasi_yayasan(request): if request.method == "POST": form = RegistrasiYayasan(request.POST) if form.is_valid(): with connection.cursor() as cursor: new_pengguna = insert(table_name=Pengguna._meta.db_table, username=form.cleaned_data['username'], password=form.cleaned_data['password'], role='donatur') new_donatur = insert( table_name=Donatur._meta.db_table, nomor_identitas=form.cleaned_data['nomor_identitas'], email=form.cleaned_data['email'], nama=form.cleaned_data['nama_yayasan'], npwp=form.cleaned_data['npwp'], no_telp=form.cleaned_data['no_telp'], alamat=form.cleaned_data['alamat'], username=form.cleaned_data['username']) new_yayasan = insert( table_name=Yayasan._meta.db_table, no_sk_yayasan=form.cleaned_data['no_sk_yayasan'], email=form.cleaned_data['email'], nama=form.cleaned_data['nama_yayasan'], no_telp_cp=form.cleaned_data['no_telp'], nomor_identitas_donatur=form. cleaned_data['nomor_identitas']) cursor.execute(new_pengguna) cursor.execute(new_donatur) cursor.execute(new_yayasan) access_role = get_access(form.cleaned_data['username'], form.cleaned_data['password']) if (access_role): request.session['user_login'] = form.cleaned_data['username'] request.session['role'] = access_role return redirect('status') else: form = RegistrasiYayasan() return render(request, 'registerYayasan.html', {'form': form})
def registrasi_mahasiswa(request): if request.method == "POST": form = RegistrasiMahasiswaForm(request.POST) if form.is_valid(): with connection.cursor() as cursor: new_pengguna = insert(table_name=Pengguna._meta.db_table, username=form.cleaned_data['username'], password=form.cleaned_data['password'], role='mahasiswa') new_mahasiswa = insert( table_name=Mahasiswa._meta.db_table, npm=form.cleaned_data['npm'], email=form.cleaned_data['email'], nama=form.cleaned_data['nama'], no_telp=form.cleaned_data['no_telp'], alamat_tinggal=form.cleaned_data['alamat_tinggal'], alamat_domisili=form.cleaned_data['alamat_domisili'], nama_bank=form.cleaned_data['nama_bank'], no_rekening=form.cleaned_data['no_rekening'], nama_pemilik=form.cleaned_data['nama_pemilik'], username=form.cleaned_data['username']) cursor.execute(new_pengguna) cursor.execute(new_mahasiswa) access_role = get_access(form.cleaned_data['username'], form.cleaned_data['password']) if (access_role): request.session['user_login'] = form.cleaned_data['username'] request.session['role'] = access_role return redirect('status') else: form = RegistrasiMahasiswaForm() return render(request, 'registerStudent.html', {'form': form})
def form_beasiswa(request): if 'user_login' not in request.session.keys(): return HttpResponseRedirect(reverse('login')) if (request.session['role'] != 'mahasiswa'): return HttpResponseRedirect(reverse('dashboard')) response = {} obj = Mahasiswa.objects.filter(username=request.session.get('user_login')) if request.method == "POST": form = FormBeasiswaForm(request.POST) if form.is_valid(): with connection.cursor() as cursor: new_pendaftaran = insert( table_name=Pendaftaran._meta.db_table, no_urut=Pendaftaran.objects.all().count(), kode_skema_beasiswa=form.cleaned_data['kode_skema'], npm=obj[0].npm, waktu_daftar=datetime.datetime.now(), status_daftar='daftar', status_terima='tidak aktif') cursor.execute(new_pendaftaran) response = {} response['status_daftar'] = 'berhasil mendaftar' response['form'] = TempatWawancaraForm() return render(request, 'tempat_wawancara.html', response) else: response['status_daftar'] = 'gagal mendaftar, kode skema tidak ada' response['loggedin'] = obj response['form'] = FormBeasiswaForm() return render(request, 'form_beasiswa.html', response) else: response['loggedin'] = obj response['form'] = FormBeasiswaForm() return render(request, 'form_beasiswa.html', response)
def daftar_skema_aktif(request): if request.method == "POST": form = daftarSkemaAktifForm(request.POST) if form.is_valid(): with connection.cursor() as cursor: new_skemaBeasiswaAktif = insert( table_name=SkemaBeasiswaAktif._meta.db_table, kode_skema_beasiswa=form. cleaned_data['kode_skema_beasiswa'], no_urut=form.cleaned_data['no_urut'], tgl_mulai_pendaftaran=form. cleaned_data['tgl_mulai_pendaftaran'], tgl_tutup_pendaftaran=form. cleaned_data['tgl_tutup_pendaftaran'], periode_penerimaan=form.cleaned_data['periode_penerimaan'], status=form.cleaned_data['status'], jumlah_pendaftar=form.cleaned_data['jumlah_pendaftar']) cursor.execute(new_skemaBeasiswaAktif) else: form = daftarSkemaAktifForm() return render(request, 'daftar_skema_aktif.html', {'form': form})