Exemplo n.º 1
0
 def import_data(cls):
   filenm ='fungsi_urusan.csv'
   with open(filenm, 'rb') as csvfile:
     reader = csv.DictReader(csvfile, delimiter=';', quotechar='"')
     for row in reader:
       print row
       fungsi_id = Fungsi.get_by_kode(row['fungsi']).id
       urusan_id = Urusan.get_by_kode(row['urusan']).id
       
       data = cls.get_by_kode(fungsi_id,urusan_id)
       if not data:
         data=cls()
         data.created = datetime.now()
         data.create_uid = 1
         data.fungsi_id = fungsi_id 
         data.urusan_id = urusan_id
       data.nama = row['nama'].strip()
       DBSession.add(data)
   DBSession.flush()
   DBSession.commit()
Exemplo n.º 2
0
 def import_data(cls):
   filenm ='unit.csv'
   with open(filenm, 'rb') as csvfile:
     reader = csv.DictReader(csvfile, delimiter=';', quotechar='"')
     for row in reader:
       print row
       kode = row['kode'].strip()
       data = cls.get_by_kode(kode)
       if not data:
         data=cls()
         data.kode = kode
         data.created = datetime.now()
         data.create_uid = 1
         #data.tahun = data.created.year 
         #data.level_id = data.kode.count('.')+1
         #data.parent_id = DBSession.query(Rekening.id).filter(Rekening.kode==data.kode[:data.kode.rfind('.')]).scalar()
         data.disabled = 0
         #data.defsign = 1
         data.urusan_id=Urusan.get_by_kode(row['urusan'].strip()).id
       data.nama = row['nama'].strip()
       DBSession.add(data)
   DBSession.flush()
   DBSession.commit()
Exemplo n.º 3
0
from base import *
from rekening import Rekening
from rekening_hukum import DasarHukum
from urusan import Urusan
from fungsi import Fungsi
from fungsi_urusan import FungsiUrusan
from unit import Unit
from program import Program
from kegiatan import Kegiatan

if __name__ == '__main__':
  Rekening.import_data()
  DasarHukum.import_data()
  Urusan.import_data()
  Fungsi.import_data()
  FungsiUrusan.import_data()
  Unit.import_data()
  Program.import_data()
  Kegiatan.import_data()