Commit a8a22117 by aa.gusti

perbaikan captcha

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