示例#1
0
 def get(self, record_id):
     item = RecordDB.get_full(record_id)
     self.context.update({
         'title': item['polnoe-naimenovanie'],
         'item': item
     })
     self.render('details.html')
示例#2
0
def send_export(filter_dict, email):
    count_all = RecordDB.get_count(filter_dict)
    pages_all = count_all / PER_FILE + 1
    filenames = []
    filename_base = 'base_' + datetime.now().strftime('%d.%m.%Y_%H:%M')
    for p in range(0, pages_all):
        filenames.append(export_list_to_excel(get_list_for_export(filter_dict, p), filename_base, p))

    body = ""
    if 'papka' in filter_dict:
        body = body + u'Регион: %s<br />' % filter_dict['papka']['$regex'][2:-2]
    if 'okved' in filter_dict:
        body = body + u'ОКВЭД: %s<br />' % filter_dict['okved']['$regex'][2:-2]
    if 'otrasl' in filter_dict:
        body = body + u'Отрасль: %s<br />' % filter_dict['otrasl']['$regex'][2:-2]
    body = body + u'Файлы во вложении.'

    send_mail_with_attach(email,
                        u'База',
                        body,
                        filenames)
示例#3
0
def get_list_for_export(filter_dict, page):
    "Возращает отпагинированный список для модели db_model и страницы page_num"
    cursor = RecordDB.get_id_cursor(filter_dict)
    items = [RecordDB.get_middle(x.id) for x in cursor.skip(page * PER_FILE).limit(PER_FILE)]
    return items
示例#4
0
	                    'okpo': record_raw[22],
	                    'inn': record_raw[23],
	                    'ogrn': record_raw[24],
	                    'kpp': record_raw[25],
                    	}
		    else:
			data = {
                    		'papka': folder_name,
                    		'fajl': file_name,
	                    	'naimenovanie': record_raw[0],
	                    	'polnoe-naimenovanie': record_raw[1],
	                    	'rukovoditel': record_raw[2],
	                    	'data-registratsii': record_raw[3],
	                    	'yuridicheskij-adres': record_raw[4],
	                    	'telefon': record_raw[5],
	                    	'region': record_raw[6],
	                    	'otrasl': record_raw[7]}
                    RecordDB.create_from_data(data)
		except:
                    print u'Ошибка в файле %s.' % u'/'.join([folder_name, file_name])
                    if not os.path.exists(u'/'.join([ERRORS_FOLDER, folder_name])):
                        os.makedirs(u'/'.join([ERRORS_FOLDER, folder_name]))
                    os.rename(u'/'.join([REGIONS_FOLDER, folder_name, file_name]), u'/'.join([ERRORS_FOLDER, folder_name, file_name]))
                    can_remove = False
                    break
	    if can_remove:
	        os.remove('/'.join([REGIONS_FOLDER, folder_name, file_name]))
	        print 'ok'
        else:
            print u'Непонятный формат. Файл не обработан.'