Skip to content
This repository has been archived by the owner on Jun 21, 2019. It is now read-only.

Commit

Permalink
Merge branch 'feature/sinav_programi_goruntule' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
alirizakeles committed Jul 27, 2016
2 parents 0c239d9 + 2e0a35d commit 90dcfd5
Show file tree
Hide file tree
Showing 7 changed files with 311 additions and 2 deletions.
56 changes: 56 additions & 0 deletions ulakbus/diagrams/ogrenci_sinav_programi_goruntule.bpmn
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?xml version="1.0" encoding="UTF-8"?>
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="1.0.0">
<bpmn:collaboration id="Collaboration_0jqtmlj">
<bpmn:participant id="OgrenciSinavProgrami" name="Öğrenci" processRef="ogrenci_sinav_programi_goruntule" />
</bpmn:collaboration>
<bpmn:process id="ogrenci_sinav_programi_goruntule" name="Sınav Programı" isExecutable="false">
<bpmn:startEvent id="StartEvent_1">
<bpmn:outgoing>SequenceFlow_18408cb</bpmn:outgoing>
</bpmn:startEvent>
<bpmn:endEvent id="EndEvent_0wartdq">
<bpmn:incoming>SequenceFlow_0bro10m</bpmn:incoming>
</bpmn:endEvent>
<bpmn:userTask id="SinavProgramiGoruntule" name="Sınav Programı Görüntüle" camunda:assignee="sinav_programi.ogrenci_sinav_programi_goruntule.Ogrenci_Sinav_Programi_Goruntule.sinav_programi_goruntule">
<bpmn:incoming>SequenceFlow_18408cb</bpmn:incoming>
<bpmn:outgoing>SequenceFlow_0bro10m</bpmn:outgoing>
</bpmn:userTask>
<bpmn:sequenceFlow id="SequenceFlow_18408cb" sourceRef="StartEvent_1" targetRef="SinavProgramiGoruntule" />
<bpmn:sequenceFlow id="SequenceFlow_0bro10m" sourceRef="SinavProgramiGoruntule" targetRef="EndEvent_0wartdq" />
</bpmn:process>
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Collaboration_0jqtmlj">
<bpmndi:BPMNShape id="Participant_0an1mes_di" bpmnElement="OgrenciSinavProgrami">
<dc:Bounds x="230" y="130" width="600" height="250" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1">
<dc:Bounds x="277" y="238" width="36" height="36" />
<bpmndi:BPMNLabel>
<dc:Bounds x="250" y="274" width="90" height="20" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="UserTask_0kiit6r_di" bpmnElement="SinavProgramiGoruntule">
<dc:Bounds x="471" y="216" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="SequenceFlow_18408cb_di" bpmnElement="SequenceFlow_18408cb">
<di:waypoint xsi:type="dc:Point" x="313" y="256" />
<di:waypoint xsi:type="dc:Point" x="471" y="256" />
<bpmndi:BPMNLabel>
<dc:Bounds x="307" y="246" width="90" height="20" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="EndEvent_0wartdq_di" bpmnElement="EndEvent_0wartdq">
<dc:Bounds x="736" y="238" width="36" height="36" />
<bpmndi:BPMNLabel>
<dc:Bounds x="709" y="274" width="90" height="20" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="SequenceFlow_0bro10m_di" bpmnElement="SequenceFlow_0bro10m">
<di:waypoint xsi:type="dc:Point" x="571" y="256" />
<di:waypoint xsi:type="dc:Point" x="736" y="256" />
<bpmndi:BPMNLabel>
<dc:Bounds x="516" y="246" width="90" height="20" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn:definitions>
56 changes: 56 additions & 0 deletions ulakbus/diagrams/okutman_sinav_programi_goruntule.bpmn
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?xml version="1.0" encoding="UTF-8"?>
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="1.0.0">
<bpmn:collaboration id="Collaboration_0jqtmlj">
<bpmn:participant id="OgretimElemaniSinavProgrami" name="Öğretim Elemanı" processRef="okutman_sinav_programi_goruntule" />
</bpmn:collaboration>
<bpmn:process id="okutman_sinav_programi_goruntule" name="Sınav Programı" isExecutable="false">
<bpmn:startEvent id="StartEvent_1">
<bpmn:outgoing>SequenceFlow_18408cb</bpmn:outgoing>
</bpmn:startEvent>
<bpmn:endEvent id="EndEvent_0wartdq">
<bpmn:incoming>SequenceFlow_0bro10m</bpmn:incoming>
</bpmn:endEvent>
<bpmn:userTask id="SinavProgramiGoruntule" name="Sınav Programı Görüntüle" camunda:assignee="sinav_programi.okutman_sinav_programi_goruntule.Okutman_Sinav_Programi_Goruntule.sinav_programi_goruntule">
<bpmn:incoming>SequenceFlow_18408cb</bpmn:incoming>
<bpmn:outgoing>SequenceFlow_0bro10m</bpmn:outgoing>
</bpmn:userTask>
<bpmn:sequenceFlow id="SequenceFlow_18408cb" sourceRef="StartEvent_1" targetRef="SinavProgramiGoruntule" />
<bpmn:sequenceFlow id="SequenceFlow_0bro10m" sourceRef="SinavProgramiGoruntule" targetRef="EndEvent_0wartdq" />
</bpmn:process>
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Collaboration_0jqtmlj">
<bpmndi:BPMNShape id="Participant_0an1mes_di" bpmnElement="OgretimElemaniSinavProgrami">
<dc:Bounds x="309" y="103" width="600" height="250" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1">
<dc:Bounds x="356" y="211" width="36" height="36" />
<bpmndi:BPMNLabel>
<dc:Bounds x="329" y="247" width="90" height="20" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="UserTask_0kiit6r_di" bpmnElement="SinavProgramiGoruntule">
<dc:Bounds x="550" y="189" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="SequenceFlow_18408cb_di" bpmnElement="SequenceFlow_18408cb">
<di:waypoint xsi:type="dc:Point" x="392" y="229" />
<di:waypoint xsi:type="dc:Point" x="550" y="229" />
<bpmndi:BPMNLabel>
<dc:Bounds x="386" y="219" width="90" height="20" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="EndEvent_0wartdq_di" bpmnElement="EndEvent_0wartdq">
<dc:Bounds x="815" y="211" width="36" height="36" />
<bpmndi:BPMNLabel>
<dc:Bounds x="788" y="247" width="90" height="20" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="SequenceFlow_0bro10m_di" bpmnElement="SequenceFlow_0bro10m">
<di:waypoint xsi:type="dc:Point" x="650" y="229" />
<di:waypoint xsi:type="dc:Point" x="815" y="229" />
<bpmndi:BPMNLabel>
<dc:Bounds x="595" y="219" width="90" height="20" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn:definitions>
1 change: 0 additions & 1 deletion ulakbus/models/ders_programi.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@

