Skip to content

Commit

Permalink
Update views.py
Browse files Browse the repository at this point in the history
  • Loading branch information
dpgaspar committed May 30, 2014
1 parent a1a0eb0 commit c68a3d4
Showing 1 changed file with 18 additions and 15 deletions.
33 changes: 18 additions & 15 deletions examples/quickcharts2/app/views.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from flask.ext.appbuilder.models.datamodel import SQLAModel
from flask.ext.appbuilder.models.datamodel import SQLAModel
from flask.ext.appbuilder.views import ModelView
from flask_appbuilder.charts.views import DirectChartView, GroupByChartView
from models import CountryStats, Country, PoliticalType
Expand All @@ -10,20 +10,23 @@
def fill_data():
countries = ['Portugal', 'Germany', 'Spain', 'France', 'USA', 'China','Russia','Japan']
politicals = ['Democratic', 'Authorative']

for country in countries:
c = Country(name=country)
db.session.add(c)
db.session.commit()
for political in politicals:
c = PoliticalType(name=political)
db.session.add(c)
db.session.commit()
for x in range(1,100):
cs = CountryStats()
cs.population = random.randint(1, 1000000)
cs.unemployed = random.randint(1, 100)
cs.college = random.randint(1, 100)
try:
for country in countries:
c = Country(name=country)
db.session.add(c)
db.session.commit()
for political in politicals:
c = PoliticalType(name=political)
db.session.add(c)
db.session.commit()
for x in range(1,100):
cs = CountryStats()
cs.population = random.randint(1, 1000000)
cs.unemployed = random.randint(1, 100)
cs.college = random.randint(1, 100)
except Exception as e:
log.error("Update ViewMenu error: {0}".format(str(e)))
self.get_session.rollback()


class CountryStatsModelView(ModelView):
Expand Down

0 comments on commit c68a3d4

Please sign in to comment.