Skip to content

Commit

Permalink
Merge pull request #759 from GFDRR/missing_categories
Browse files Browse the repository at this point in the history
Add missing categories records
  • Loading branch information
tonio authored May 29, 2017
2 parents c64c237 + 9b83adc commit ab828cd
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ thinkhazard/static/build/%.css: $(LESS_FILES) .build/node_modules.timestamp
-e 's#{{WSGISCRIPT_ADMIN}}#$(abspath .build/thinkhazard_admin-$*.wsgi)#' $< > $@

.build/wkhtmltox:
curl -o- http://download.gna.org/wkhtmltopdf/0.12/0.12.3/wkhtmltox-0.12.3_linux-generic-amd64.tar.xz | tar -xvJ
wget https://github.com/DM87/yocaza/raw/master/wkhtmltox-0.12.3_linux-generic-amd64.tar.xz && tar -xv -f wkhtmltox-0.12.3_linux-generic-amd64.tar.xz
mv wkhtmltox .build

.PRECIOUS: node_modules/font-awesome/fonts/fontawesome-webfont.%
Expand Down
48 changes: 48 additions & 0 deletions alembic/versions/8f08766e4541_add_category_for_urban_flood.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
"""Add category for Urban Flood, Wild Fire & Air Pollution
Revision ID: 8f08766e4541
Revises: 2a26a7ae26a0
Create Date: 2017-05-29 12:24:46.523502
"""

# revision identifiers, used by Alembic.
revision = '8f08766e4541'
down_revision = '2a26a7ae26a0'
branch_labels = None
depends_on = None

from alembic import op
import sqlalchemy as sa
from thinkhazard.models import HazardType, HazardCategory, HazardLevel

hazardtype = HazardType.__table__
hazardlevel = HazardLevel.__table__
hazardcategory = HazardCategory.__table__

def upgrade(engine_name):

for htype in ['UF', 'WF', 'AP']:
for level in ['VLO', 'LOW', 'MED', 'HIG']:
op.execute(hazardcategory.insert().values(
hazardtype_id=sa.select(
[hazardtype.c.id],
hazardtype.c.mnemonic==op.inline_literal(htype)
),
hazardlevel_id=sa.select(
[hazardlevel.c.id],
hazardlevel.c.mnemonic==op.inline_literal(level)
),
general_recommendation=op.inline_literal(
'General recommendation for %s %s' % (htype, level))
))


def downgrade(engine_name):
for htype in ['UF', 'WF', 'AP']:
op.execute(hazardcategory.delete().where(
hazardcategory.c.hazardtype_id==sa.select(
[hazardtype.c.id],
hazardtype.c.mnemonic==op.inline_literal(htype)
)
))

0 comments on commit ab828cd

Please sign in to comment.