HAFTA = HAFTA_ICI_GUNLER + HAFTA_SONU_GUNLER


class ZamanDilimleri(Model):

class Meta:
Expand Down
2 changes: 1 addition & 1 deletion ulakbus/models/ders_programi_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,4 @@ class Meta:
tarih = fields.DateTime('Sınav Tarihi', index=True)

class SinavYerleri(ListNode):
room = Room('Sınav Yeri', index=True)
room = Room('Sınav Yeri', index=True)
11 changes: 11 additions & 0 deletions ulakbus/views/sinav_programi/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# -*- coding: utf-8 -*-
"""
"""

# Copyright (C) 2015 ZetaOps Inc.
#
# This file is licensed under the GNU General Public License v3
# (GPLv3). See LICENSE.txt for details.

from .okutman_sinav_programi_goruntule import *
from .ogrenci_sinav_programi_goruntule import *
79 changes: 79 additions & 0 deletions ulakbus/views/sinav_programi/ogrenci_sinav_programi_goruntule.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# -*- coding: utf-8 -*-
# Copyright (C) 2015 ZetaOps Inc.
#
# This file is licensed under the GNU General Public License v3
# (GPLv3). See LICENSE.txt for details.
#

from zengine.forms import JsonForm
from zengine.views.crud import CrudView
from collections import OrderedDict
from ulakbus.models import Donem, Ogrenci, OgrenciDersi, \
Sube # eğer haftanın günü(1,2..) öğretim görevlisinin sınavı varsa
from ulakbus.models.ders_programi import HAFTA
from ulakbus.views.sinav_programi import okutman_sinav_programi_goruntule as SP


