def update_country(request, run=None): """ Update country if given or all if not """ logging.info("%s" % os.environ.keys()) if "run" in request.POST: for country_code in COUNTRIES_CODE: logging.info("processing: %s" % country_code) Country.update(country_code) return HttpResponse("") else: #put in a taskqueue to taskqueue.add(url=reverse("country_update_country"), params={'run': "1"}) return HttpResponse("")
def developers_by_country(request, country_code): """ Show developers for a country """ country_code = country_code.upper() developers = Developer.all().filter('country =', country_code).fetch(1000) country = Country.get_by_key_name(country_code) if country is None: raise Http404 return render_to_response('country/country.html', {'developers': developers, 'country': country }, RequestContext(request))
def index(request): query = Developer.all() query.order('-sign_up_date') developers = query.fetch(100) countries = Country.all().filter("total >", 0).fetch(300) countries = sorted(countries, key=lambda x: unicode(x.name)) return render_to_response('index.html', {'developers': developers, 'countries': countries }, RequestContext(request))
def view_stats(request): """ Show AppEngine general stats """ countries = Country.all().filter("total >", 0).order("-total").fetch(250) #Get last stats stats = DeveloperStats.all().order("-timestamp").get() tags = TagStats.all().filter("developer_stats =", stats) tags = tags.order("-total").fetch(20) return render_to_response("stats/stats.html", {'stats': stats, 'countries': countries, 'tags': tags}, RequestContext(request))
class LanguageAdminChangeForm(forms.ModelForm): model = Language name = forms.ChoiceField(choices=Country.get_list()) status = forms.ChoiceField(choices=Language.LIST_STATUSES) main = forms.ChoiceField(choices=Language.LIST_STATUSES)
def test_str_method(self): country = Country(name='Demo', iso_2_digit='de') self.assertEqual(country.__str__(), country.name)