Add shippingpending and pickuppending status
parent
79a9480165
commit
3a3b58c523
|
@ -17,6 +17,8 @@ class Status(enum.Enum):
|
|||
spam = 6
|
||||
delegated = 7
|
||||
intransit = 8
|
||||
shippingpending = 9
|
||||
pickuppending = 10
|
||||
|
||||
|
||||
class PostalCode(db.Model):
|
||||
|
|
|
@ -0,0 +1,56 @@
|
|||
"""Add pickuppending/shippingpending status
|
||||
|
||||
Revision ID: fc0fbabc5fb6
|
||||
Revises: 6e57deac23f2
|
||||
Create Date: 2020-04-09 16:21:00.191895
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = 'fc0fbabc5fb6'
|
||||
down_revision = '6e57deac23f2'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
old_options = ('new', 'confirmed', 'allocated', 'fulfilled', 'rejected', 'spam', 'delegated', 'intransit')
|
||||
new_options = sorted(old_options + ('shippingpending','pickuppending'))
|
||||
|
||||
old_type = sa.Enum(*old_options, name='status')
|
||||
new_type = sa.Enum(*new_options, name='status')
|
||||
tmp_type = sa.Enum(*new_options, name='_status')
|
||||
|
||||
fsr = sa.sql.table('faceshield_request',
|
||||
sa.Column('status', new_type, nullable=False))
|
||||
|
||||
def upgrade():
|
||||
# Create a tempoary "_status" type, convert and drop the "old" type
|
||||
tmp_type.create(op.get_bind(), checkfirst=False)
|
||||
op.execute('ALTER TABLE faceshield_request ALTER COLUMN status DROP DEFAULT, ALTER COLUMN status TYPE _status'
|
||||
' USING status::text::_status')
|
||||
old_type.drop(op.get_bind(), checkfirst=False)
|
||||
# Create and convert to the "new" status type
|
||||
new_type.create(op.get_bind(), checkfirst=False)
|
||||
op.execute('ALTER TABLE faceshield_request ALTER COLUMN status TYPE status'
|
||||
' USING status::text::status, ALTER COLUMN status SET DEFAULT \'new\'::status')
|
||||
tmp_type.drop(op.get_bind(), checkfirst=False)
|
||||
|
||||
|
||||
def downgrade():
|
||||
op.execute(fsr.update().where(fsr.c.status==u'shippingpending')
|
||||
.values(status='intransit'))
|
||||
op.execute(fsr.update().where(fsr.c.status==u'pickupppending')
|
||||
.values(status='allocated'))
|
||||
|
||||
# Create a tempoary "_status" type, convert and drop the "new" type
|
||||
tmp_type.create(op.get_bind(), checkfirst=False)
|
||||
op.execute('ALTER TABLE faceshield_request ALTER COLUMN status DROP DEFAULT, ALTER COLUMN status TYPE _status'
|
||||
' USING status::text::_status')
|
||||
new_type.drop(op.get_bind(), checkfirst=False)
|
||||
# Create and convert to the "old" status type
|
||||
old_type.create(op.get_bind(), checkfirst=False)
|
||||
op.execute('ALTER TABLE faceshield_request ALTER COLUMN status TYPE status'
|
||||
' USING status::text::status, ALTER COLUMN status SET DEFAULT \'new\'::status')
|
||||
tmp_type.drop(op.get_bind(), checkfirst=False)
|
|
@ -3,7 +3,7 @@
|
|||
{% block details_table %}
|
||||
<p>
|
||||
<a href="{{ url_for('map.index', id=model.id) }}" title="Show on map"><span class="fa fa-pencil glyphicon glyphicon-map-marker"></span> Show on map</a>
|
||||
<a href="{{ url_for('faceshieldrequest.label', id=model.id) }}" title="Render package label"><span class="glyphicon glyphicon-print"></span> Render package label</a>
|
||||
<a href="{{ url_for('faceshieldrequest.label', id=model.id) }}" title="Print label"><span class="glyphicon glyphicon-print"></span> Print label</a>
|
||||
</p>
|
||||
{{ super() }}
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
</li>
|
||||
{%- endif -%}
|
||||
<li>
|
||||
<a href="{{ url_for('faceshieldrequest.label', id=model.id) }}" title="Render package label"><span class="glyphicon glyphicon-print"></span> Render package label</a>
|
||||
<a href="{{ url_for('faceshieldrequest.label', id=model.id) }}" title="Print label"><span class="glyphicon glyphicon-print"></span> Print label</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="{{ url_for('map.index', id=model.id) }}" title="Show on map"><span class="glyphicon glyphicon-map-marker"></span> Show on map</a>
|
||||
|
|
Loading…
Reference in New Issue