Commit 92dd6d09 by Joel Marpaung

no message

parent 84666bd7
from django.contrib import admin
# Register your models here.
from django.apps import AppConfig
class StaffConfig(AppConfig):
name = 'staff'
# -*- coding: utf-8 -*-
# Generated by Django 1.10.5 on 2017-05-18 03:01
from __future__ import unicode_literals
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
initial = True
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]
operations = [
migrations.CreateModel(
name='Akun_Staff',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('jenis_akun', models.CharField(choices=[('admin', 'Admin'), ('surveyer', 'Surveyer'), ('quality', 'Quality')], max_length=10)),
('akun', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
],
),
migrations.CreateModel(
name='Staff',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('username', models.CharField(max_length=100, null=True)),
('full_name', models.CharField(max_length=100, null=True)),
('role', models.CharField(max_length=20, null=True)),
('photo', models.ImageField(blank=True, upload_to='staffs')),
],
),
migrations.AddField(
model_name='akun_staff',
name='staff',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='staff.Staff'),
),
]
from __future__ import unicode_literals
from django.db import models
from django.contrib.auth.models import User
# Create your models here.
class Staff (models.Model):
username = models.CharField(max_length=100, null=True)
full_name = models.CharField(max_length=100, null=True)
role = models.CharField(max_length=20, null=True)
photo = models.ImageField(upload_to='staffs', blank=True)
def __str__(self):
return self.full_name
class Akun_Staff (models.Model):
JENIS_AKUN_CHOICES = (
('admin', 'Admin'),
('surveyer', 'Surveyer'),
('quality', 'Quality'),
)
akun = models.ForeignKey(User)
staff = models.ForeignKey(Staff)
jenis_akun = models.CharField(max_length=10, choices=JENIS_AKUN_CHOICES)
def __str__(self):
return self.staff.full_name
\ No newline at end of file
from django.test import TestCase
# Create your tests here.
from django.conf.urls import url
from staff import views
app_name = 'staff'
urlpatterns = [
url(r'^$',views.index, name='index'),
url(r'^create-staff/$',views.createStaff, name='createStaff'),
url(r'^daftar-staff/$',views.daftarStaff, name='daftarStaff'),
url(r'^pending-pengajuan-lahan/$',views.pendingPengajuanLahan, name='pendingPengajuanLahan'),
url(r'^reject-pengajuan-lahan/$',views.rejectPengajuanLahan, name='rejectPengajuanLahan'),
url(r'^pending-peminjaman-uang/$',views.pendingPeminjamanUang, name='pendingPeminjamanUang'),
url(r'^accept-peminjaman-uang/$',views.acceptPeminjamanUang, name='acceptPeminjamanUang'),
url(r'^reject-peminjaman-uang/$',views.rejectPeminjamanUang, name='rejectPeminjamanUang'),
url(r'^data-lahan/$',views.indexDataLahan, name='indexDataLahan'),
]
\ No newline at end of file
from django.shortcuts import render, redirect
from django.http import HttpResponse,HttpResponseRedirect
from django.contrib.auth.decorators import login_required
from django.contrib.auth import authenticate
from django.contrib.auth import logout as auth_logout
from django.contrib.auth import login as auth_login
from django.core.urlresolvers import reverse
from django.conf import settings
import datetime
from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger
# from django.contrib.auth.hashers import make_password
from django.contrib.auth.models import User
from staff.models import *
from farmer.models import *
# Create your views here.
def index(request):
return render(request,'staff/index.html', {'nbar':'home'})
def createStaff(request):
if request.method == 'POST':
user = User(
username = request.POST['username'],
)
user.set_password(request.POST['password'],)
user.save()
staff = Staff(
username = request.POST['username'],
full_name = request.POST['full_name'],
role = request.POST['role'],
photo = request.FILES['photo'],
)
staff.save()
account = Akun_Staff(
akun = User.objects.get(username=request.POST['username']),
staff = Staff.objects.get(username=request.POST['username']),
akun_id = User.objects.get(username=request.POST['username']).id,
staff_id = Staff.objects.get(username=request.POST['username']).id,
jenis_akun = request.POST['role'],
)
account.save()
return redirect('/staff/daftar-staff')
else:
return render(request, 'staff/data_staff/create.html', {'nbar':'activeStaff', 'li':'createStaff'})
def daftarStaff(request):
# account = Pengguna.objects.get(username=request.session['username'])
daftar_staff = Staff.objects.all().order_by('-role')
paginator = Paginator(daftar_staff, 5)
page = request.GET.get('page')
try:
daftar_staff = paginator.page(page)
except PageNotAnInteger:
daftar_staff = paginator.page(1)
except EmptyPage:
daftar_staff = paginator.page(paginator.num_pages)
return render(request, 'staff/data_staff/daftar.html', {'nbar':'activeStaff', 'li':'daftarStaff', 'daftar_staff':daftar_staff})
def pendingPengajuanLahan(request):
# account = Pengguna.objects.get(username=request.session['username'])
pengajuan_pending = Data_Pengajuan_Lahan.objects.filter(status='pending').order_by('-tanggal_pengajuan')
paginator = Paginator(pengajuan_pending, 10)
page = request.GET.get('page')
try:
pengajuan_pending = paginator.page(page)
except PageNotAnInteger:
pengajuan_pending = paginator.page(1)
except EmptyPage:
pengajuan_pending = paginator.page(paginator.num_pages)
return render(request, 'staff/pengajuan_lahan/pending.html', {'nbar':'activePengajuan', 'li':'pendingPengajuan', 'pengajuan_pending':pengajuan_pending})
def rejectPengajuanLahan(request):
# account = Pengguna.objects.get(username=request.session['username'])
pengajuan_reject = Data_Pengajuan_Lahan.objects.filter(status='reject').order_by('-tanggal_pengajuan')
paginator = Paginator(pengajuan_reject, 5)
page = request.GET.get('page')
try:
pengajuan_reject = paginator.page(page)
except PageNotAnInteger:
pengajuan_reject = paginator.page(1)
except EmptyPage:
pengajuan_reject = paginator.page(paginator.num_pages)
return render(request, 'staff/pengajuan_lahan/reject.html', {'nbar':'activePengajuan', 'li':'rejectPengajuan', 'pengajuan_reject':pengajuan_reject})
def pendingPeminjamanUang(request):
# account = Pengguna.objects.get(username=request.session['username'])
peminjaman_uang = Data_Pengajuan_Peminjaman.objects.filter(status='pending').order_by('-tanggal_peminjaman')
paginator = Paginator(peminjaman_uang, 5)
page = request.GET.get('page')
try:
peminjaman_uang = paginator.page(page)
except PageNotAnInteger:
peminjaman_uang = paginator.page(1)
except EmptyPage:
peminjaman_uang = paginator.page(paginator.num_pages)
return render(request, 'staff/peminjaman_uang/pending.html', {'nbar':'activePeminjaman', 'li':'pendingPeminjaman', 'peminjaman_uang':peminjaman_uang})
def acceptPeminjamanUang(request):
return render(request, 'staff/peminjaman_uang/accept.html', {'nbar':'activePeminjaman', 'li':'acceptPeminjaman'})
def rejectPeminjamanUang(request):
# account = Pengguna.objects.get(username=request.session['username'])
peminjaman_uang = Data_Pengajuan_Peminjaman.objects.filter(status='tolak').order_by('-tanggal_peminjaman')
paginator = Paginator(peminjaman_uang, 5)
page = request.GET.get('page')
try:
peminjaman_uang = paginator.page(page)
except PageNotAnInteger:
peminjaman_uang = paginator.page(1)
except EmptyPage:
peminjaman_uang = paginator.page(paginator.num_pages)
return render(request, 'staff/peminjaman_uang/reject.html', {'nbar':'activePeminjaman', 'li':'rejectPeminjaman', 'peminjaman_uang':peminjaman_uang})
def indexDataLahan(request):
return render(request,'staff/data_lahan/index.html', {'nbar':'lahan'})
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment