Ejemplo n.º 1
0
    def add(cls, id='', s_date='', m_date='', file_no='', kootaj='', cert_no='', s_date_1='', s_date_2='',
            policy_1=False, policy_2=False, policy_3=False, policy_4=False, policy_5=False, policy_6=False,
            policy_7=False, ezharname=0, person_type=False, full_name='', card_no='', code_no='', company='',
            ez_full_name='', ez_owner='', ez_agent='', ez_card_no='', ez_code_no='', tr_full_name='', tr_code_no='',
            tr_reg_no='', tr_nationality='', tr_manager='', tr_type=False, item_name='', tariff_no='', paid=0,
            different=0, fine=0, diff_paid=0, vi_type_1=False, vi_type_2=False, vi_type_3=False, vi_type_4=False,
            vi_type_5=False, vi_type_6=False, vi_type_7=False, vi_type_other='', stated_tariff=0, stated_value=0,
            stated_weight=0, deducted_tariff=0, deducted_value=0, deducted_weight=0, law='', detector=0,
            detector_other='', results='', commitment=False, receip_no='', details='', locked=False):


        #TODO Something for this
        vi_type_1 = True if vi_type_1 == 'on' else False
        vi_type_2 = True if vi_type_2 == 'on' else False
        vi_type_3 = True if vi_type_3 == 'on' else False
        vi_type_4 = True if vi_type_4 == 'on' else False
        vi_type_5 = True if vi_type_5 == 'on' else False
        vi_type_6 = True if vi_type_6 == 'on' else False
        vi_type_7 = True if vi_type_7 == 'on' else False

        policy_1 = True if policy_1 == 'on' else False
        policy_2 = True if policy_2 == 'on' else False
        policy_3 = True if policy_3 == 'on' else False
        policy_4 = True if policy_4 == 'on' else False
        policy_5 = True if policy_5 == 'on' else False
        policy_6 = True if policy_6 == 'on' else False
        policy_7 = True if policy_7 == 'on' else False

        print('stated_weight: ' + str(stated_weight))
        print('deducted_weight: ' + str(deducted_weight))
        if id != '':
            obj = Model.objects(Kootaj=id).first()

        else:
            obj = Model()

        if obj != None:
            vi_type_1 = True
            obj.s_date = s_date
            #TODO it should use s_date
            obj.m_date = datetime.now()
            obj.file_no = file_no
            obj.kootaj = kootaj
            obj.cert_no = cert_no
            obj.s_date_1 = s_date_1
            obj.s_date_2 = s_date_2
            obj.policy_1 = policy_1
            obj.policy_2 = policy_2
            obj.policy_3 = policy_3
            obj.policy_4 = policy_4
            obj.policy_5 = policy_5
            obj.policy_6 = policy_6
            obj.policy_7 = policy_7
            obj.ezharname = ezharname
            obj.person_type = person_type
            obj.full_name = full_name
            obj.card_no = card_no
            obj.code_no = code_no
            obj.company = company
            obj.ez_full_name = ez_full_name
            obj.ez_owner = ez_owner
            obj.ez_agent = ez_agent
            obj.ez_card_no = ez_card_no
            obj.ez_code_no = ez_code_no
            obj.tr_full_name = tr_full_name
            obj.tr_code_no = tr_code_no
            obj.tr_reg_no = tr_reg_no
            obj.tr_nationality = tr_nationality
            obj.tr_manager = tr_manager
            obj.tr_type = tr_type
            obj.item_name = item_name
            obj.tariff_no = tariff_no
            obj.paid = paid
            obj.different = different
            obj.fine = fine
            obj.diff_paid = diff_paid
            obj.vi_type_1 = vi_type_1
            obj.vi_type_2 = vi_type_2
            obj.vi_type_3 = vi_type_3
            obj.vi_type_4 = vi_type_4
            obj.vi_type_5 = vi_type_5
            obj.vi_type_6 = vi_type_6
            obj.vi_type_7 = vi_type_7
            obj.vi_type_other = vi_type_other
            obj.stated_tariff = stated_tariff
            obj.stated_value = stated_value
            obj.stated_weight = stated_weight
            obj.deducted_tariff = deducted_tariff
            obj.deducted_value = deducted_value
            obj.deducted_weight = deducted_weight
            obj.law = law
            obj.detector = detector
            obj.detector_other = detector_other
            obj.results = results
            obj.commitment = commitment
            obj.receip_no = receip_no
            obj.details = details
            obj.m_rec_date = datetime.now()
            #TODO: Hard Code! convert not to shanmsi
            obj.s_rec_date = '1393-05-17'
            obj.locked = locked
            Debug.dprint(vi_type_1)

            obj.save()
        print('Controller.add inside is executed')
Ejemplo n.º 2
0
    redis_username = ''
    redis_password = ''
elif redis_server == 'customs_remote':
    #TODO: not set
    redis_host = '82.115.26.202'
    redis_port = 6379
    redis_username = ''
    redis_password = '******'
elif redis_server == 'office':
    redis_host = '192.168.1.173'
    redis_port = 6379
    redis_password = '******'
# elif redis_server == 'customs_remote_lan':
#     redis_host = '192.1.8.13'
#     redis_port = 6379
#     redis_username = ''
#     redis_password = ''

# Debug.dprint(text='Redis port')
# Debug.dprint(text=redis_port, type='data')
Debug.dprint(text='Mongo host')
Debug.dprint(text=mongo_host, type='data')
Debug.dprint(text='Redis host')
Debug.dprint(text=redis_host, type='data')
redis_instance = redis.StrictRedis(host=redis_host, port=redis_port, db=0)
# redis_instance = redis.StrictRedis(host=redis_host, port=redis_port, db=0, password=redis_password)
# redisInstance = redis.StrictRedis(host=redis_host, port=redis_port, db=0, password=redis_password)
# client = MongoClient('127.0.0.1', 27017)
client = MongoClient('192.1.8.14', 27017)
db = client.Customs
Ejemplo n.º 3
0
# a = Personnel()
# a.name = 'ehsan'
# a.create()



# from controllers.violation import Violation as Controller
# print Controller.find()
# print Controller.find()
# from connections import db
import json
from pymongo import MongoClient
from tools.debug import Debug
client = MongoClient('192.1.8.14', 27017)
db = client.Customs
collection = db.violation
records = list(collection.find())
# records =  list(collection.find())
# records =  json.dumps(list(collection.find()))
# records = collection.find().count()
# for item in records:
#     Debug.dprint(item['full_name'])

# from controllers.violation import Violation as Controller
from models.violation import Violation as Model
Debug.dprint(text=list(Model.objects()), type='custom')
# Debug.dprint(text=list(Model.objects(__raw__={'file_no': '123456'})), type='custom')
# Debug.dprint(text=str(Controller.find(_filter=filter)), type='custom')
# f = {'file_no': '123456'}
# Debug.dprint(text=str(f), type='error')
# Debug.dprint(text=str(Controller.find(_filter=f)), type='msg')