tambah alembic

1 parent 4c1464ca
Generic single-database configuration.
\ No newline at end of file \ No newline at end of file
from logging.config import fileConfig
from sqlalchemy import engine_from_config
from sqlalchemy import pool
from alembic import context
# this is the Alembic Config object, which provides
# access to the values within the .ini file in use.
config = context.config
# Interpret the config file for Python logging.
# This line sets up loggers basically.
if config.config_file_name is not None:
fileConfig(config.config_file_name)
# add your model's MetaData object here
# for 'autogenerate' support
# from myapp import mymodel
# target_metadata = mymodel.Base.metadata
target_metadata = None
# other values from the config, defined by the needs of env.py,
# can be acquired:
# my_important_option = config.get_main_option("my_important_option")
# ... etc.
def run_migrations_offline() -> None:
"""Run migrations in 'offline' mode.
This configures the context with just a URL
and not an Engine, though an Engine is acceptable
here as well. By skipping the Engine creation
we don't even need a DBAPI to be available.
Calls to context.execute() here emit the given string to the
script output.
"""
url = config.get_main_option("sqlalchemy.url")
context.configure(
url=url,
target_metadata=target_metadata,
literal_binds=True,
dialect_opts={"paramstyle": "named"},
)
with context.begin_transaction():
context.run_migrations()
def run_migrations_online() -> None:
"""Run migrations in 'online' mode.
In this scenario we need to create an Engine
and associate a connection with the context.
"""
connectable = engine_from_config(
config.get_section(config.config_ini_section, {}),
prefix="sqlalchemy.",
poolclass=pool.NullPool,
)
with connectable.connect() as connection:
context.configure(
connection=connection, target_metadata=target_metadata
)
with context.begin_transaction():
context.run_migrations()
if context.is_offline_mode():
run_migrations_offline()
else:
run_migrations_online()
"""${message}
Revision ID: ${up_revision}
Revises: ${down_revision | comma,n}
Create Date: ${create_date}
"""
from typing import Sequence, Union
from alembic import op
import sqlalchemy as sa
${imports if imports else ""}
# revision identifiers, used by Alembic.
revision: str = ${repr(up_revision)}
down_revision: Union[str, None] = ${repr(down_revision)}
branch_labels: Union[str, Sequence[str], None] = ${repr(branch_labels)}
depends_on: Union[str, Sequence[str], None] = ${repr(depends_on)}
def upgrade() -> None:
${upgrades if upgrades else "pass"}
def downgrade() -> None:
${downgrades if downgrades else "pass"}
...@@ -1047,34 +1047,35 @@ class BaseView(object): ...@@ -1047,34 +1047,35 @@ class BaseView(object):
# self.form_error(form, error) # self.form_error(form, error)
# def save_file(self, values, field, path=None, filename=None): def save_file(self, values, field, path=None, filename=None):
# if field in values and values[field]: if field in values and values[field]:
# value = values[field] value = values[field]
# file_name = value["filename"] file_name = value["filename"]
# ext = get_ext(file_name) ext = get_ext(file_name)
# if ext not in self.upload_exts: if ext not in self.upload_exts:
# raise InvalidExtension(self.upload_exts) raise InvalidExtension(self.upload_exts)
# if "fp" in value and value["fp"] and value["fp"] != b'': if "fp" in value and value["fp"] and value["fp"] != b'':
# if not path: if not path:
# path = get_params('tmp', '/tmp') path = BASE_CLASS.temp_files
# path = os.join(path, "upload") path = os.join(path, "upload")
# if not os.path.exists(path): if not os.path.exists(path):
# os.makedirs(path) os.makedirs(path)
# upload = Upload(path)
# resp = upload.save_fp(value) upload = Upload(path)
# if filename: resp = upload.save_fp(value)
# ext = get_ext(resp) if filename:
# new_resp = filename+ext ext = get_ext(resp)
# new_resp_full = os.path.join(path, new_resp) new_resp = filename+ext
# if os.path.isfile(new_resp_full): new_resp_full = os.path.join(path, new_resp)
# os.remove(new_resp_full) if os.path.isfile(new_resp_full):
os.remove(new_resp_full)
# os.rename(os.path.join(path, resp), new_resp_full)
# return new_resp os.rename(os.path.join(path, resp), new_resp_full)
# return resp return new_resp
# return value["filename"] return resp
return value["filename"]
def get_partner(self): def get_partner(self):
return Partner.query_email(self.req.user.email).first() return Partner.query_email(self.req.user.email).first()
......
...@@ -7,10 +7,10 @@ ...@@ -7,10 +7,10 @@
delete cstruct.get('delete')|''; delete cstruct.get('delete')|'';
maxsize field.widget.size|5242880; maxsize field.widget.size|5242880;
img ['jpg', 'jpeg', 'gif', 'png', 'svg', 'eps', 'psd']; img ['jpg', 'jpeg', 'gif', 'png', 'svg', 'eps', 'psd'];
video ['avi', 'mov', 'mpv'] video ['avi', 'mov', 'mp4']
"> ">
${field.start_mapping()} ${field.start_mapping()}
<div class="thumbnail"> <div class="thumbnail" tal:condition="ext in img or ext in video or ext=='pdf'">
<img tal:condition="ext in img" id="preview-${oid}" alt="" src="${preview_url}" style="${style}" <img tal:condition="ext in img" id="preview-${oid}" alt="" src="${preview_url}" style="${style}"
onload="window.URL.revokeObjectURL(this.src);"></img> onload="window.URL.revokeObjectURL(this.src);"></img>
<video tal:condition="ext in video" style="${style}" controls src="${preview_url}" type="video/${ext}" <video tal:condition="ext in video" style="${style}" controls src="${preview_url}" type="video/${ext}"
...@@ -22,10 +22,10 @@ ...@@ -22,10 +22,10 @@
id="preview-${oid}"> id="preview-${oid}">
Your browser does not support the video tag. Your browser does not support the video tag.
</video> </video>
<embed tal:condition="ext=='pdf'" src="${preview_url}" style="${style}" id="preview-${oid}"> <embed tal:condition="ext=='pdf'" src="${preview_url}" style="${style}" id="preview-${oid}">
</div> </div>
<a class="label label-default" href="${preview_url}" target="_blank" id="a-preview-${oid}"><i
<a tal:condition="ext" class="label label-default" href="${preview_url}" target="_blank" id="a-preview-${oid}"><i
class="fa fa-search"></i> View</a> class="fa fa-search"></i> View</a>
<input type="file" name="upload" id="${oid}" tal:attributes="style style; <input type="file" name="upload" id="${oid}" tal:attributes="style style;
......
<div tal:define="
oid oid|field.oid;" i18n:domain="deform">
<p class="deform-readonly-true" id="${oid}" i18n:translate="">
<span id="{$oid}-blok_kav_no">${blok_kav_no}</span>
<span id="{$oid}-rt">RT: ${rt}</span>
<span id="{$oid}-rw">RW: ${rw}</span>
</p>
</div>
\ No newline at end of file \ No newline at end of file
...@@ -130,8 +130,8 @@ class FormulirWidget(Widget): ...@@ -130,8 +130,8 @@ class FormulirWidget(Widget):
class BlokKavNoWidget(Widget): class BlokKavNoWidget(Widget):
template = "opensipkd.base:/views/widgets/blok_kav_no.pt" template = "opensipkd.base:./widgets/templates/blok_kav_no.pt"
readonly_template = "opensipkd.base:/views/widgets/readonly/blok_kav_no.pt" readonly_template = "opensipkd.base:./widgets/templates/readonly/blok_kav_no.pt"
_pstruct_schema = SchemaNode( _pstruct_schema = SchemaNode(
Mapping(), Mapping(),
...@@ -300,8 +300,8 @@ class AutocompleteMsInputWidget(AutocompleteInputWidget): ...@@ -300,8 +300,8 @@ class AutocompleteMsInputWidget(AutocompleteInputWidget):
class QtyWidget(Widget): class QtyWidget(Widget):
template = "opensipkd.base:/views/widgets/qty.pt" template = "opensipkd.base:/widgets/templates/qty.pt"
readonly_template = "opensipkd.base:/views/widgets/readonly/qty.pt" readonly_template = "opensipkd.base:/viewswidgets/templates/readonly/qty.pt"
_pstruct_schema = SchemaNode( _pstruct_schema = SchemaNode(
Mapping(), Mapping(),
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!