def __init__(self, *args, **kwargs): super(BaseEventFilterForm, self).__init__(*args, **kwargs) q = Country.all().order('long_name') choices = [('all', 'All')] for c in q: choices.append( (c.key().name(), '%s [%s]'%(c.long_name, c.key().name())) ) self.fields['country'].choices = choices q = Region.all().order('long_name') choices = [('all', 'All')] for r in q: choices.append( (r.key().name(), '%s'%(r.long_name)) ) self.fields['region'].choices = choices
def get(self): if self.user: c = Country.all().order('-name') countries = list(c) s = Subregion.all().order('-name') subregion = list(s) wt = WineType.all().order('-name') wine_types = list(wt) g = Grape.all().order('-name') grapes = list(g) self.render("newwine.html",countries=countries, subregions=subregion, wine_types=wine_types, grapes=grapes) else: self.redirect("/login")
def entity_browser_body(self, *args): country_key = args[0] entity_list = None if country_key: entity_list = Entity.gql("where country=:country_key", country_key=country_key) else: member = self.current_member() country = Country.gql("WHERE name = :country_name", country_name=member.country).get() entity_list = Entity.gql("where country=:country_key", country_key=country.key()) param = self.render_parameters() param["entity_list"] = entity_list param["country_list"] = Country.all() return self.render("entity_browser_body", param)
def generate_events_per_country_list(): result = [] for c in Country.all(): result.append([c.key().name(), c.long_name, c.event_set.count()]) return result