class Ogrenci_Sinav_Programi_Goruntule(CrudView):
def sinav_programi_goruntule(self):

"""
Öğrenci kendi şubelerine ait sinav
programını görüntüleyebilir.
"""
ogrenci = Ogrenci.objects.get(user=self.current.user)
guncel_donem = Donem.objects.get(guncel=True)
# Güncel döneme ve giriş yapan, öğrenciye ait öğrenci_dersleri bulunur.
ogrenci_dersleri = OgrenciDersi.objects.filter(ogrenci=ogrenci, donem=guncel_donem)

subeler = []
# Bulunan öğrenci derslerinin şubeleri bulunur ve listeye eklenir.
for ogrenci_ders in ogrenci_dersleri:
try:
sube = Sube.objects.get(ogrenci_ders.sube.key)
subeler.append(sube)
except:
pass

ogrenci_adi = ogrenci.ad + ' ' + ogrenci.soyad

# öğrencinin şubelerine göre sınav etkinlikleri
# dictionary'e eklenir.
sinav_etkinlik = SP.sinav_etkinlik_olustur(subeler)
object_list = ['Pazartesi', 'Salı', 'Çarşamba', 'Perşembe', 'Cuma', 'Cumartesi', 'Pazar']
self.output['objects'] = [object_list]

_form = JsonForm(current=self.current)
_form.title = "%s / %s Sınav Programı" % (ogrenci_adi, guncel_donem.ad)

hafta_dict = SP.hafta_gun_olustur(HAFTA)
# Öğrencinin bir günde maksimum kaç tane sınavı olduğu bulunur
# ve bu bilgi kadar dönülür.
for i in range(max(map(len, sinav_etkinlik.values()))):
sinav_etkinlik_list = OrderedDict({})
# eğer haftanın günü(1,2..) öğrencinin sınavı varsa
for hafta_gun in hafta_dict.keys():
if hafta_gun in sinav_etkinlik:
try:
etkinlik = sinav_etkinlik[hafta_gun][i]
sinav_saat = "%02d:%02d" % (etkinlik.tarih.time().hour, etkinlik.tarih.time().minute)
sinav_etkinlik_list[hafta_dict[hafta_gun]] = str(
etkinlik.sube.ad) + ' / ' + etkinlik.tarih.strftime(
'%d:%m:%Y') + ' / ' + sinav_saat
except:
sinav_etkinlik_list[hafta_dict[hafta_gun]] = ''

else:
sinav_etkinlik_list[hafta_dict[hafta_gun]] = ''

item = {
"type": "table-multiRow",
"fields": sinav_etkinlik_list,
"actions": False,
'key': ''
}

self.output['objects'].append(item)

self.form_out(_form)
108 changes: 108 additions & 0 deletions ulakbus/views/sinav_programi/okutman_sinav_programi_goruntule.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
# -*- coding: utf-8 -*-
# Copyright (C) 2015 ZetaOps Inc.
#
# This file is licensed under the GNU General Public License v3
# (GPLv3). See LICENSE.txt for details.
#

from zengine.forms import JsonForm, fields
from zengine.views.crud import CrudView
from collections import OrderedDict
from ulakbus.models import Okutman, Personel, Sube, Donem
from ulakbus.models.ders_programi_data import SinavEtkinligi
from ulakbus.models.ders_programi import HAFTA
import calendar


