Exemple #1
0
 def get(self, show_id=None):
     # If a show was specified
     if show_id:
         show = ndb.Key(Show, int(show_id)).get()
         context = {'show': show}
     else:
         tomorrow_start = get_tomorrow_start()
         # Get the future shows
         future_shows = Show.query(
             Show.scheduled > tomorrow_start).order(Show.scheduled).filter()
         # Get the previous shows
         previous_shows = Show.query(
                             Show.end_time != None).order(
                                 -Show.end_time).filter()
         context = {'future_shows': future_shows,
                    'previous_shows': previous_shows}
     self.response.out.write(template.render(self.path('other_shows.html'),
                                             self.add_context(context)))
Exemple #2
0
def scrape_all(venue):
    for show in venue.scrape():
        if Show.query(Show.url == show.get('url'), Show.date == show.get('date')).fetch():
            # import pdb; pdb.set_trace()
            continue
        new_show = Show(
            venue = show.get('venue'),
            title = show.get('title'),
            description = show.get('description'),
            date = show.get('date'),
            times = show.get('times'),
            prices = show.get('prices'),
            price_descriptions = show.get('price_descriptions'),
            url = show.get('url')
        )
        new_show.put()
	def get(self):
		context = {'shows': Show.query().fetch(),
				   'actions': Action.query(Action.used == False).fetch(),
				   'themes': Theme.query(Theme.used == False).fetch()}
		self.response.out.write(template.render(self.path('delete_tools.html'),
												self.add_context(context)))
	def post(self):
		deleted = None
		unused_deleted = False
		show_list = self.request.get_all('show_list')
		action_list = self.request.get_all('action_list')
		item_list = self.request.get_all('item_list')
		character_list = self.request.get_all('character_list')
		theme_list = self.request.get_all('theme_list')
		delete_unused = self.request.get_all('delete_unused')
		# If action(s) were deleted
		if action_list:
			for action in action_list:
				action_entity = ndb.Key(Action, int(action)).get()
				# Get all the related action votes and delete them
				action_votes = ActionVote.query(ActionVote.action == action_entity.key).fetch()
				for av in action_votes:
					av.key.delete()
				action_entity.key.delete()
			deleted = 'Action(s)'
		# If theme(s) were deleted
		if theme_list:
			for theme in theme_list:
				theme_entity = ndb.Key(Theme, int(theme)).get()
				# Get all the related theme votes and delete them
				theme_votes = ThemeVote.query(ThemeVote.theme == theme_entity.key).fetch()
				for tv in theme_votes:
					tv.key.delete()
				theme_entity.key.delete()
			deleted = 'Theme(s)'
		# If show(s) were deleted
		if show_list:
			for show in show_list:
				show_entity = ndb.Key(Show, int(show)).get()
				show_actions = ShowAction.query(ShowAction.show == show_entity.key).fetch()
				# Delete the actions that occurred within the show
				for show_action in show_actions:
					action = show_action.player_action.get().action
					if action:
						action.delete()
					show_action.player_action.delete()
					show_action.key.delete()
				# Delete player associations to the show
				show_players = ShowPlayer.query(ShowPlayer.show == show_entity.key).fetch()
				for show_player in show_players:
					show_player.key.delete()
				# Delete all Role votes
				role_votes = RoleVote.query(RoleVote.show == show_entity.key).fetch()
				for role_vote in role_votes:
					role_vote.key.delete()
				# Delete the theme used in the show, if it existed
				if show_entity.theme:
					show_entity.theme.delete()
				show_entity.key.delete()
				deleted = 'Show(s)'
		# Delete ALL un-used things
		if delete_unused:
			# Delete Un-used Actions
			unused_actions = Action.query(Action.used == False).fetch()
			for unused_action in unused_actions:
				# Get all the related action votes and delete them
				action_votes = ActionVote.query(ActionVote.action == unused_action.key).fetch()
				for av in action_votes:
					av.key.delete()
				# Delete the un-used actions
				unused_action.key.delete()
			deleted = 'All Un-used Actions'
		context = {'deleted': deleted,
				   'unused_deleted': unused_deleted,
				   'shows': Show.query().fetch(),
				   'actions': Action.query(Action.used == False).fetch(),
				   'themes': Theme.query(Theme.used == False).fetch()}
		self.response.out.write(template.render(self.path('delete_tools.html'),
												self.add_context(context)))
Exemple #5
0
def shows_this_week():
    today, next_week = week_interval()
    qry = Show.query(Show.date > today, Show.date <= next_week)
    qry.order(Show.date, Show.times)
    return qry.fetch()