Ejemplo n.º 1
0
    def get(self):
        '''
        The class serving the page for showing statistics about countries.
        '''
        # Init selectable countries
        selectable_countries = ['India', 'Pakistan', 'Bangladesh', 'United States', 'Vietnam', 'Romania',
            'United Kingdom', 'Philippines', 'China', 'Sri Lanka', 'Ukraine', 'Canada', 'Egypt', 'Australia',
            'Indonesia', 'Serbia and Montenegro', 'Bulgaria', 'Nepal', 'Poland', 'Russian Federation',
            'Argentina', 'Italy', 'Spain', 'Brazil', 'Portugal', 'Germany', 'Turkey', 'Malaysia', 'Kenya',
            'United Arab Emirates', 'Florida', 'Mexico', 'Nigeria', 'France', 'Greece', 'Morocco', 'Bolivia',
            'Moldova', 'Croatia', 'South Africa', 'Sweden', 'Iran', 'Bosnia and Herzegovina', 'Macedonia',
            'Singapore', 'Belarus', 'Hungary', 'Tunisia', 'Algeria', 'Peru', 'Netherlands', 'Hong Kong',
            'Saudi Arabia', 'Israel', 'New Zealand', 'Estonia', 'Colombia', 'Denmark', 'Lithuania', 'Thailand',
            'Armenia', 'Switzerland', 'Austria', 'Uruguay', 'Japan', 'Cyprus', 'Venezuela', 'Czech Republic',
            'Kazakhstan', 'Slovak Republic', 'Albania', 'Dominican Republic', 'Lebanon', 'Slovenia', 'Chile',
            'Mauritius', 'Ireland', 'Belgium', 'Latvia', 'Palestine', 'Jamaica', 'Georgia', 'Cameroon', 'Gambia',
            'Puerto Rico', 'Qatar', 'Jordan', 'Costa Rica', 'Finland', 'El Salvador', 'Panama', 'Ethiopia', 'Norway'];
        selectable_countries.sort();
        
        # Get the selected countries
        countries = self.request.get_all("country")
        countries = [j for j in countries if j in selectable_countries]
        log.info("Stats for countries: " + ",".join(countries))
        
        #Get the stats from the database
        stats = CountryStats.all()
        stats.filter("country IN", countries)
        expanded_stats = []
        for s in stats:
            s.expand()
            log.info(s);
            expanded_stats.append(s)
        countries = [c.country for c in stats]
        expanded_stats.sort(key=lambda x: x.country)
        
        #Get the outbound bids from the database
        bids = OutBidderBehavior.all()
        bids.filter("country IN", countries)
        expanded_bids = []
        for b in bids:
            b.expand()
            log.info(b);
            expanded_bids.append(b)
        expanded_bids.sort(key=lambda x: x.country)

        #Generate the page
        template_values = { 'selectable_countries': selectable_countries, 'countries':countries,
                'stats': expanded_stats, 'bids': expanded_bids }
        
        template = jinja_environment.get_template('templates/country_stats.html')
        self.response.out.write(template.render(template_values))
Ejemplo n.º 2
0
    def get(self):
        '''
        The class serving the page for information about bids
        '''
        # Init selectable countries
        selectable_countries = [
            "United States", "Australia", "United Kingdom", "Canada", "India",
            "Germany", "Pakistan", "Bangladesh", "Netherlands", "France",
            "Italy", "Singapore", "Spain", "Sweden", "Denmark", "Israel",
            "Norway", "Malaysia", "Hong Kong"
        ]
        selectable_countries.sort()

        # Get countries for biddings
        countries = self.request.get_all("country")
        countries = [j for j in countries if j in selectable_countries]
        log.info("Bids for countries: " + ",".join(countries))

        #Get the behaviors from the database
        behaviors = AcceptedBidderBehavior.all()
        behaviors.filter("country IN", countries)
        expanded_behaviors = []
        for b in behaviors:
            b.expand()
            expanded_behaviors.append(b)
            log.info(b)
        expanded_behaviors.sort(key=lambda x: x.country)
        countries = [c.country for c in expanded_behaviors]

        #Get the outbound bids from the database
        bids = OutBidderBehavior.all()
        bids.filter("country IN", countries)
        expanded_bids = []
        for b in bids:
            b.expand()
            log.info(b)
            expanded_bids.append(b)
        expanded_bids.sort(key=lambda x: x.country)

        # Generate the page
        template_values = {
            "countries": countries,
            'selectable_countries': selectable_countries,
            'accepted_bids': expanded_behaviors,
            'out_bids': expanded_bids
        }

        template = jinja_environment.get_template('templates/bids.html')
        self.response.out.write(template.render(template_values))
Ejemplo n.º 3
0
 def get(self):
     '''
     The class serving the page for information about bids
     '''
     # Init selectable countries
     selectable_countries = ["United States", "Australia", "United Kingdom", "Canada",
     "India", "Germany", "Pakistan", "Bangladesh", "Netherlands", "France",
     "Italy", "Singapore", "Spain", "Sweden", "Denmark", "Israel", "Norway",
     "Malaysia", "Hong Kong"];
     selectable_countries.sort();
     
     # Get countries for biddings
     countries = self.request.get_all("country")
     countries = [j for j in countries if j in selectable_countries]
     log.info("Bids for countries: " + ",".join(countries))
     
     #Get the behaviors from the database
     behaviors = AcceptedBidderBehavior.all()
     behaviors.filter("country IN", countries)
     expanded_behaviors = []
     for b in behaviors:
         b.expand()
         expanded_behaviors.append(b)
         log.info(b);
     expanded_behaviors.sort(key=lambda x: x.country)
     countries = [c.country for c in expanded_behaviors]
     
     #Get the outbound bids from the database
     bids = OutBidderBehavior.all()
     bids.filter("country IN", countries)
     expanded_bids = []
     for b in bids:
         b.expand()
         log.info(b);
         expanded_bids.append(b)
     expanded_bids.sort(key=lambda x: x.country)    
             
     # Generate the page
     template_values = { "countries": countries, 'selectable_countries': selectable_countries, 'accepted_bids': expanded_behaviors, 'out_bids': expanded_bids  }
     
     template = jinja_environment.get_template('templates/bids.html')
     self.response.out.write(template.render(template_values))