class Okutman_Sinav_Programi_Goruntule(CrudView):
def sinav_programi_goruntule(self):
"""
Öğretim Görevlisi kendi şubelerine ait sinav
programını görüntüleyebilir.
"""
# Giriş yapılan öğretim görevlisinin personel objesi getirilir.
personel = Personel.objects.get(user=self.current.user)
# Okutman objesi bulunur.
okutman = Okutman.objects.get(personel=personel)

guncel_donem = Donem.objects.get(guncel=True)
# Güncel döneme ve giriş yapan öğretim görevlisine ait şubeler bulunur.
subeler = Sube.objects.filter(okutman=okutman, donem=guncel_donem)
okutman_adi = okutman.ad + ' ' + okutman.soyad

# Öğretim görevlisinin haftanın günlerine göre sınavları bir dictionary'de
# tutulur. Dictionary'nin key'leri 1'den 7'ye kadardır. 1 Pazartesini 7'de
# Pazar'ı gösterir.
sinav_etkinlik = sinav_etkinlik_olustur(subeler)
object_list = ['Pazartesi', 'Salı', 'Çarşamba', 'Perşembe', 'Cuma', 'Cumartesi', 'Pazar']
self.output['objects'] = [object_list]

_form = JsonForm(current=self.current)
_form.title = "%s / %s Sınav Programı" % (okutman_adi, guncel_donem.ad)

hafta_dict = hafta_gun_olustur(HAFTA)
#Öğretim görevlisinin bir günde maksimum kaç tane sınavı olduğu bulunur
# ve bu bilgi kadar dönülür.
for i in range(max(map(len, sinav_etkinlik.values()))):
sinav_etkinlik_list = OrderedDict({})
# eğer haftanın günü(1,2..) öğretim görevlisinin sınavı varsa
for hafta_gun in hafta_dict.keys():
if hafta_gun in sinav_etkinlik:
try:
etkinlik = sinav_etkinlik[hafta_gun][i]
sinav_saat = "%02d:%02d" % (etkinlik.tarih.time().hour, etkinlik.tarih.time().minute)
sinav_etkinlik_list[hafta_dict[hafta_gun]] = etkinlik.sube.ad + ' / ' + etkinlik.tarih.strftime(
'%d:%m:%Y') + ' / ' + sinav_saat
except:
sinav_etkinlik_list[hafta_dict[hafta_gun]] = ''

else:
sinav_etkinlik_list[hafta_dict[hafta_gun]] = ''

item = {
"type": "table-multiRow",
"fields": sinav_etkinlik_list,
"actions": False,
'key': ''
}

self.output['objects'].append(item)

self.form_out(_form)


def sinav_etkinlik_olustur(subeler):
sinav_etkinlik = {}
# sınav_etkinlik dictionarynin yapısı şu şekildedir:
# sinav_etkinlik = {1:[sinav object, sinav object],3:[sinav object]}
for sube in subeler:
try:
etkinlik = SinavEtkinligi.objects.get(sube=sube)
tarih = etkinlik.tarih
gun = calendar.weekday(tarih.year, tarih.month, tarih.day) + 1

# eğer varsa listeye ekler, yoksa list yaratılıp içerisine eklenir.
if gun in sinav_etkinlik:
sinav_etkinlik[gun].append(etkinlik)
else:
sinav_etkinlik[gun] = [etkinlik]
except:
pass

# bir günde bulunan sınavlar zamanına göre küçükten büyüğe sıralanır.
for etkinlik in sinav_etkinlik.keys():
sinav_etkinlik[etkinlik] = sorted(sinav_etkinlik[etkinlik],key = zamana_gore_sirala)

return sinav_etkinlik

def zamana_gore_sirala(sinav):
return sinav.tarih

# HAFTA bir tuple listesidir, method HAFTA'yı dictionary haline çevirir.
def hafta_gun_olustur(HAFTA):
hafta_dict = {}
for i in range(len(HAFTA)):
hafta_dict[HAFTA[i][0]] = HAFTA[i][1]

return hafta_dict

0 comments on commit 90dcfd5

Please sign in to comment.