def main(main_uri, rb_uri, sqla_uri, photo_path, drop, merged_avatars): update_session_options(db) # get rid of the zope transaction extension main_root, rb_root, app = setup(main_uri, rb_uri, sqla_uri) global tz try: tz = pytz.timezone(main_root['MaKaCInfo']['main'].getTimezone()) except KeyError: tz = pytz.utc start = time.clock() with app.app_context(): if drop: print cformat('%{yellow!}*** DANGER') print cformat('%{yellow!}***%{reset} ' '%{red!}ALL DATA%{reset} in your database %{yellow!}{!r}%{reset} will be ' '%{red!}PERMANENTLY ERASED%{reset}!').format(db.engine.url) if raw_input(cformat('%{yellow!}***%{reset} To confirm this, enter %{yellow!}YES%{reset}: ')) != 'YES': print 'Aborting' sys.exit(1) delete_all_tables(db) stamp() db.create_all() if Location.find().count(): # Usually there's no good reason to migrate with data in the DB. However, during development one might # comment out some migration tasks and run the migration anyway. print cformat('%{yellow!}*** WARNING') print cformat('%{yellow!}***%{reset} Your database is not empty, migration will most likely fail!') if raw_input(cformat('%{yellow!}***%{reset} To confirm this, enter %{yellow!}YES%{reset}: ')) != 'YES': print 'Aborting' sys.exit(1) migrate(main_root, rb_root, photo_path, merged_avatars) print 'migration took {} seconds'.format((time.clock() - start))
def _process(self): is_default = Location.find().count() == 0 db.session.add(Location(name=self._locationName, is_default=is_default)) flash(_(u'Location added'), 'success') self._redirect(urlHandlers.UHRoomBookingAdmin.getURL())
def has_data(self): return bool(Location.find().count())
def _process(self): is_default = Location.find().count() == 0 db.session.add(Location(name=self._locationName, is_default=is_default)) flash(_(u'Location added'), 'success') return redirect(url_for('rooms_admin.roomBooking-admin'))