Commit a8a22117 by aa.gusti

perbaikan captcha

1 parent 4d23405e
from __future__ import print_function
import os
import re
import mimetypes
import csv
import calendar
import csv
import datetime
import io
import locale
import logging
import mimetypes
import os
import re
from json import JSONEncoder
from random import choice
from string import (ascii_uppercase, ascii_lowercase, digits, )
import locale
import colander
import pytz
import io
from pyramid.httpexceptions import HTTPNotFound
from pyramid.threadlocal import get_current_registry
from json import JSONEncoder
import logging
log = logging.getLogger(__name__)
################
# Phone number #
################
MSISDN_ALLOW_CHARS = map(lambda x: str(x), range(10)) # + ['+']
class CSRFSchema(colander.Schema):
def after_bind(self, schema, kwargs):
request = kwargs["request"]
......@@ -34,6 +34,7 @@ class CSRFSchema(colander.Schema):
default=csrf_token
)
def get_msisdn(msisdn, country='+62'):
"""
Digunakan untuk pengecekan no telp suatu negara
......@@ -474,7 +475,7 @@ def file_response(request, f, filename, type):
class Upload(SaveFile):
def save_to_file(self, input_file, ext, filename=None):
if filename:
fullpath = os.path.join(self.dir_path, filename, ext)
fullpath = os.path.join(self.dir_path, f"{filename}")
else:
fullpath = self.create_fullpath(ext)
log.debug(f"Saving file to: {fullpath}")
......@@ -491,6 +492,7 @@ class Upload(SaveFile):
def save(self, request, name, exts=None, filename=None):
input_file = request.POST[name].file
ext = get_ext(request.POST[name].filename)
ext = ext and ext.lower() or None
if exts and ext not in exts:
raise InvalidExtension(exts)
......@@ -500,7 +502,7 @@ class Upload(SaveFile):
def save_fp(self, upload):
if 'fp' not in upload or upload['fp'] == b'' or not upload['fp'] or not \
upload['size']:
upload['size']:
if "filename" in upload:
return upload['filename']
return
......@@ -1054,4 +1056,4 @@ def create_static_path(config, folder, url, cache_max_age=3600):
def includeme(config):
# config.add_translation_dirs('opensipkd.tools:locale/')
pass
pass
\ No newline at end of file
......@@ -45,4 +45,4 @@ def randomcaptcha(length, chars=string.ascii_uppercase + string.digits):
def get_captcha(request):
kode_captcha, file_name = img_captcha(request)
request.session['captcha'] = kode_captcha
return file_name
return file_name
\ No newline at end of file
......@@ -284,25 +284,26 @@ def nop_to_id(row):
def query_nop(table):
return func.concat(table.kd_propinsi, func.concat('.',
func.concat(table.kd_dati2, func.concat('-',
func.concat(
table.kd_kecamatan,
func.concat(
'.',
func.concat(
table.kd_kelurahan,
func.concat(
'-',
func.concat(
table.kd_blok,
func.concat(
'.',
func.concat(
table.no_urut,
func.concat(
'-',
table.kd_jns_op))))))))))))
return func.concat(table.kd_propinsi,
func.concat('.',
func.concat(table.kd_dati2, func.concat('-',
func.concat(
table.kd_kecamatan,
func.concat(
'.',
func.concat(
table.kd_kelurahan,
func.concat(
'-',
func.concat(
table.kd_blok,
func.concat(
'.',
func.concat(
table.no_urut,
func.concat(
'-',
table.kd_jns_op))))))))))))
# JEnis REstitusi Kompensasi
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!